@molecule/app-ide-panel-logic 1.3.1 → 1.4.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.
Files changed (66) hide show
  1. package/README.md +277 -1
  2. package/dist/chatTimelineOrdering.d.ts +175 -1
  3. package/dist/chatTimelineOrdering.d.ts.map +1 -1
  4. package/dist/chatTimelineOrdering.js +192 -1
  5. package/dist/chatTimelineOrdering.js.map +1 -1
  6. package/dist/components/chat-card-event-utilities.d.ts +320 -0
  7. package/dist/components/chat-card-event-utilities.d.ts.map +1 -0
  8. package/dist/components/chat-card-event-utilities.js +198 -0
  9. package/dist/components/chat-card-event-utilities.js.map +1 -0
  10. package/dist/components/chat-composer-utilities.d.ts +472 -0
  11. package/dist/components/chat-composer-utilities.d.ts.map +1 -0
  12. package/dist/components/chat-composer-utilities.js +519 -0
  13. package/dist/components/chat-composer-utilities.js.map +1 -0
  14. package/dist/components/chat-dictation-controller.d.ts +376 -0
  15. package/dist/components/chat-dictation-controller.d.ts.map +1 -0
  16. package/dist/components/chat-dictation-controller.js +559 -0
  17. package/dist/components/chat-dictation-controller.js.map +1 -0
  18. package/dist/components/chat-effort-utilities.d.ts +24 -0
  19. package/dist/components/chat-effort-utilities.d.ts.map +1 -1
  20. package/dist/components/chat-effort-utilities.js +41 -0
  21. package/dist/components/chat-effort-utilities.js.map +1 -1
  22. package/dist/components/chat-format-utilities.d.ts +71 -0
  23. package/dist/components/chat-format-utilities.d.ts.map +1 -0
  24. package/dist/components/chat-format-utilities.js +192 -0
  25. package/dist/components/chat-format-utilities.js.map +1 -0
  26. package/dist/components/chat-models-utilities.d.ts +168 -0
  27. package/dist/components/chat-models-utilities.d.ts.map +1 -1
  28. package/dist/components/chat-models-utilities.js +253 -0
  29. package/dist/components/chat-models-utilities.js.map +1 -1
  30. package/dist/components/chat-settings-utilities.d.ts +153 -1
  31. package/dist/components/chat-settings-utilities.d.ts.map +1 -1
  32. package/dist/components/chat-settings-utilities.js +204 -1
  33. package/dist/components/chat-settings-utilities.js.map +1 -1
  34. package/dist/components/chat-stream-utilities.d.ts +165 -1
  35. package/dist/components/chat-stream-utilities.d.ts.map +1 -1
  36. package/dist/components/chat-stream-utilities.js +155 -1
  37. package/dist/components/chat-stream-utilities.js.map +1 -1
  38. package/dist/components/chat-tests-controller.d.ts +249 -0
  39. package/dist/components/chat-tests-controller.d.ts.map +1 -0
  40. package/dist/components/chat-tests-controller.js +504 -0
  41. package/dist/components/chat-tests-controller.js.map +1 -0
  42. package/dist/components/chat-timeline-utilities.d.ts +90 -0
  43. package/dist/components/chat-timeline-utilities.d.ts.map +1 -0
  44. package/dist/components/chat-timeline-utilities.js +71 -0
  45. package/dist/components/chat-timeline-utilities.js.map +1 -0
  46. package/dist/components/chat-ui-constants.d.ts +98 -0
  47. package/dist/components/chat-ui-constants.d.ts.map +1 -0
  48. package/dist/components/chat-ui-constants.js +146 -0
  49. package/dist/components/chat-ui-constants.js.map +1 -0
  50. package/dist/components/chat-undo-utilities.d.ts +47 -0
  51. package/dist/components/chat-undo-utilities.d.ts.map +1 -0
  52. package/dist/components/chat-undo-utilities.js +73 -0
  53. package/dist/components/chat-undo-utilities.js.map +1 -0
  54. package/dist/components/context-usage-utilities.d.ts +25 -3
  55. package/dist/components/context-usage-utilities.d.ts.map +1 -1
  56. package/dist/components/context-usage-utilities.js +42 -2
  57. package/dist/components/context-usage-utilities.js.map +1 -1
  58. package/dist/index.d.ts +2 -0
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +2 -0
  61. package/dist/index.js.map +1 -1
  62. package/dist/panels.d.ts +6 -0
  63. package/dist/panels.d.ts.map +1 -1
  64. package/dist/panels.js +6 -0
  65. package/dist/panels.js.map +1 -1
  66. package/package.json +2 -2
package/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-17T07:08:06.498Z
6
+ Generated: 2026-11-22T12:47:00.615Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-ide-panel-logic
@@ -325,6 +325,44 @@ interface ChatTimestampSlot {
325
325
  }
326
326
  ```
327
327
 
328
+ #### `ChatCardCodeStyle`
329
+
330
+ Inline monospace code style for command/identifier spans in chat cards.
331
+
332
+ ```typescript
333
+ interface ChatCardCodeStyle {
334
+ /** Monospace font stack. */
335
+ fontFamily: string
336
+ /** Slightly smaller than the card body text. */
337
+ fontSize: string
338
+ /** Tight padding around the code span. */
339
+ padding: string
340
+ /** Corner radius in pixels. */
341
+ borderRadius: number
342
+ /** Subtle gray chip background. */
343
+ background: string
344
+ /** The 1px chip frame. */
345
+ border: string
346
+ /** Commands never wrap inside a chat card line. */
347
+ whiteSpace: string
348
+ }
349
+ ```
350
+
351
+ #### `ChatCardLinkStyle`
352
+
353
+ Inline link style for action segments in chat cards.
354
+
355
+ ```typescript
356
+ interface ChatCardLinkStyle {
357
+ /** The theme primary, so a link reads clickable in any theme. */
358
+ color: string
359
+ /** Underline — the affordance that says "clickable". */
360
+ textDecoration: string
361
+ /** Pointer cursor. */
362
+ cursor: string
363
+ }
364
+ ```
365
+
328
366
  #### `DeviceDimensions`
329
367
 
330
368
  Per-frame iframe sizing. `width`/`height` are the PORTRAIT CSS sizes; a
@@ -1965,6 +2003,111 @@ function chatCardStyle(accent?: string): ChatCardStyle
1965
2003
 
1966
2004
  **Returns:** The container `style` chrome (border, background, padding, radius).
1967
2005
 
2006
+ #### `relativeTime(iso)`
2007
+
2008
+ Formats an ISO timestamp as a relative time string (e.g. "5m ago", "2h ago").
2009
+
2010
+ ```typescript
2011
+ function relativeTime(iso: string): string
2012
+ ```
2013
+
2014
+ - `iso` — The ISO 8601 timestamp string.
2015
+
2016
+ **Returns:** A human-readable relative time string.
2017
+
2018
+ #### `allowanceResetCountdown(t, resetAt)`
2019
+
2020
+ Format an AI-allowance window reset (epoch ms) as a short countdown phrase for
2021
+ the /cost used-up line ("refreshes in about 3 hours"). Under an hour reads "in
2022
+ under an hour"; ≥ 6h out on a later local calendar day reads "tomorrow"; a day
2023
+ or more out reads "in about N days".
2024
+
2025
+ The day scale is what makes this usable on a BILLING-PERIOD allowance, which
2026
+ can be weeks out — an hours-only formatter capped at "tomorrow", so a window
2027
+ ending in 18 days told the user it came back in the morning.
2028
+
2029
+ ```typescript
2030
+ function allowanceResetCountdown(t: TranslateFunction, resetAt: number): string
2031
+ ```
2032
+
2033
+ - `t` — The translation function from `useTranslation()`.
2034
+ - `resetAt` — Epoch ms of the window end (always in the future from the API).
2035
+
2036
+ **Returns:** A localized human countdown phrase.
2037
+
2038
+ #### `fileToBase64(file)`
2039
+
2040
+ Reads a File as base64 (without data-URL prefix).
2041
+
2042
+ ```typescript
2043
+ function fileToBase64(file: File): Promise<string>
2044
+ ```
2045
+
2046
+ - `file` — The file to encode.
2047
+
2048
+ **Returns:** Base64-encoded string.
2049
+
2050
+ #### `formatSize(bytes)`
2051
+
2052
+ Formats a byte count as a human-readable size string.
2053
+
2054
+ ```typescript
2055
+ function formatSize(bytes: number): string
2056
+ ```
2057
+
2058
+ - `bytes` — The size in bytes.
2059
+
2060
+ **Returns:** Formatted string (e.g., "1.2MB").
2061
+
2062
+ #### `formatThinkingDuration(t, ms)`
2063
+
2064
+ Format a duration in milliseconds as a human-readable string.
2065
+
2066
+ ```typescript
2067
+ function formatThinkingDuration(t: TranslateFunction, ms: number): string
2068
+ ```
2069
+
2070
+ - `t` — The translation function from `useTranslation()`.
2071
+ - `ms` — Duration in milliseconds.
2072
+
2073
+ **Returns:** Formatted string like "Thought for 5 seconds" or "Thought for 2 minutes".
2074
+
2075
+ #### `panelOverlayHeading(t, overlay)`
2076
+
2077
+ The heading of the closeable panel overlay (/skills, /scripts, /settings) above the composer.
2078
+
2079
+ ```typescript
2080
+ function panelOverlayHeading(
2081
+ t: TranslateFunction,
2082
+ overlay: 'skills' | 'scripts' | 'settings' | 'tests',
2083
+ ): string
2084
+ ```
2085
+
2086
+ #### `streamingActivityLabel(t, msg)`
2087
+
2088
+ Derive a real current-activity label for the streaming indicator from the
2089
+ in-flight assistant message's latest block, so the user sees what's actually
2090
+ happening (e.g. "Reading App.tsx", "Writing the plan") instead of a generic
2091
+ spinner. Returns undefined when there's nothing specific to show (the
2092
+ indicator then falls back to its rotating generic messages).
2093
+
2094
+ ```typescript
2095
+ function streamingActivityLabel(
2096
+ t: TranslateFunction,
2097
+ msg: {
2098
+ blocks?: ChatMessage['blocks']
2099
+ toolCalls?: Array<Pick<NonNullable<ChatMessage['toolCalls']>[number], 'id' | 'name' | 'input'>>
2100
+ },
2101
+ ): string | undefined
2102
+ ```
2103
+
2104
+ - `t` — The translation function from `useTranslation()`.
2105
+ - `msg` — The streaming assistant message.
2106
+ - `msg.blocks` — The message's ordered blocks (a tool call is a `tool_call` block naming its id).
2107
+ - `msg.toolCalls` — The message's tool calls, looked up by block id.
2108
+
2109
+ **Returns:** A short activity label, or undefined.
2110
+
1968
2111
  #### `parseReportCommand(input)`
1969
2112
 
1970
2113
  Parses a `/report [title]` or `/bug [title]` command. Returns the (possibly
@@ -3108,6 +3251,139 @@ Window event dispatched (same tab) whenever the preference changes.
3108
3251
  const CHAT_TIMESTAMPS_EVENT: 'mol:chat-timestamps-changed'
3109
3252
  ```
3110
3253
 
3254
+ #### `CHAT_CARD_CODE_STYLE`
3255
+
3256
+ Subtle inline monospace code style for command/identifier spans in chat cards.
3257
+
3258
+ ```typescript
3259
+ const CHAT_CARD_CODE_STYLE: ChatCardCodeStyle
3260
+ ```
3261
+
3262
+ #### `CHAT_CARD_LINK_STYLE`
3263
+
3264
+ Inline link style for action segments in chat cards (theme primary, underlined).
3265
+
3266
+ ```typescript
3267
+ const CHAT_CARD_LINK_STYLE: ChatCardLinkStyle
3268
+ ```
3269
+
3270
+ #### `USER_ACCENT_STYLE`
3271
+
3272
+ User-message accent stripe. The left edge of a real user message draws a vertical,
3273
+ multi-tone BLUE gradient swept gently up and down (the same smooth single-gradient
3274
+ technique as the composer ring, but vertical + blue) — NOT a repeating barber-pole,
3275
+ which read busy + janky. The host supplies the curated blues via
3276
+ `--mol-chat-accent-gradient`; the fallback is a lightened primary so it stays blue +
3277
+ never dark in any theme (the theme's primary-light/-dark tokens are actually a medium
3278
+
3279
+ - a dark blue with no light tone). It's a full-box gradient (so the sweep has room to
3280
+ travel) clipped to a 3px LEFT band that follows the row's rounded corners. A
3281
+ `::before` + its keyframe can't be expressed inline (and inline `animation` can't be
3282
+ media-queried), so — like AutoCommitBadge — it is injected once and gated on the
3283
+ existing `data-mol-id`; the auto-sent row keeps its solid success accent.
3284
+
3285
+ ```typescript
3286
+ const USER_ACCENT_STYLE: '\n[data-mol-id="chat-user-message"] { position: relative; }\n[data-mol-id="chat-user-message"]::before {\n content: \'\';\n position: absolute;\n inset: 0;\n border-radius: inherit;\n background: var(--mol-chat-accent-gradient, linear-gradient(to bottom, color-mix(in srgb, var(--mol-color-primary, #3060c0) 85%, #fff), color-mix(in srgb, var(--mol-color-primary, #3060c0) 50%, #fff) 50%, color-mix(in srgb, var(--mol-color-primary, #3060c0) 85%, #fff)));\n background-size: 100% 300%;\n animation: mol-chat-accent-flow 6s ease-in-out infinite;\n -webkit-mask: linear-gradient(to right, #000 3px, transparent 3px);\n mask: linear-gradient(to right, #000 3px, transparent 3px);\n pointer-events: none;\n}\n@keyframes mol-chat-accent-flow {\n 0%, 100% { background-position: 50% 0%; }\n 50% { background-position: 50% 100%; }\n}\n@media (prefers-reduced-motion: reduce) {\n [data-mol-id="chat-user-message"]::before { animation: none; }\n}'
3287
+ ```
3288
+
3289
+ #### `MAX_ATTACHMENT_SIZE`
3290
+
3291
+ Maximum file size for attachments (20 MB).
3292
+
3293
+ ```typescript
3294
+ const MAX_ATTACHMENT_SIZE: number
3295
+ ```
3296
+
3297
+ #### `ACCEPTED_FILE_TYPES`
3298
+
3299
+ MIME types accepted by the file input for AI provider attachments.
3300
+
3301
+ ```typescript
3302
+ const ACCEPTED_FILE_TYPES: 'image/jpeg,image/png,image/gif,image/webp,image/svg+xml,application/pdf,audio/mpeg,audio/wav,audio/ogg,audio/flac,audio/webm,video/mp4,video/webm'
3303
+ ```
3304
+
3305
+ #### `USER_MSG_COLLAPSE_HEIGHT`
3306
+
3307
+ Height threshold (px) above which user messages get collapsed.
3308
+
3309
+ ```typescript
3310
+ const USER_MSG_COLLAPSE_HEIGHT: 150
3311
+ ```
3312
+
3313
+ #### `LOAD_EARLIER_THRESHOLD_PX`
3314
+
3315
+ Distance from the top (px) at which scrolling up pages in older timeline
3316
+ items. Same idea as the 80px bottom threshold of the stick-to-bottom
3317
+ detector: a margin, so the trigger fires while the user is still moving,
3318
+ not only pinned exactly at scrollTop 0.
3319
+
3320
+ ```typescript
3321
+ const LOAD_EARLIER_THRESHOLD_PX: 120
3322
+ ```
3323
+
3324
+ #### `APP_VERSION`
3325
+
3326
+ The version this IDE reports — read by the `/version` command output AND the
3327
+ `/version` entry's description in the slash-command menu, so the menu shows
3328
+ the real number, not a stale literal.
3329
+
3330
+ ```typescript
3331
+ const APP_VERSION: '0.1.0'
3332
+ ```
3333
+
3334
+ #### `TIMELINE_ITEM_GAP`
3335
+
3336
+ Standard bottom margin (px) every chat-timeline item owns. 8px-grid rhythm unit.
3337
+
3338
+ ```typescript
3339
+ const TIMELINE_ITEM_GAP: 16
3340
+ ```
3341
+
3342
+ #### `TIMELINE_ITEM_GAP_DISCOVERY`
3343
+
3344
+ Roomier bottom margin (px) for discovery-phase message cards (intentionally looser).
3345
+
3346
+ ```typescript
3347
+ const TIMELINE_ITEM_GAP_DISCOVERY: 24
3348
+ ```
3349
+
3350
+ #### `AUTO_SENT_ACCENT`
3351
+
3352
+ Accent (success green) for an auto-sent message card — drives its tint, 1px border
3353
+ and `sync` icon via {@link chatCardStyle}, so an agent-sent message is unmistakably
3354
+ green while sharing the exact card shape of the user message and info cards.
3355
+
3356
+ ```typescript
3357
+ const AUTO_SENT_ACCENT: 'var(--mol-color-success, #16a34a)'
3358
+ ```
3359
+
3360
+ #### `NOTICE_TONE`
3361
+
3362
+ The accent + default icon per notice tone, keyed by tone id.
3363
+
3364
+ ```typescript
3365
+ const NOTICE_TONE: Record<
3366
+ 'info' | 'gold' | 'upgrade' | 'success' | 'signup',
3367
+ { accent: string; icon: IconName }
3368
+ >
3369
+ ```
3370
+
3371
+ #### `NOTICE_TONE_BUTTON_COLOR`
3372
+
3373
+ The SEMANTIC button colour each notice tone falls back to when the host gives
3374
+ an action no explicit `color`. Every notice-card action is a design-system
3375
+ button; this is only about which semantic it takes when the caller did not
3376
+ say. Without it a coloured action and a colourless one rendered side by side
3377
+ in the SAME card with two different box models (13px/3px vs a hand-rolled
3378
+ 12px/6px) — the exact mismatch this treatment exists to prevent.
3379
+
3380
+ ```typescript
3381
+ const NOTICE_TONE_BUTTON_COLOR: Record<
3382
+ 'info' | 'gold' | 'upgrade' | 'success' | 'signup',
3383
+ NonNullable<ChatEventCardAction['color']>
3384
+ >
3385
+ ```
3386
+
3111
3387
  #### `DEVICE_FRAMES`
3112
3388
 
3113
3389
  The device frames the selector dropdown lists, in display order.
@@ -1,8 +1,18 @@
1
1
  /**
2
- * Timeline ordering for the chat transcript.
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 type { CardEvent, ChatErrorMeta, ChatMessage } from '@molecule/app-ai-chat';
14
+ import type { ActivityCardEntry, CommitCard, SystemCard, TipCardEntry } from './components/chat-card-event-utilities.js';
15
+ import type { ChatTimestampSlot } from './components/chat-timestamps-utilities.js';
6
16
  /** The minimal shape {@link timelineSortKey} reads from a timeline item. */
7
17
  interface OrderableItem {
8
18
  kind: string;
@@ -46,5 +56,169 @@ interface OrderableItem {
46
56
  * @returns The numeric key to sort ascending by.
47
57
  */
48
58
  export declare function timelineSortKey(item: OrderableItem): number;
59
+ /**
60
+ * One item of the rendered chat timeline: a chat message, or one of the card
61
+ * kinds the panel appends after the messages (commit cards, system cards,
62
+ * activity cards, tip cards).
63
+ */
64
+ export type ChatTimelineItem = {
65
+ kind: 'message';
66
+ msg: ChatMessage;
67
+ } | {
68
+ kind: 'commit';
69
+ card: CommitCard;
70
+ } | {
71
+ kind: 'system';
72
+ card: SystemCard;
73
+ } | {
74
+ kind: 'activity';
75
+ card: ActivityCardEntry;
76
+ } | {
77
+ kind: 'tip';
78
+ card: TipCardEntry;
79
+ };
80
+ /**
81
+ * Never render hidden driver messages (the post-boot kickoff etc.). The server
82
+ * already filters them on read, but guard here too so the client NEVER shows
83
+ * one — even an optimistic/in-flight hidden message.
84
+ *
85
+ * @param messages - The transcript's messages.
86
+ * @returns The messages the timeline may render.
87
+ */
88
+ export declare function selectVisibleMessages(messages: readonly ChatMessage[]): ChatMessage[];
89
+ /**
90
+ * Splits out the queued messages (user/auto messages waiting to send while the
91
+ * agent works). They are NOT rendered inline in the scrolling timeline — they'd
92
+ * be pushed around and reflow as the response streams. They render instead in an
93
+ * anchored bar pinned above the composer (the same fixed-position treatment as
94
+ * the commit bar), so the timeline never includes them.
95
+ *
96
+ * @param visibleMessages - The visible messages (see {@link selectVisibleMessages}).
97
+ * @returns The queued subset, in queue order.
98
+ */
99
+ export declare function selectQueuedMessages(visibleMessages: readonly ChatMessage[]): ChatMessage[];
100
+ /**
101
+ * Whether a limit the backend raised for an ANONYMOUS caller is now STALE — the
102
+ * viewer signed in, so they have an account, a different allowance, and two
103
+ * dead-end buttons. A `requiresSignup` error, whose whole message is "…for
104
+ * guests … or create a free account for more" and whose CTAs are Sign up / Log
105
+ * in, is stale the moment the viewer is no longer anonymous. The error state
106
+ * survives the in-place auth modal (nothing navigates, and useChat only clears
107
+ * it on the next send), so without this the freshly-signed-up user keeps reading
108
+ * the guest limit they just escaped. Same reasoning the host's `upgrade_prompt`
109
+ * card factory already applies to the recorded guest card.
110
+ *
111
+ * @param errorMeta - The error's limit metadata, or `null` when there is none.
112
+ * @param isAnonymous - Whether the viewer is still anonymous; `undefined` (not yet
113
+ * known) counts as anonymous, so the limit stays until sign-in is confirmed.
114
+ * @returns Whether the guest limit is stale and must not render.
115
+ */
116
+ export declare function isStaleAnonymousLimit(errorMeta: ChatErrorMeta | null, isAnonymous: boolean | undefined): boolean;
117
+ /** Everything {@link buildChatTimeline} needs to build the timeline. */
118
+ export interface BuildChatTimelineInput {
119
+ /** The messages to render (already filtered through {@link selectVisibleMessages}). */
120
+ visibleMessages: readonly ChatMessage[];
121
+ /** Builds a system card from a card-message's recorded event, or `null` to drop it. */
122
+ cardEventToSystemCard: (cardEvent: CardEvent, id: string, timestamp: number) => SystemCard | null;
123
+ /** This session's local commit cards. */
124
+ commitCards: readonly CommitCard[];
125
+ /** This session's local command cards (ephemeral). */
126
+ systemCards: readonly SystemCard[];
127
+ /** The captured activity cards. */
128
+ activityCards: readonly ActivityCardEntry[];
129
+ /** The dismissable tip cards. */
130
+ tipCards: readonly TipCardEntry[];
131
+ /** The live error text, or `null`. */
132
+ error: string | null;
133
+ /** The live error's limit metadata, or `null`. */
134
+ errorMeta: ChatErrorMeta | null;
135
+ /** Whether the live error's anonymous limit is stale (see {@link isStaleAnonymousLimit}). */
136
+ isStaleAnonymousLimit: boolean;
137
+ }
138
+ /**
139
+ * Build a unified timeline so commit cards appear at the correct position.
140
+ *
141
+ * A card-message (role:'system' carrying a cardEvent) renders as a SYSTEM CARD,
142
+ * not a chat bubble — split it out here so it flows through the same card render
143
+ * path, sourced from the ONE transcript. Every other message renders as a
144
+ * message. A limit the LIVE banner is already stating is dropped from its card
145
+ * while the banner is up: a limit is hit once but surfaces twice — the card
146
+ * recorded when the turn was interrupted, then the banner when the next send is
147
+ * refused — so a card that declares it covers this same limit is dropped while
148
+ * the banner is up (it comes back when the error clears). The banner stays: it
149
+ * is the refused send's only feedback, and its message can be the more specific
150
+ * one (platform capacity vs the user's own budget, same `limitType`).
151
+ *
152
+ * The commit endpoint both returns the commit AND persists it as a
153
+ * `commitRecord` message, so once any history reload (tab refocus,
154
+ * end-of-turn reconcile) pulls that record into `messages`, this session's local
155
+ * card for the same commit is a duplicate. The persisted record wins; a local
156
+ * card is kept only until it lands.
157
+ *
158
+ * Order by timestamp, EXCEPT an empty (still-thinking) streaming response sorts
159
+ * last — so a turn's preamble cards (mode/model/skills notices, onboarding tips),
160
+ * emitted a beat after the placeholder is created, render ABOVE the response
161
+ * rather than below the whole streamed block. See {@link timelineSortKey}.
162
+ *
163
+ * @param input - The messages and cards to build from, plus the live error state.
164
+ * @returns The ordered timeline items.
165
+ */
166
+ export declare function buildChatTimeline(input: BuildChatTimelineInput): ChatTimelineItem[];
167
+ /** A timeline item's timestamp placement: in the header row, or on its own line. */
168
+ export interface TimelineTimestampSlot extends ChatTimestampSlot {
169
+ /** Where the time renders: in the message header row, or on a line above the item. */
170
+ placement: 'header' | 'line';
171
+ /** Text alignment for a line-placed time. */
172
+ align: 'left' | 'center';
173
+ }
174
+ /**
175
+ * Where (if anywhere) a timeline item carries its time. Typed user messages and
176
+ * team notes carry it in their header row and always qualify; Synthase replies
177
+ * and event cards get a line above them, and qualify with timestamps off only
178
+ * when critical. The command browsers (/settings, /skills, /scripts, /help) are
179
+ * this viewer's UI, not something that happened, so they never carry one.
180
+ *
181
+ * @param item - The timeline item.
182
+ * @returns Its slot, or `null` when it carries no timestamp.
183
+ */
184
+ export declare function timestampSlotFor(item: ChatTimelineItem): TimelineTimestampSlot | null;
185
+ /**
186
+ * Whether the latest plan is waiting on the person: a plan step only spins while
187
+ * a turn is running; otherwise it says it is waiting on the person when the last
188
+ * message carries an unanswered `ask_user` (a tool call whose output status is
189
+ * `awaiting_response`).
190
+ *
191
+ * @param messages - The transcript's messages.
192
+ * @returns Whether the plan awaits a user response.
193
+ */
194
+ export declare function planAwaitingUser(messages: readonly ChatMessage[]): boolean;
195
+ /** Everything {@link isWorkVisible} needs to decide whether the work card shows. */
196
+ export interface ChatWorkVisibilityInput {
197
+ /** The composer's slash-command menu, when open. */
198
+ commandMenu: unknown;
199
+ /** The model picker, when open. */
200
+ modelPicker: unknown;
201
+ /** The effort picker, when open. */
202
+ effortPicker: unknown;
203
+ /** The closeable panel overlay, when open. */
204
+ panelOverlay: unknown;
205
+ /** The latest plan's steps. */
206
+ plan: readonly unknown[];
207
+ /** The background tasks in flight. */
208
+ backgroundTasks: readonly unknown[];
209
+ /** Whether the tests strip shows. */
210
+ showTests: boolean;
211
+ /** Whether the pending-files strip shows. */
212
+ showFiles: boolean;
213
+ }
214
+ /**
215
+ * Everything about the work in flight shares one card above the composer. The
216
+ * tests strip also shows for a read-only viewer (watching is not editing); the
217
+ * files strip does not (committing is editor work). Popups hide the card.
218
+ *
219
+ * @param input - The popup states and the work the card would show.
220
+ * @returns Whether the work card renders.
221
+ */
222
+ export declare function isWorkVisible(input: ChatWorkVisibilityInput): boolean;
49
223
  export {};
50
224
  //# sourceMappingURL=chatTimelineOrdering.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chatTimelineOrdering.d.ts","sourceRoot":"","sources":["../src/chatTimelineOrdering.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4EAA4E;AAC5E,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE;QACJ,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,CAAC,EAAE,OAAO,CAAA;QACrB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;QAClB,MAAM,CAAC,EAAE,OAAO,CAAA;KACjB,CAAA;IACD,IAAI,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CA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