@camunda/copilot-chat 0.7.0 → 0.8.1-alpha.0

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
@@ -11,40 +11,163 @@ npm install @camunda/copilot-chat
11
11
  **Peer Dependencies:**
12
12
 
13
13
  ```bash
14
- npm install react react-dom @carbon/react @carbon/icons-react
14
+ npm install react react-dom
15
+ ```
16
+
17
+ ## Styling
18
+
19
+ The library ships precompiled CSS (including its own Tailwind v4 utilities,
20
+ scoped under `.copilot-chat-root` so they cannot leak into the host document):
21
+
22
+ ```tsx
23
+ import '@camunda/copilot-chat/style.css';
24
+ ```
25
+
26
+ Components are built on `@camunda/design-system` (a runtime dependency, kept
27
+ external to the bundle). Consumers must import the design-system stylesheet
28
+ themselves:
29
+
30
+ ```tsx
31
+ import '@camunda/design-system/styles.css';
15
32
  ```
16
33
 
17
34
  ## Quick Start
18
35
 
19
36
  ```tsx
20
- import { CopilotChat, useChatStore } from '@camunda/copilot-chat';
37
+ import {
38
+ CopilotConversationPanel,
39
+ createFixtureClient,
40
+ } from '@camunda/copilot-chat';
21
41
  import '@camunda/copilot-chat/style.css';
42
+ import { useState } from 'react';
43
+
44
+ const client = createFixtureClient();
22
45
 
23
46
  function App() {
24
- const handleSendMessage = (message: string) => {
25
- const { addAssistantMessage, appendToMessage, updateMessageStatus } = useChatStore.getState();
26
- const messageId = `msg-${Date.now()}`;
27
- addAssistantMessage(messageId);
28
- appendToMessage(messageId, 'Hello!');
29
- updateMessageStatus(messageId, 'complete');
30
- };
31
-
32
- return <CopilotChat onSendMessage={handleSendMessage} />;
47
+ const [conversationId, setConversationId] = useState<string | null>(null);
48
+
49
+ return (
50
+ <CopilotConversationPanel
51
+ client={client}
52
+ conversationId={conversationId}
53
+ onConversationStarted={setConversationId}
54
+ onSelectConversation={setConversationId}
55
+ />
56
+ );
33
57
  }
34
58
  ```
35
59
 
36
- For full agent orchestration with tool execution, see [Writing Adapters](../../docs/adapters.md).
37
-
38
- ## Props
39
-
40
- Full props reference: [Integration Guide](../../docs/integration.md).
60
+ Pass `onClose` when the panel is used in a sidecar. It adds a close button to
61
+ the header in both the chat list and an open chat; the host callback should
62
+ close the sidecar and return focus to its opener.
63
+
64
+ ## Conversation context
65
+
66
+ Pass `projectName` for the selected conversation's project to show its name in
67
+ the header. The project chip explains Copilot's project access; pass
68
+ `onOpenProject(projectId)` to show a "Go to project" action in its popup.
69
+ If the project name cannot be loaded, pass `projectNameUnavailable` rather
70
+ than displaying a project ID as its name. The host must still provide editor
71
+ context in `postMessage`; these props only describe the project.
72
+
73
+ ## Selection context
74
+
75
+ Pass `selectionContext={{ projectId, count }}` to `CopilotConversationPanel`
76
+ when a BPMN editor has selected elements. A positive count appears as a
77
+ read-only "1 element selected" or "N elements selected" pill in the
78
+ composer's prompt-input toolbar; omit the prop or
79
+ pass `count: 0` to hide it. For a pinned conversation,
80
+ the indicator appears only when the loaded conversation's origin artifact belongs
81
+ to `projectId`. It remains hidden while that origin is loading or belongs to a
82
+ different project. The host is responsible for supplying the selected elements
83
+ as context when the message is sent.
84
+
85
+ ## Reviewing proposed changes
86
+
87
+ `CopilotConversationPanel` accepts a `renderReview(candidate, { approve, reject })`
88
+ callback for host-owned review flows. When provided, its return value replaces
89
+ the inline approve/reject controls for pending candidates. Hosts should present
90
+ the candidate's changes (including their `before` and `content` snapshots)
91
+ before calling `approve`; the exported `CandidateReview` renders BPMN diagrams
92
+ and text diffs. Both actions return promises, so the host can display progress
93
+ and keep the review open if an action fails.
94
+ While a proposal awaits approval or rejection, the composer is disabled for
95
+ that conversation. Other conversations remain available. The backend also
96
+ rejects new turns until the proposal is resolved.
97
+
98
+ While a turn is running, the message input and suggestions are disabled and no
99
+ additional message can be submitted. Stop remains available; sending resumes after
100
+ the turn finishes or is stopped, provided no proposal awaits review. Rejected submissions show an inline
101
+ error and preserve the draft for retry. Messages are not queued or automatically
102
+ used to interrupt a running turn.
103
+
104
+ Applied changes offer a Restore action. It opens a confirmation dialog naming the
105
+ affected files before restoring their earlier state. Cancel or Escape leaves them
106
+ unchanged; restoring preserves chat history. Failed restores remain in the dialog
107
+ with an error and can be retried.
108
+
109
+ Async `CopilotClient` adapters should call the optional third `observe` argument
110
+ after each connection or reconnection. The panel refreshes its snapshot at that
111
+ point to recover events missed while connecting. The HTTP adapter does this on
112
+ SSE open; two-argument synchronous adapters remain supported.
113
+
114
+ An open conversation refreshes its snapshot every five seconds while running,
115
+ until a terminal snapshot has been fetched. Missing realtime completion events
116
+ therefore do not require a page reload. Online and visibility-resume events also
117
+ refresh the snapshot. Requests are serialized and reconnect/lifecycle refreshes
118
+ are coalesced. Failed requests retry with backoff, capped at 30 seconds; the panel
119
+ shows a synchronization warning and disables submissions until recovery. It does
120
+ not infer success or cancel provider work when synchronization fails.
121
+
122
+ Adapters may use the optional fourth `observe` argument to report an `Error` after
123
+ a transport or parsing failure. The observer then refreshes the snapshot. The HTTP
124
+ adapter reports SSE errors and malformed JSON this way.
125
+
126
+ Snapshots, summaries, and events optionally carry a monotonically increasing
127
+ numeric `revision` per conversation. Once a revision is present, older or
128
+ unversioned updates are ignored. Events at the same revision may carry different
129
+ parts of one change; revisions are not event IDs. Hosts must supply consistent
130
+ revisions across all three surfaces to enable this protection. Existing unversioned
131
+ adapters remain supported: events arriving during a snapshot request invalidate
132
+ that response and cause a later refresh. Without server revisions, the library
133
+ cannot identify stale server responses or all delayed events.
134
+
135
+ Polling only repairs browser state from the backend's snapshot. It cannot repair
136
+ a backend that has not persisted completion, and a suspended/offline browser or
137
+ a request that never settles has no bounded convergence guarantee. Unmounting
138
+ stops observation, timers, and browser listeners; it never cancels a turn.
139
+
140
+ `CandidateReview.onReviewReady` reports true only when every artifact is ready.
141
+ Fixture scripts must supply `before` for modifications to support restore;
142
+ otherwise approval has no checkpoint. Only created files restore to absence.
143
+
144
+ ## Conversation steps
145
+
146
+ Assistant messages can include `message` steps for intermediate agent progress.
147
+ Their `description` holds the message text. Intermediate messages remain visible
148
+ alongside tool steps in event order, including after completion or interruption.
149
+ If the turn ends with a message, only that last message is removed from the steps
150
+ and becomes the assistant reply in `content`. Optional `groupId` metadata in
151
+ older snapshots does not nest rows. Message rows show text directly beside a
152
+ neutral dot, without a generic "Progress" label.
153
+
154
+ An assistant reply in `content` is visible while the message is still streaming.
155
+ The turn remains busy and the composer stays disabled until completion; rendering
156
+ the reply does not indicate that output verification or proposal creation succeeded.
157
+ Empty reasoning markers are not shown or counted. Actual thinking blocks with
158
+ non-blank description text remain visible, and failed steps are never hidden.
159
+
160
+ Shell-tool lint steps, including combined layout/lint steps, use a neutral wrench
161
+ and their original activity label even when the check returns an error. They do
162
+ not show red failure styling, a "(failed)" suffix, or a warning badge. The stored
163
+ step status remains `error`; lint findings stay in the assistant's explanation.
164
+ Other failed operations retain their failure presentation. This presentation
165
+ rule applies both to live steps and to reopened conversation history.
41
166
 
42
167
  ## Documentation
43
168
 
44
- - [Architecture Overview](../../docs/architecture.md)
45
- - [Integration Guide](../../docs/integration.md)
46
- - [Writing Adapters](../../docs/adapters.md)
47
- - [Development Guide](../../docs/development.md)
169
+ - [Repository README](https://github.com/camunda/camunda-copilot-client#readme)
170
+ - [Development Guide](https://github.com/camunda/camunda-copilot-client/blob/main/docs/development.md)
48
171
 
49
172
  ## License
50
173
 
@@ -0,0 +1,19 @@
1
+ import { R as c, L as f, A as d } from "./index-Bh5gDiy3.js";
2
+ import { useContext as p, useState as L, useEffect as N } from "react";
3
+ import { jsx as x } from "react/jsx-runtime";
4
+ var A = ({ code: s, language: e, raw: a, className: o, startLine: m, lineNumbers: u, ...g }) => {
5
+ let { shikiTheme: i } = p(c), t = f(), [n, r] = L(a);
6
+ return N(() => {
7
+ if (!t) {
8
+ r(a);
9
+ return;
10
+ }
11
+ let l = t.highlight({ code: s, language: e, themes: i }, (h) => {
12
+ r(h);
13
+ });
14
+ l && r(l);
15
+ }, [s, e, i, t, a]), x(d, { className: o, language: e, lineNumbers: u, result: n, startLine: m, ...g });
16
+ };
17
+ export {
18
+ A as HighlightedCodeBlockBody
19
+ };