@camunda/copilot-chat 0.8.1-alpha.4 → 0.8.1-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,12 +38,19 @@ import {
38
38
  CopilotConversationPanel,
39
39
  createFixtureClient,
40
40
  } from '@camunda/copilot-chat';
41
+ import type { OpenDraftReviewInput } from '@camunda/copilot-chat';
41
42
  import '@camunda/copilot-chat/style.css';
42
43
  import { useState } from 'react';
43
44
 
44
45
  const client = createFixtureClient();
45
46
 
46
- function App() {
47
+ function App({
48
+ host,
49
+ }: {
50
+ host: {
51
+ openDraftReview(input: OpenDraftReviewInput): void;
52
+ };
53
+ }) {
47
54
  const [conversationId, setConversationId] = useState<string | null>(null);
48
55
 
49
56
  return (
@@ -52,6 +59,7 @@ function App() {
52
59
  conversationId={conversationId}
53
60
  onConversationStarted={setConversationId}
54
61
  onSelectConversation={setConversationId}
62
+ openDraftReview={host.openDraftReview}
55
63
  />
56
64
  );
57
65
  }
@@ -89,8 +97,8 @@ context in `postMessage`; these props only describe the project.
89
97
  Pass `readOnlyReason` when the selected conversation can no longer accept
90
98
  messages, for example because its project was deleted. The composer is
91
99
  disabled and shows the reason, and stale proposals can no longer be reapplied;
92
- stopping a running turn and reviewing proposals
93
- stay available, as do the chat list and new chats.
100
+ stopping a running turn and reading the conversation stay available, as do the
101
+ chat list and new chats.
94
102
 
95
103
  ## Naming conversations
96
104
 
@@ -102,7 +110,7 @@ elsewhere in Hub: Rename stays disabled until the trimmed name is non-empty and
102
110
  differs from the current one; Enter renames; Escape, Cancel, or the close
103
111
  button leave the name unchanged; focus returns to the actions button. The new
104
112
  name shows at once; if the request fails, the previous name returns and the row
105
- shows an error. Without `renameConversation`, no actions menu is offered.
113
+ shows an error.
106
114
 
107
115
  Adapters resolve with the conversation's updated summary. The server trims the
108
116
  name and rejects it when blank or longer than `CONVERSATION_NAME_MAX_LENGTH`
@@ -173,7 +181,7 @@ Streamdown's sanitization, external-link safety and image behavior.
173
181
 
174
182
  The host owns authorized project/file resolution, accessibility, current-target
175
183
  availability, preview cleanup and explicit navigation. The fragment never supplies
176
- a project or authorizes access, model edits, proposal approval or a new turn.
184
+ a project or authorizes access, draft application or a new turn.
177
185
  Preserve the historical label and explain unavailable targets explicitly rather
178
186
  than resolving a different element by name.
179
187
 
@@ -183,25 +191,32 @@ and unavailable targets. Its explicitly mocked controls exercise rendering and
183
191
  keyboard behavior only, not BPMN navigation. Add `?hostless` to exercise inert
184
192
  fallback without a renderer.
185
193
 
186
- ## Reviewing proposed changes
187
-
188
- `CopilotConversationPanel` accepts a `renderReview(candidate, { approve, reject })`
189
- callback for host-owned review flows. When provided, its return value replaces
190
- the inline approve/reject controls for pending candidates. Hosts should present
191
- the candidate's changes (including their `before` and `content` snapshots)
192
- before calling `approve`; the exported `CandidateReview` renders BPMN diagrams
193
- and text diffs. Both actions return promises, so the host can display progress
194
- and keep the review open if an action fails. Failed actions reject their promises;
195
- the host owns error presentation in its review flow.
196
- While a proposal awaits approval or rejection, the composer is disabled for
197
- that conversation. Other conversations remain available. The backend also
198
- rejects new turns until the proposal is resolved.
194
+ ## Conversation drafts
195
+
196
+ The conversation snapshot owns one optional `Draft`, with a monotonically
197
+ increasing `generation` and artifact-level access, validation, and live-version
198
+ divergence. When the conversation is idle, the panel shows a compact
199
+ **Proposed changes** row below the transcript with a **Review changes** action.
200
+ The required `openDraftReview` host callback receives only `{ conversationId, draftId }`;
201
+ the host opens the all-files review and checks the current draft and
202
+ permissions. Opening review does not authorize writes or confirm a generation.
203
+ The latest apply appears as a checkpoint in the transcript. Restoring it uses
204
+ `undoApply` for the whole apply, not the host's single-file version action.
205
+
206
+ Applying a draft sends its exact `draftId`, `reviewedGeneration`, and any
207
+ confirmed live fingerprints. The host must reject a stale generation rather
208
+ than apply edits the user has not reviewed. Apply results distinguish success,
209
+ a changed draft that must be reviewed again, and access or policy blocks.
210
+ Discarding selected artifacts, reverting changes from a turn, updating from
211
+ live, and undoing the last apply are separate conversation-scoped operations.
212
+ An open draft does not disable sending another turn; subsequent turns update
213
+ the same draft.
199
214
 
200
215
  While a turn is running, the message input and suggestions are disabled and no
201
- additional message can be submitted. Stop remains available; sending resumes after
202
- the turn finishes or is stopped, provided no proposal awaits review. Rejected submissions show an inline
203
- error and preserve the draft for retry. Messages are not queued or automatically
204
- used to interrupt a running turn.
216
+ additional message can be submitted. Stop remains available; sending resumes
217
+ after the turn finishes or is stopped. Rejected submissions show an inline
218
+ error and preserve the prompt for retry. Messages are not queued or
219
+ automatically used to interrupt a running turn.
205
220
 
206
221
  Pending or unconfirmed remote stops block Send, but not Stop. Snapshot polling
207
222
  continues even when the transcript is idle so a missed stop-confirmation event
@@ -217,46 +232,37 @@ affected files before restoring their earlier state. Cancel or Escape leaves the
217
232
  unchanged; restoring preserves chat history. Failed restores remain in the dialog
218
233
  with an error and can be retried.
219
234
 
220
- Async `CopilotClient` adapters should call the optional third `observe` argument
221
- after each connection or reconnection. The panel refreshes its snapshot at that
222
- point to recover events missed while connecting. The HTTP adapter does this on
223
- SSE open; two-argument synchronous adapters remain supported.
224
-
225
- An open conversation refreshes its snapshot every five seconds while running
226
- or while a remote stop remains pending or unconfirmed, until an idle snapshot
227
- with no unresolved stop has been fetched. Missing realtime completion events
228
- therefore do not require a page reload. Online and visibility-resume events also
229
- refresh the snapshot. Requests are serialized and reconnect/lifecycle refreshes
230
- are coalesced. Failed requests retry with backoff, capped at 30 seconds; the panel
231
- shows a synchronization warning and disables submissions until recovery. It does
232
- not infer success or cancel provider work when synchronization fails.
233
-
234
- Adapters may use the optional fourth `observe` argument to report an `Error` after
235
- a transport or parsing failure. The observer then refreshes the snapshot. The HTTP
236
- adapter reports SSE errors and malformed JSON this way.
237
-
238
- Snapshots, summaries, and events optionally carry a monotonically increasing
239
- numeric `revision` per conversation. Once a revision is present, older or
240
- unversioned updates are ignored. Events at the same revision may carry different
241
- parts of one change; revisions are not event IDs. Hosts must supply consistent
242
- revisions across all three surfaces to enable this protection. Existing unversioned
243
- adapters remain supported: events arriving during a snapshot request invalidate
244
- that response and cause a later refresh. Without server revisions, the library
245
- cannot identify stale server responses or all delayed events.
235
+ `getConversation(id)` returns the newest message page and an opaque `olderCursor`
236
+ (`null` at the start of history). The panel requests older pages with
237
+ `getOlderMessages(id, cursor)` on demand. Since the initial page, it calls
238
+ `getChanges(id, since)` and merges complete message rows by `messageId` and row
239
+ `revision`, ordered by `sequence`. Changes replace the whole draft when present:
240
+ omitted means unchanged; `null` means cleared.
241
+
242
+ The header `revision` is the covered watermark for `since`, not the largest row
243
+ revision. A read may contain newer rows without covering all intervening changes.
244
+ `observe` delivers only `{ chatId, revision }` notices. Adapters call the optional
245
+ connection callback on connect and reconnect and may report transport failures
246
+ through the optional error callback. The panel coalesces catch-up requests and
247
+ polls every ten seconds while running or while a remote stop is unresolved.
248
+ Synchronization errors block submissions until recovery.
249
+ When the read scope changes, adapters send `{ chatId, revision, reset: true }`
250
+ even if the revision is unchanged. The panel discards cached details and
251
+ in-flight reads from the old scope and loads the newest page again.
246
252
 
247
253
  Polling only repairs browser state from the backend's snapshot. It cannot repair
248
254
  a backend that has not persisted completion, and a suspended/offline browser or
249
255
  a request that never settles has no bounded convergence guarantee. Unmounting
250
256
  stops observation, timers, and browser listeners; it never cancels a turn.
251
257
 
252
- `CandidateReview.onReviewReady` reports true only when every artifact is ready.
253
- Fixture scripts must supply `before` for modifications to support restore;
254
- otherwise approval has no checkpoint. Only created files restore to absence.
258
+ Fixture scripts may supply `before` for modifications to make the fixture's
259
+ last-apply restore action available; without a known prior value the fixture
260
+ does not offer a partial restore.
255
261
 
256
262
  ## Organization availability
257
263
 
258
- Adapters can implement `getAvailability()` and include snapshot `availability`
259
- as `{ state: 'enabled' | 'organization_disabled', policyVersion: string }`.
264
+ Adapters implement `getAvailability()` and include snapshot `availability` as
265
+ `{ state: 'enabled' | 'organization_disabled', policyVersion: string }`.
260
266
  The panel reconciles both sources by local request order: a response from an
261
267
  older request cannot replace a result accepted from a newer request.
262
268
  `policyVersion` is opaque and is never sorted. Snapshots omitting availability
@@ -264,8 +270,9 @@ do not replace a known endpoint result.
264
270
 
265
271
  The endpoint is checked before protected actions and on online/visible resume,
266
272
  including on the conversation list. Failed lookups block changes and offer
267
- retry. Disabled availability preserves the transcript, Stop, and local proposal
268
- dismissal, but blocks new prompts, answers, approval, reapply, and Restore.
273
+ retry. Disabled availability preserves the transcript and Stop, but blocks new
274
+ prompts, answers, draft apply, live update, revert, and Restore. Draft
275
+ dismissal remains available.
269
276
  Denied actions are not automatically replayed.
270
277
 
271
278
  ## Questions from Copilot
@@ -287,10 +294,8 @@ delivery status. One question may be actionable per conversation. Keep the
287
294
  conversation `running` and its assistant message `streaming` while awaiting
288
295
  input; provider "requires action" is not turn completion.
289
296
 
290
- Implement optional `CopilotClient.answerQuestion(AnswerQuestionInput)` to enable
291
- answers. Existing adapters without Q&A remain supported; a pending question
292
- from an adapter without that action displays an explicit unsupported message.
293
- The HTTP client posts the answer fields (excluding the two path identities) to
297
+ `CopilotClient.answerQuestion(AnswerQuestionInput)` sends answers. The HTTP
298
+ client posts the answer fields (excluding the two path identities) to
294
299
  `/conversations/{conversationId}/questions/{questionId}/answer` relative to
295
300
  `baseUrl`. Hosts with other routes map this action in their adapter.
296
301
 
@@ -1,4 +1,4 @@
1
- import { R as c, L as f, A as d } from "./index-DAyxug2G.js";
1
+ import { R as c, L as f, A as d } from "./index-CNP5V04Z.js";
2
2
  import { useContext as p, useState as L, useEffect as N } from "react";
3
3
  import { jsx as x } from "react/jsx-runtime";
4
4
  var A = ({ code: s, language: e, raw: a, className: o, startLine: m, lineNumbers: u, ...g }) => {