@molecule/app-ide-panel-logic 1.3.1 → 1.4.1
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 +285 -3
- package/dist/chatTimelineOrdering.d.ts +175 -1
- package/dist/chatTimelineOrdering.d.ts.map +1 -1
- package/dist/chatTimelineOrdering.js +192 -1
- package/dist/chatTimelineOrdering.js.map +1 -1
- package/dist/components/chat-card-event-utilities.d.ts +320 -0
- package/dist/components/chat-card-event-utilities.d.ts.map +1 -0
- package/dist/components/chat-card-event-utilities.js +198 -0
- package/dist/components/chat-card-event-utilities.js.map +1 -0
- package/dist/components/chat-card-style.d.ts +7 -1
- package/dist/components/chat-card-style.d.ts.map +1 -1
- package/dist/components/chat-card-style.js +8 -2
- package/dist/components/chat-card-style.js.map +1 -1
- package/dist/components/chat-composer-utilities.d.ts +472 -0
- package/dist/components/chat-composer-utilities.d.ts.map +1 -0
- package/dist/components/chat-composer-utilities.js +519 -0
- package/dist/components/chat-composer-utilities.js.map +1 -0
- package/dist/components/chat-dictation-controller.d.ts +376 -0
- package/dist/components/chat-dictation-controller.d.ts.map +1 -0
- package/dist/components/chat-dictation-controller.js +559 -0
- package/dist/components/chat-dictation-controller.js.map +1 -0
- package/dist/components/chat-effort-utilities.d.ts +24 -0
- package/dist/components/chat-effort-utilities.d.ts.map +1 -1
- package/dist/components/chat-effort-utilities.js +41 -0
- package/dist/components/chat-effort-utilities.js.map +1 -1
- package/dist/components/chat-format-utilities.d.ts +71 -0
- package/dist/components/chat-format-utilities.d.ts.map +1 -0
- package/dist/components/chat-format-utilities.js +192 -0
- package/dist/components/chat-format-utilities.js.map +1 -0
- package/dist/components/chat-models-utilities.d.ts +168 -0
- package/dist/components/chat-models-utilities.d.ts.map +1 -1
- package/dist/components/chat-models-utilities.js +253 -0
- package/dist/components/chat-models-utilities.js.map +1 -1
- package/dist/components/chat-settings-utilities.d.ts +153 -1
- package/dist/components/chat-settings-utilities.d.ts.map +1 -1
- package/dist/components/chat-settings-utilities.js +204 -1
- package/dist/components/chat-settings-utilities.js.map +1 -1
- package/dist/components/chat-stream-utilities.d.ts +165 -1
- package/dist/components/chat-stream-utilities.d.ts.map +1 -1
- package/dist/components/chat-stream-utilities.js +155 -1
- package/dist/components/chat-stream-utilities.js.map +1 -1
- package/dist/components/chat-tests-controller.d.ts +249 -0
- package/dist/components/chat-tests-controller.d.ts.map +1 -0
- package/dist/components/chat-tests-controller.js +504 -0
- package/dist/components/chat-tests-controller.js.map +1 -0
- package/dist/components/chat-timeline-utilities.d.ts +90 -0
- package/dist/components/chat-timeline-utilities.d.ts.map +1 -0
- package/dist/components/chat-timeline-utilities.js +71 -0
- package/dist/components/chat-timeline-utilities.js.map +1 -0
- package/dist/components/chat-ui-constants.d.ts +98 -0
- package/dist/components/chat-ui-constants.d.ts.map +1 -0
- package/dist/components/chat-ui-constants.js +146 -0
- package/dist/components/chat-ui-constants.js.map +1 -0
- package/dist/components/chat-undo-utilities.d.ts +47 -0
- package/dist/components/chat-undo-utilities.d.ts.map +1 -0
- package/dist/components/chat-undo-utilities.js +73 -0
- package/dist/components/chat-undo-utilities.js.map +1 -0
- package/dist/components/context-usage-utilities.d.ts +25 -3
- package/dist/components/context-usage-utilities.d.ts.map +1 -1
- package/dist/components/context-usage-utilities.js +42 -2
- package/dist/components/context-usage-utilities.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/panels.d.ts +6 -0
- package/dist/panels.d.ts.map +1 -1
- package/dist/panels.js +6 -0
- package/dist/panels.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Building and ordering the chat transcript's timeline, plus the small
|
|
3
|
+
* derivations the timeline region computes from it — which messages render, the
|
|
4
|
+
* live work card's visibility, the plan's waiting state, and where each item's
|
|
5
|
+
* timestamp belongs.
|
|
6
|
+
*
|
|
7
|
+
* Every framework's chat panel renders the same timeline from the same inputs,
|
|
8
|
+
* so this lives here, framework-neutral. Nothing in this module reads React
|
|
9
|
+
* state, refs, props or hooks: the caller passes every input in.
|
|
3
10
|
*
|
|
4
11
|
* @module
|
|
5
12
|
*/
|
|
13
|
+
import { cardCoveredByLimit, commitCardVisible, persistedCommitHashes, } from './components/chat-timeline-utilities.js';
|
|
6
14
|
/**
|
|
7
15
|
* Sort key for a chat-timeline item (message or any card). Items normally order by
|
|
8
16
|
* their `timestamp`, with TWO exceptions: a streaming assistant message that has not
|
|
@@ -43,4 +51,187 @@ export function timelineSortKey(item) {
|
|
|
43
51
|
}
|
|
44
52
|
return item.card?.timestamp ?? 0;
|
|
45
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Never render hidden driver messages (the post-boot kickoff etc.). The server
|
|
56
|
+
* already filters them on read, but guard here too so the client NEVER shows
|
|
57
|
+
* one — even an optimistic/in-flight hidden message.
|
|
58
|
+
*
|
|
59
|
+
* @param messages - The transcript's messages.
|
|
60
|
+
* @returns The messages the timeline may render.
|
|
61
|
+
*/
|
|
62
|
+
export function selectVisibleMessages(messages) {
|
|
63
|
+
return messages.filter((m) => !m.hidden);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Splits out the queued messages (user/auto messages waiting to send while the
|
|
67
|
+
* agent works). They are NOT rendered inline in the scrolling timeline — they'd
|
|
68
|
+
* be pushed around and reflow as the response streams. They render instead in an
|
|
69
|
+
* anchored bar pinned above the composer (the same fixed-position treatment as
|
|
70
|
+
* the commit bar), so the timeline never includes them.
|
|
71
|
+
*
|
|
72
|
+
* @param visibleMessages - The visible messages (see {@link selectVisibleMessages}).
|
|
73
|
+
* @returns The queued subset, in queue order.
|
|
74
|
+
*/
|
|
75
|
+
export function selectQueuedMessages(visibleMessages) {
|
|
76
|
+
return visibleMessages.filter((m) => m.queued);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Whether a limit the backend raised for an ANONYMOUS caller is now STALE — the
|
|
80
|
+
* viewer signed in, so they have an account, a different allowance, and two
|
|
81
|
+
* dead-end buttons. A `requiresSignup` error, whose whole message is "…for
|
|
82
|
+
* guests … or create a free account for more" and whose CTAs are Sign up / Log
|
|
83
|
+
* in, is stale the moment the viewer is no longer anonymous. The error state
|
|
84
|
+
* survives the in-place auth modal (nothing navigates, and useChat only clears
|
|
85
|
+
* it on the next send), so without this the freshly-signed-up user keeps reading
|
|
86
|
+
* the guest limit they just escaped. Same reasoning the host's `upgrade_prompt`
|
|
87
|
+
* card factory already applies to the recorded guest card.
|
|
88
|
+
*
|
|
89
|
+
* @param errorMeta - The error's limit metadata, or `null` when there is none.
|
|
90
|
+
* @param isAnonymous - Whether the viewer is still anonymous; `undefined` (not yet
|
|
91
|
+
* known) counts as anonymous, so the limit stays until sign-in is confirmed.
|
|
92
|
+
* @returns Whether the guest limit is stale and must not render.
|
|
93
|
+
*/
|
|
94
|
+
export function isStaleAnonymousLimit(errorMeta, isAnonymous) {
|
|
95
|
+
return errorMeta?.requiresSignup === true && isAnonymous === false;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build a unified timeline so commit cards appear at the correct position.
|
|
99
|
+
*
|
|
100
|
+
* A card-message (role:'system' carrying a cardEvent) renders as a SYSTEM CARD,
|
|
101
|
+
* not a chat bubble — split it out here so it flows through the same card render
|
|
102
|
+
* path, sourced from the ONE transcript. Every other message renders as a
|
|
103
|
+
* message. A limit the LIVE banner is already stating is dropped from its card
|
|
104
|
+
* while the banner is up: a limit is hit once but surfaces twice — the card
|
|
105
|
+
* recorded when the turn was interrupted, then the banner when the next send is
|
|
106
|
+
* refused — so a card that declares it covers this same limit is dropped while
|
|
107
|
+
* the banner is up (it comes back when the error clears). The banner stays: it
|
|
108
|
+
* is the refused send's only feedback, and its message can be the more specific
|
|
109
|
+
* one (platform capacity vs the user's own budget, same `limitType`).
|
|
110
|
+
*
|
|
111
|
+
* The commit endpoint both returns the commit AND persists it as a
|
|
112
|
+
* `commitRecord` message, so once any history reload (tab refocus,
|
|
113
|
+
* end-of-turn reconcile) pulls that record into `messages`, this session's local
|
|
114
|
+
* card for the same commit is a duplicate. The persisted record wins; a local
|
|
115
|
+
* card is kept only until it lands.
|
|
116
|
+
*
|
|
117
|
+
* Order by timestamp, EXCEPT an empty (still-thinking) streaming response sorts
|
|
118
|
+
* last — so a turn's preamble cards (mode/model/skills notices, onboarding tips),
|
|
119
|
+
* emitted a beat after the placeholder is created, render ABOVE the response
|
|
120
|
+
* rather than below the whole streamed block. See {@link timelineSortKey}.
|
|
121
|
+
*
|
|
122
|
+
* @param input - The messages and cards to build from, plus the live error state.
|
|
123
|
+
* @returns The ordered timeline items.
|
|
124
|
+
*/
|
|
125
|
+
export function buildChatTimeline(input) {
|
|
126
|
+
const { visibleMessages, cardEventToSystemCard } = input;
|
|
127
|
+
const items = [];
|
|
128
|
+
const liveLimitType = input.error && !input.isStaleAnonymousLimit ? input.errorMeta?.limitType : undefined;
|
|
129
|
+
for (const msg of visibleMessages) {
|
|
130
|
+
// Queued messages render in the anchored bar above the composer, not inline.
|
|
131
|
+
if (msg.queued)
|
|
132
|
+
continue;
|
|
133
|
+
if (msg.cardEvent) {
|
|
134
|
+
const card = cardEventToSystemCard(msg.cardEvent, msg.id, msg.timestamp);
|
|
135
|
+
if (!card)
|
|
136
|
+
continue;
|
|
137
|
+
if (cardCoveredByLimit(card, liveLimitType))
|
|
138
|
+
continue;
|
|
139
|
+
items.push({ kind: 'system', card });
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
items.push({ kind: 'message', msg });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
const persistedHashes = persistedCommitHashes(visibleMessages);
|
|
146
|
+
// systemCards now holds ONLY this session's local command cards (ephemeral, see above).
|
|
147
|
+
items.push(...input.commitCards
|
|
148
|
+
.filter((card) => commitCardVisible(card, persistedHashes))
|
|
149
|
+
.map((card) => ({ kind: 'commit', card })), ...input.systemCards.map((card) => ({ kind: 'system', card })), ...input.activityCards.map((card) => ({ kind: 'activity', card })), ...input.tipCards.map((card) => ({ kind: 'tip', card })));
|
|
150
|
+
items.sort((a, b) => timelineSortKey(a) - timelineSortKey(b));
|
|
151
|
+
return items;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Where (if anywhere) a timeline item carries its time. Typed user messages and
|
|
155
|
+
* team notes carry it in their header row and always qualify; Synthase replies
|
|
156
|
+
* and event cards get a line above them, and qualify with timestamps off only
|
|
157
|
+
* when critical. The command browsers (/settings, /skills, /scripts, /help) are
|
|
158
|
+
* this viewer's UI, not something that happened, so they never carry one.
|
|
159
|
+
*
|
|
160
|
+
* @param item - The timeline item.
|
|
161
|
+
* @returns Its slot, or `null` when it carries no timestamp.
|
|
162
|
+
*/
|
|
163
|
+
export function timestampSlotFor(item) {
|
|
164
|
+
if (item.kind === 'message') {
|
|
165
|
+
const { msg } = item;
|
|
166
|
+
if (typeof msg.timestamp !== 'number')
|
|
167
|
+
return null;
|
|
168
|
+
const base = { id: msg.id, timestamp: msg.timestamp, align: 'left' };
|
|
169
|
+
if ((msg.role === 'user' && !msg.automatic) || msg.teamOnly)
|
|
170
|
+
return { ...base, alwaysShown: true, placement: 'header' };
|
|
171
|
+
// An assistant placeholder with nothing rendered yet (still thinking).
|
|
172
|
+
if (!msg.commitRecord && !msg.content && !msg.blocks?.length && !msg.toolCalls?.length)
|
|
173
|
+
return null;
|
|
174
|
+
// A reply that failed verification or hit a resource limit is a critical event.
|
|
175
|
+
const critical = !!msg.blocks?.some((block) => {
|
|
176
|
+
const b = block;
|
|
177
|
+
return (b.type === 'verification' && b.status === 'error') || b.type === 'resource_limit';
|
|
178
|
+
});
|
|
179
|
+
return { ...base, alwaysShown: critical, placement: 'line' };
|
|
180
|
+
}
|
|
181
|
+
const { card } = item;
|
|
182
|
+
if (typeof card.timestamp !== 'number')
|
|
183
|
+
return null;
|
|
184
|
+
const base = { id: card.id, timestamp: card.timestamp, placement: 'line' };
|
|
185
|
+
if (item.kind === 'commit')
|
|
186
|
+
return { ...base, alwaysShown: item.card.status === 'error', align: 'left' };
|
|
187
|
+
if (item.kind === 'activity')
|
|
188
|
+
return { ...base, alwaysShown: item.card.activity.status === 'failed', align: 'left' };
|
|
189
|
+
if (item.kind === 'tip')
|
|
190
|
+
return { ...base, alwaysShown: false, align: 'left' };
|
|
191
|
+
const systemCard = item.card;
|
|
192
|
+
if (systemCard.variant === 'help')
|
|
193
|
+
return null;
|
|
194
|
+
// Centered one-line notices center their time to match.
|
|
195
|
+
const centered = systemCard.variant === 'skillsLoaded' ||
|
|
196
|
+
(systemCard.variant === undefined &&
|
|
197
|
+
!(systemCard.tone || systemCard.emphasized || systemCard.action) &&
|
|
198
|
+
!systemCard.text.includes('\n'));
|
|
199
|
+
return {
|
|
200
|
+
...base,
|
|
201
|
+
alwaysShown: systemCard.variant === undefined && !!systemCard.critical,
|
|
202
|
+
align: centered ? 'center' : 'left',
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Whether the latest plan is waiting on the person: a plan step only spins while
|
|
207
|
+
* a turn is running; otherwise it says it is waiting on the person when the last
|
|
208
|
+
* message carries an unanswered `ask_user` (a tool call whose output status is
|
|
209
|
+
* `awaiting_response`).
|
|
210
|
+
*
|
|
211
|
+
* @param messages - The transcript's messages.
|
|
212
|
+
* @returns Whether the plan awaits a user response.
|
|
213
|
+
*/
|
|
214
|
+
export function planAwaitingUser(messages) {
|
|
215
|
+
return (messages[messages.length - 1]?.toolCalls ?? []).some((tc) => tc.output != null &&
|
|
216
|
+
typeof tc.output === 'object' &&
|
|
217
|
+
tc.output.status === 'awaiting_response');
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Everything about the work in flight shares one card above the composer. The
|
|
221
|
+
* tests strip also shows for a read-only viewer (watching is not editing); the
|
|
222
|
+
* files strip does not (committing is editor work). Popups hide the card.
|
|
223
|
+
*
|
|
224
|
+
* @param input - The popup states and the work the card would show.
|
|
225
|
+
* @returns Whether the work card renders.
|
|
226
|
+
*/
|
|
227
|
+
export function isWorkVisible(input) {
|
|
228
|
+
return (!input.commandMenu &&
|
|
229
|
+
!input.modelPicker &&
|
|
230
|
+
!input.effortPicker &&
|
|
231
|
+
!input.panelOverlay &&
|
|
232
|
+
(input.plan.length > 0 ||
|
|
233
|
+
input.backgroundTasks.length > 0 ||
|
|
234
|
+
input.showTests ||
|
|
235
|
+
input.showFiles));
|
|
236
|
+
}
|
|
46
237
|
//# sourceMappingURL=chatTimelineOrdering.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatTimelineOrdering.js","sourceRoot":"","sources":["../src/chatTimelineOrdering.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"chatTimelineOrdering.js","sourceRoot":"","sources":["../src/chatTimelineOrdering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,yCAAyC,CAAA;AAgBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,eAAe,CAAC,IAAmB;IACjD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAA;QAClB,IAAI,CAAC,CAAC,MAAM;YAAE,OAAO,MAAM,CAAC,gBAAgB,CAAA;QAC5C,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;QAChE,IAAI,CAAC,CAAC,WAAW,IAAI,KAAK;YAAE,OAAO,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAA;QAC9D,OAAO,CAAC,CAAC,SAAS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C,CAAC,CAAC,MAAM;KACpC,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgC;IAC/D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,CAC1D,CAAC,EAAE,EAAE,EAAE,CACL,EAAE,CAAC,MAAM,IAAI,IAAI;QACjB,OAAO,EAAE,CAAC,MAAM,KAAK,QAAQ;QAC5B,EAAE,CAAC,MAA8B,CAAC,MAAM,KAAK,mBAAmB,CACpE,CAAA;AACH,CAAC;AAsBD;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAA8B;IAC1D,OAAO,CACL,CAAC,KAAK,CAAC,WAAW;QAClB,CAAC,KAAK,CAAC,WAAW;QAClB,CAAC,KAAK,CAAC,YAAY;QACnB,CAAC,KAAK,CAAC,YAAY;QACnB,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC;YACpB,KAAK,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;YAChC,KAAK,CAAC,SAAS;YACf,KAAK,CAAC,SAAS,CAAC,CACnB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chat "system card" vocabulary and the one construction of a system card
|
|
3
|
+
* from a recorded `CardEvent`.
|
|
4
|
+
*
|
|
5
|
+
* The React panel carries these notices inline in its chat timeline — the
|
|
6
|
+
* model/mode/setting/skills/custom system cards, the dismissable tips, the
|
|
7
|
+
* captured activity cards, commit cards, attached files and the composer's
|
|
8
|
+
* command/mode/effort/file pickers. Every framework's panel shows the same
|
|
9
|
+
* cards, so the types and the `CardEvent` → {@link SystemCard} mapping live
|
|
10
|
+
* here, framework-neutral. A view supplies its own `t()`, model catalog,
|
|
11
|
+
* region choices, custom-card factory and logger through
|
|
12
|
+
* {@link CardEventToSystemCardDeps}; nothing in this module reads React state,
|
|
13
|
+
* refs, props or hooks.
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import type { CardEvent } from '@molecule/app-ai-chat';
|
|
18
|
+
import type { AppModelDefinition } from '@molecule/app-ai-models';
|
|
19
|
+
import type { TranslateFunction } from '@molecule/app-i18n';
|
|
20
|
+
import type { IconName } from '@molecule/app-icons';
|
|
21
|
+
import type { ChatEventCardAction, ChatEventCardFactory, ChatEventCardSegment } from '../customEventCards.js';
|
|
22
|
+
import type { Activity } from './activity-utilities.js';
|
|
23
|
+
import type { EffortMode } from './chat-effort-utilities.js';
|
|
24
|
+
import type { ModelMode } from './chat-model-mode-utilities.js';
|
|
25
|
+
import type { TipDef } from './chat-tips-utilities.js';
|
|
26
|
+
/** One entry of the composer's `@`-file picker list. */
|
|
27
|
+
export interface FileEntry {
|
|
28
|
+
/** File or directory name. */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Whether the entry is a file or a directory. */
|
|
31
|
+
type: 'file' | 'directory';
|
|
32
|
+
/** Size in bytes, when known. */
|
|
33
|
+
size?: number;
|
|
34
|
+
}
|
|
35
|
+
/** A file the composer will send along with the message. */
|
|
36
|
+
export interface AttachedFile {
|
|
37
|
+
/** Sandbox file path for @-mentioned text files. */
|
|
38
|
+
path?: string;
|
|
39
|
+
/** Browser File object for drag-dropped/pasted/picked binary files. */
|
|
40
|
+
file?: File;
|
|
41
|
+
/** Display name. */
|
|
42
|
+
filename: string;
|
|
43
|
+
/** MIME type. */
|
|
44
|
+
mediaType: string;
|
|
45
|
+
/** File size in bytes. */
|
|
46
|
+
size: number;
|
|
47
|
+
/** Object URL for image thumbnail preview (revoked on removal). */
|
|
48
|
+
previewUrl?: string;
|
|
49
|
+
}
|
|
50
|
+
/** The composer's `@`-file picker state. */
|
|
51
|
+
export interface FilePicker {
|
|
52
|
+
/** The listed entries, already filtered by {@link FilePicker.query}. */
|
|
53
|
+
entries: FileEntry[];
|
|
54
|
+
/** The composer text the picker filters by, as of the last write to the composer. */
|
|
55
|
+
query: string;
|
|
56
|
+
/** The highlighted row's index. */
|
|
57
|
+
selectedIdx: number;
|
|
58
|
+
}
|
|
59
|
+
/** The composer's slash-command menu state. */
|
|
60
|
+
export interface CommandMenu {
|
|
61
|
+
/** The highlighted row's index. */
|
|
62
|
+
selectedIdx: number;
|
|
63
|
+
/** The composer text the picker filters by, as of the last write to the composer. */
|
|
64
|
+
text: string;
|
|
65
|
+
/**
|
|
66
|
+
* Opened via the slash BUTTON with text already in the composer: list every
|
|
67
|
+
* runnable command instead of filtering by the composer text (which the
|
|
68
|
+
* toggle deliberately leaves untouched). Cleared the moment typing re-derives
|
|
69
|
+
* the menu from the input.
|
|
70
|
+
*/
|
|
71
|
+
showAll?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** One entry of the conversation history list. */
|
|
74
|
+
export interface ConversationSummary {
|
|
75
|
+
/** The conversation id. */
|
|
76
|
+
id: string;
|
|
77
|
+
/** ISO creation timestamp. */
|
|
78
|
+
createdAt: string;
|
|
79
|
+
/** ISO last-update timestamp. */
|
|
80
|
+
updatedAt: string;
|
|
81
|
+
/** The stored preview line, or null when the conversation has none. */
|
|
82
|
+
preview: string | null;
|
|
83
|
+
}
|
|
84
|
+
/** A commit card in the chat timeline. */
|
|
85
|
+
export interface CommitCard {
|
|
86
|
+
/** The card's identity (and the commit's id while running). */
|
|
87
|
+
id: string;
|
|
88
|
+
/** The commit message. */
|
|
89
|
+
message: string;
|
|
90
|
+
/** The committed file paths. */
|
|
91
|
+
files: string[];
|
|
92
|
+
/** Numeric timestamp for timeline ordering. */
|
|
93
|
+
timestamp: number;
|
|
94
|
+
/** Where the commit is in its lifecycle. */
|
|
95
|
+
status: 'running' | 'done' | 'error';
|
|
96
|
+
/** The resulting commit hash, once the commit succeeded. */
|
|
97
|
+
hash?: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* `Omit` that distributes over a union, so each member keeps its own remaining keys
|
|
101
|
+
* (plain `Omit<A | B, K>` collapses to the common keys only).
|
|
102
|
+
*/
|
|
103
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
104
|
+
/**
|
|
105
|
+
* Fields shared by every system card. `action` (an optional CTA button, or array of
|
|
106
|
+
* them) is common — any card may carry one.
|
|
107
|
+
*/
|
|
108
|
+
export interface SystemCardBase {
|
|
109
|
+
/** The card's identity in the timeline. */
|
|
110
|
+
id: string;
|
|
111
|
+
/** Plain-text body (the accessible/non-toned fallback). */
|
|
112
|
+
text: string;
|
|
113
|
+
/** Numeric timestamp for timeline ordering. */
|
|
114
|
+
timestamp: number;
|
|
115
|
+
/** An optional CTA button (or buttons) shown with the card. */
|
|
116
|
+
action?: ChatEventCardAction | ChatEventCardAction[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Default card (no `variant`): a plain inline notice, or — with `tone` set — a
|
|
120
|
+
* dismissable tip box. Owns the body/styling fields the rich variants never use.
|
|
121
|
+
*/
|
|
122
|
+
export interface PlainSystemCard extends SystemCardBase {
|
|
123
|
+
/** The default card has no variant key. */
|
|
124
|
+
variant?: undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Composable inline body for a `tone` (tip) card — an ordered list of segments
|
|
127
|
+
* (plain strings + inline link actions) rendered in sequence, used INSTEAD of
|
|
128
|
+
* `text` + appended `action`s so a link can sit mid-sentence (see
|
|
129
|
+
* {@link ChatEventCard.content}). `text` stays the plain-text fallback.
|
|
130
|
+
*/
|
|
131
|
+
content?: ChatEventCardSegment[];
|
|
132
|
+
/**
|
|
133
|
+
* When true, render with the emphasized (highlighted box) style instead of the
|
|
134
|
+
* muted inline style — e.g. a host-supplied sign-up / upgrade nudge. The caller
|
|
135
|
+
* opts in explicitly; the styling is never inferred from the card's route or copy.
|
|
136
|
+
*/
|
|
137
|
+
emphasized?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Tip TONE — picks the card's accent colour + default icon so every notice card shares
|
|
140
|
+
* ONE consistent box, differing only by colour/icon: `info` (blue), `gold` (amber tip),
|
|
141
|
+
* `upgrade` (amber clock), `success` (green check), `signup` (primary sign-in). Setting
|
|
142
|
+
* a tone implies emphasis; `emphasized` without a tone falls back to `info`. See
|
|
143
|
+
* {@link ChatEventCard.tone}.
|
|
144
|
+
*/
|
|
145
|
+
tone?: 'info' | 'gold' | 'upgrade' | 'success' | 'signup';
|
|
146
|
+
/** Icon-name override (a `@molecule/app-icons` glyph); defaults to the tone's icon. */
|
|
147
|
+
icon?: IconName;
|
|
148
|
+
/**
|
|
149
|
+
* The limit this card already explains (a backend `limitType`). While a live error
|
|
150
|
+
* carries the same `limitType` — i.e. the limit banner is restating it right above the
|
|
151
|
+
* composer — this card is dropped from the timeline so the same limit is stated once,
|
|
152
|
+
* not twice. See {@link ChatEventCard.coversLimitType}.
|
|
153
|
+
*/
|
|
154
|
+
coversLimitType?: string;
|
|
155
|
+
/** A critical event — keeps its timestamp with timestamps off. See {@link ChatEventCard.critical}. */
|
|
156
|
+
critical?: boolean;
|
|
157
|
+
}
|
|
158
|
+
/** The `/help` high-level guide card. `text` carries the `buildHelpText` fallback. */
|
|
159
|
+
export interface HelpSystemCard extends SystemCardBase {
|
|
160
|
+
/** The `/help` card variant. */
|
|
161
|
+
variant: 'help';
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The compact, clickable "Loaded {{count}} skills" notice built from a recorded `skills`
|
|
165
|
+
* card event; its onClick, which opens the `/skills` browser, is attached at render time.
|
|
166
|
+
*/
|
|
167
|
+
export interface SkillsLoadedSystemCard extends SystemCardBase {
|
|
168
|
+
/** The loaded-skills card variant. */
|
|
169
|
+
variant: 'skillsLoaded';
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A system card — a discriminated union keyed on `variant`, so each card type declares
|
|
173
|
+
* ONLY its own fields and the compiler enforces validity (`content`/`tone` only on the
|
|
174
|
+
* plain/tip card). The render switch narrows on `variant`. The `/settings`, `/skills`,
|
|
175
|
+
* `/scripts` and `/test` browsers are overlays (`panelOverlay`), not cards.
|
|
176
|
+
*/
|
|
177
|
+
export type SystemCard = PlainSystemCard | HelpSystemCard | SkillsLoadedSystemCard;
|
|
178
|
+
/**
|
|
179
|
+
* Options for `addSystemCard`: the card's fields minus the generated `id`, the
|
|
180
|
+
* positional `text` and the `timestamp` it stamps. Distributes over the union (see
|
|
181
|
+
* {@link DistributiveOmit}) so a caller only ever names the fields valid for the variant it sets.
|
|
182
|
+
*/
|
|
183
|
+
export type AddSystemCardOptions = DistributiveOmit<SystemCard, 'id' | 'text' | 'timestamp'>;
|
|
184
|
+
/** A dismissable auto-tip entry in the chat timeline. */
|
|
185
|
+
export interface TipCardEntry {
|
|
186
|
+
/** The card's identity in the timeline. */
|
|
187
|
+
id: string;
|
|
188
|
+
/**
|
|
189
|
+
* The tip's definition ({@link TipDef}), NOT the rendered sentence: the entry
|
|
190
|
+
* stores WHAT to say and the render translates it
|
|
191
|
+
* (`tipText(t, tip, { agentName })`), so a locale switch re-translates every
|
|
192
|
+
* visible tip instead of leaving the sentence the effect captured before the
|
|
193
|
+
* switch.
|
|
194
|
+
*/
|
|
195
|
+
tip: TipDef;
|
|
196
|
+
/** Numeric timestamp for timeline ordering. */
|
|
197
|
+
timestamp: number;
|
|
198
|
+
/**
|
|
199
|
+
* Accent colour override (border/background tint + icon colour) for a
|
|
200
|
+
* semantic tip — e.g. the viewer tip goes gold to match the team-only
|
|
201
|
+
* message treatment it explains. Default: the neutral primary tint.
|
|
202
|
+
*/
|
|
203
|
+
accent?: string;
|
|
204
|
+
/** Leading-icon override (e.g. `people` for the viewer tip). Default: `lightbulb`. */
|
|
205
|
+
icon?: IconName;
|
|
206
|
+
}
|
|
207
|
+
/** An inline activity card entry in the chat timeline (a captured side effect). */
|
|
208
|
+
export interface ActivityCardEntry {
|
|
209
|
+
/** The card's identity in the timeline. */
|
|
210
|
+
id: string;
|
|
211
|
+
/** The captured side effect. */
|
|
212
|
+
activity: Activity;
|
|
213
|
+
/** Numeric timestamp for timeline ordering (derived from the activity's ISO timestamp). */
|
|
214
|
+
timestamp: number;
|
|
215
|
+
/**
|
|
216
|
+
* Set when this card was applied from a teammate's broadcast (the chat push channel),
|
|
217
|
+
* not this client's own stream. Rendered but NEVER persisted — the originating member
|
|
218
|
+
* already persisted it; if every viewer re-PUT, members would race on the conversation
|
|
219
|
+
* row.
|
|
220
|
+
*/
|
|
221
|
+
received?: boolean;
|
|
222
|
+
}
|
|
223
|
+
/** The `/model` picker state. */
|
|
224
|
+
export interface ModelPicker {
|
|
225
|
+
/** The highlighted row's index. */
|
|
226
|
+
selectedIdx: number;
|
|
227
|
+
/** The composer text the picker filters by, as of the last write to the composer. */
|
|
228
|
+
text: string;
|
|
229
|
+
/**
|
|
230
|
+
* When set, the picker is scoped to a mode: selections persist to that
|
|
231
|
+
* mode's settings field (`planModel` / `executeModel` / `commitModel` /
|
|
232
|
+
* `compactModel`) and the free-tier lock follows the mode's rules. Unset =
|
|
233
|
+
* the legacy single `chatModel` ("Default"). Driven live by the mode
|
|
234
|
+
* dropdown at the top of the picker; the `/model --plan` etc. flags merely
|
|
235
|
+
* preselect it.
|
|
236
|
+
*/
|
|
237
|
+
mode?: ModelMode;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* The `/effort` level picker — a selectable list of the target mode's model's
|
|
241
|
+
* own effort levels (mirrors how bare `/model` opens the model picker).
|
|
242
|
+
*/
|
|
243
|
+
export interface EffortPicker {
|
|
244
|
+
/** The highlighted row's index. */
|
|
245
|
+
selectedIdx: number;
|
|
246
|
+
/** The composer text the picker filters by, as of the last write to the composer. */
|
|
247
|
+
text: string;
|
|
248
|
+
/**
|
|
249
|
+
* The mode being edited — a selection persists to `effortByMode[mode]`.
|
|
250
|
+
* Opens scoped to the live conversation mode (or the `--plan` / `--execute`
|
|
251
|
+
* flag); the picker's own mode dropdown re-scopes it in place, and the
|
|
252
|
+
* listed levels follow that mode's MODEL (plan and execute can run models
|
|
253
|
+
* with entirely different native effort scales).
|
|
254
|
+
*/
|
|
255
|
+
mode: EffortMode;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The log surface {@link cardEventToSystemCard} uses for a custom-card factory
|
|
259
|
+
* failure — structurally the `Logger` a panel gets from `@molecule/app-logger`,
|
|
260
|
+
* so this module stays free of a logger dependency.
|
|
261
|
+
*/
|
|
262
|
+
export interface ChatCardEventLogger {
|
|
263
|
+
/**
|
|
264
|
+
* Record a failed custom-card factory.
|
|
265
|
+
*
|
|
266
|
+
* @param message - What failed and why it matters.
|
|
267
|
+
* @param args - The error and the offending event name.
|
|
268
|
+
*/
|
|
269
|
+
error(message: string, ...args: unknown[]): void;
|
|
270
|
+
}
|
|
271
|
+
/** What {@link cardEventToSystemCard} needs from its caller. */
|
|
272
|
+
export interface CardEventToSystemCardDeps {
|
|
273
|
+
/** The caller's translate function (keys, values and defaults pass through unchanged). */
|
|
274
|
+
t: TranslateFunction;
|
|
275
|
+
/** The project's model catalog, for a model card's processing-region code. */
|
|
276
|
+
models: AppModelDefinition[];
|
|
277
|
+
/** The viewer's per-model region choices, keyed by model id. */
|
|
278
|
+
modelRegions: Record<string, string>;
|
|
279
|
+
/** Resolves an app-registered custom-card factory (see `registerCustomEventCard`). */
|
|
280
|
+
getFactory: (name: string) => ChatEventCardFactory | undefined;
|
|
281
|
+
/** The caller's logger, for a factory that throws. */
|
|
282
|
+
logger: ChatCardEventLogger;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Build a renderable {@link SystemCard} from a card-message's raw {@link CardEvent}. This is the ONE
|
|
286
|
+
* construction, used IDENTICALLY for a live `card` event (now a card-message in the transcript)
|
|
287
|
+
* and for a card-message loaded on refresh — so the rendered card is the same in both, with
|
|
288
|
+
* no separate store and no client-side "should I show this" decision. App-specific copy /
|
|
289
|
+
* actions stay client-side (the server records only the raw data); returns null for an
|
|
290
|
+
* unrenderable card (a custom event with no registered factory, or a non-execute mode) so
|
|
291
|
+
* the timeline simply omits it.
|
|
292
|
+
*
|
|
293
|
+
* @param cardEvent - The raw recorded card payload.
|
|
294
|
+
* @param id - The card-message's id, carried onto the built card.
|
|
295
|
+
* @param timestamp - The card-message's timestamp, carried onto the built card.
|
|
296
|
+
* @param deps - The caller's translate function, model catalog, region choices, custom-card factory resolver and logger.
|
|
297
|
+
* @returns The system card to render, or null when the event has nothing to show.
|
|
298
|
+
*/
|
|
299
|
+
export declare function cardEventToSystemCard(cardEvent: CardEvent, id: string, timestamp: number, deps: CardEventToSystemCardDeps): SystemCard | null;
|
|
300
|
+
/**
|
|
301
|
+
* The stand-in a translated sentence is rendered with, to find where its slot lands. A
|
|
302
|
+
* private-use character: no translation or name carries it.
|
|
303
|
+
*/
|
|
304
|
+
export declare const CARD_SEGMENT_SLOT = "\uE000";
|
|
305
|
+
/**
|
|
306
|
+
* A card body that puts one inline segment (a clickable code name, a link) where a
|
|
307
|
+
* translated sentence's placeholder sits: `Loaded {{name}} skill` gives
|
|
308
|
+
* `['Loaded ', segment, ' skill']`. The sentence stays ONE translation, so each language
|
|
309
|
+
* places the name where its grammar wants it; two fragment keys around the name
|
|
310
|
+
* ("Loaded " + " skill") forced English word order on every language.
|
|
311
|
+
*
|
|
312
|
+
* @param render - Renders the sentence with the given text as the placeholder's value
|
|
313
|
+
* (the caller's `t()` call).
|
|
314
|
+
* @param segment - The segment that takes the placeholder's place.
|
|
315
|
+
* @returns The segments in order, without empty strings, or `null` when the rendered
|
|
316
|
+
* sentence does not carry the placeholder exactly once (render the plain text then).
|
|
317
|
+
*/
|
|
318
|
+
export declare function cardSegmentsAround(render: (slot: string) => string, segment: ChatEventCardSegment): ChatEventCardSegment[] | null;
|
|
319
|
+
export {};
|
|
320
|
+
//# sourceMappingURL=chat-card-event-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-card-event-utilities.d.ts","sourceRoot":"","sources":["../../src/components/chat-card-event-utilities.ts"],"names":[],"mappings":"AAAA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