@camunda/copilot-chat 0.8.1-alpha.3 → 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,24 +191,36 @@ 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.
195
- While a proposal awaits approval or rejection, the composer is disabled for
196
- that conversation. Other conversations remain available. The backend also
197
- 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.
198
214
 
199
215
  While a turn is running, the message input and suggestions are disabled and no
200
- additional message can be submitted. Stop remains available; sending resumes after
201
- the turn finishes or is stopped, provided no proposal awaits review. Rejected submissions show an inline
202
- error and preserve the draft for retry. Messages are not queued or automatically
203
- 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.
220
+
221
+ Pending or unconfirmed remote stops block Send, but not Stop. Snapshot polling
222
+ continues even when the transcript is idle so a missed stop-confirmation event
223
+ can recover; polling stops once no turn or unresolved stop remains.
204
224
 
205
225
  Failed chat-list reads (including initial load, reconnect, visibility resume and
206
226
  Back navigation) retain cached rows and display a retryable error in the Chats
@@ -212,40 +232,48 @@ affected files before restoring their earlier state. Cancel or Escape leaves the
212
232
  unchanged; restoring preserves chat history. Failed restores remain in the dialog
213
233
  with an error and can be retried.
214
234
 
215
- Async `CopilotClient` adapters should call the optional third `observe` argument
216
- after each connection or reconnection. The panel refreshes its snapshot at that
217
- point to recover events missed while connecting. The HTTP adapter does this on
218
- SSE open; two-argument synchronous adapters remain supported.
219
-
220
- An open conversation refreshes its snapshot every five seconds while running,
221
- until a terminal snapshot has been fetched. Missing realtime completion events
222
- therefore do not require a page reload. Online and visibility-resume events also
223
- refresh the snapshot. Requests are serialized and reconnect/lifecycle refreshes
224
- are coalesced. Failed requests retry with backoff, capped at 30 seconds; the panel
225
- shows a synchronization warning and disables submissions until recovery. It does
226
- not infer success or cancel provider work when synchronization fails.
227
-
228
- Adapters may use the optional fourth `observe` argument to report an `Error` after
229
- a transport or parsing failure. The observer then refreshes the snapshot. The HTTP
230
- adapter reports SSE errors and malformed JSON this way.
231
-
232
- Snapshots, summaries, and events optionally carry a monotonically increasing
233
- numeric `revision` per conversation. Once a revision is present, older or
234
- unversioned updates are ignored. Events at the same revision may carry different
235
- parts of one change; revisions are not event IDs. Hosts must supply consistent
236
- revisions across all three surfaces to enable this protection. Existing unversioned
237
- adapters remain supported: events arriving during a snapshot request invalidate
238
- that response and cause a later refresh. Without server revisions, the library
239
- 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.
240
252
 
241
253
  Polling only repairs browser state from the backend's snapshot. It cannot repair
242
254
  a backend that has not persisted completion, and a suspended/offline browser or
243
255
  a request that never settles has no bounded convergence guarantee. Unmounting
244
256
  stops observation, timers, and browser listeners; it never cancels a turn.
245
257
 
246
- `CandidateReview.onReviewReady` reports true only when every artifact is ready.
247
- Fixture scripts must supply `before` for modifications to support restore;
248
- 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.
261
+
262
+ ## Organization availability
263
+
264
+ Adapters implement `getAvailability()` and include snapshot `availability` as
265
+ `{ state: 'enabled' | 'organization_disabled', policyVersion: string }`.
266
+ The panel reconciles both sources by local request order: a response from an
267
+ older request cannot replace a result accepted from a newer request.
268
+ `policyVersion` is opaque and is never sorted. Snapshots omitting availability
269
+ do not replace a known endpoint result.
270
+
271
+ The endpoint is checked before protected actions and on online/visible resume,
272
+ including on the conversation list. Failed lookups block changes and offer
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.
276
+ Denied actions are not automatically replayed.
249
277
 
250
278
  ## Questions from Copilot
251
279
 
@@ -266,10 +294,8 @@ delivery status. One question may be actionable per conversation. Keep the
266
294
  conversation `running` and its assistant message `streaming` while awaiting
267
295
  input; provider "requires action" is not turn completion.
268
296
 
269
- Implement optional `CopilotClient.answerQuestion(AnswerQuestionInput)` to enable
270
- answers. Existing adapters without Q&A remain supported; a pending question
271
- from an adapter without that action displays an explicit unsupported message.
272
- 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
273
299
  `/conversations/{conversationId}/questions/{questionId}/answer` relative to
274
300
  `baseUrl`. Hosts with other routes map this action in their adapter.
275
301
 
@@ -1,4 +1,4 @@
1
- import { R as c, L as f, A as d } from "./index-DevZv06y.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 }) => {