@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.
Files changed (70) hide show
  1. package/README.md +285 -3
  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-card-style.d.ts +7 -1
  11. package/dist/components/chat-card-style.d.ts.map +1 -1
  12. package/dist/components/chat-card-style.js +8 -2
  13. package/dist/components/chat-card-style.js.map +1 -1
  14. package/dist/components/chat-composer-utilities.d.ts +472 -0
  15. package/dist/components/chat-composer-utilities.d.ts.map +1 -0
  16. package/dist/components/chat-composer-utilities.js +519 -0
  17. package/dist/components/chat-composer-utilities.js.map +1 -0
  18. package/dist/components/chat-dictation-controller.d.ts +376 -0
  19. package/dist/components/chat-dictation-controller.d.ts.map +1 -0
  20. package/dist/components/chat-dictation-controller.js +559 -0
  21. package/dist/components/chat-dictation-controller.js.map +1 -0
  22. package/dist/components/chat-effort-utilities.d.ts +24 -0
  23. package/dist/components/chat-effort-utilities.d.ts.map +1 -1
  24. package/dist/components/chat-effort-utilities.js +41 -0
  25. package/dist/components/chat-effort-utilities.js.map +1 -1
  26. package/dist/components/chat-format-utilities.d.ts +71 -0
  27. package/dist/components/chat-format-utilities.d.ts.map +1 -0
  28. package/dist/components/chat-format-utilities.js +192 -0
  29. package/dist/components/chat-format-utilities.js.map +1 -0
  30. package/dist/components/chat-models-utilities.d.ts +168 -0
  31. package/dist/components/chat-models-utilities.d.ts.map +1 -1
  32. package/dist/components/chat-models-utilities.js +253 -0
  33. package/dist/components/chat-models-utilities.js.map +1 -1
  34. package/dist/components/chat-settings-utilities.d.ts +153 -1
  35. package/dist/components/chat-settings-utilities.d.ts.map +1 -1
  36. package/dist/components/chat-settings-utilities.js +204 -1
  37. package/dist/components/chat-settings-utilities.js.map +1 -1
  38. package/dist/components/chat-stream-utilities.d.ts +165 -1
  39. package/dist/components/chat-stream-utilities.d.ts.map +1 -1
  40. package/dist/components/chat-stream-utilities.js +155 -1
  41. package/dist/components/chat-stream-utilities.js.map +1 -1
  42. package/dist/components/chat-tests-controller.d.ts +249 -0
  43. package/dist/components/chat-tests-controller.d.ts.map +1 -0
  44. package/dist/components/chat-tests-controller.js +504 -0
  45. package/dist/components/chat-tests-controller.js.map +1 -0
  46. package/dist/components/chat-timeline-utilities.d.ts +90 -0
  47. package/dist/components/chat-timeline-utilities.d.ts.map +1 -0
  48. package/dist/components/chat-timeline-utilities.js +71 -0
  49. package/dist/components/chat-timeline-utilities.js.map +1 -0
  50. package/dist/components/chat-ui-constants.d.ts +98 -0
  51. package/dist/components/chat-ui-constants.d.ts.map +1 -0
  52. package/dist/components/chat-ui-constants.js +146 -0
  53. package/dist/components/chat-ui-constants.js.map +1 -0
  54. package/dist/components/chat-undo-utilities.d.ts +47 -0
  55. package/dist/components/chat-undo-utilities.d.ts.map +1 -0
  56. package/dist/components/chat-undo-utilities.js +73 -0
  57. package/dist/components/chat-undo-utilities.js.map +1 -0
  58. package/dist/components/context-usage-utilities.d.ts +25 -3
  59. package/dist/components/context-usage-utilities.d.ts.map +1 -1
  60. package/dist/components/context-usage-utilities.js +42 -2
  61. package/dist/components/context-usage-utilities.js.map +1 -1
  62. package/dist/index.d.ts +2 -0
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +2 -0
  65. package/dist/index.js.map +1 -1
  66. package/dist/panels.d.ts +6 -0
  67. package/dist/panels.d.ts.map +1 -1
  68. package/dist/panels.js +6 -0
  69. package/dist/panels.js.map +1 -1
  70. package/package.json +3 -3
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-22T22:19:37.468Z
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
@@ -1948,7 +1986,7 @@ function chatCardBg(accent?: string, pct?: number): string
1948
1986
 
1949
1987
  **Returns:** A `color-mix` background colour.
1950
1988
 
1951
- #### `chatCardStyle(accent)`
1989
+ #### `chatCardStyle(accent, borderPct)`
1952
1990
 
1953
1991
  The single container chrome shared by every boxed info card in the chat
1954
1992
  timeline: subtle tint, full 1px border on all sides, one padding, one radius.
@@ -1957,14 +1995,125 @@ Spread it first, then add layout (`display`/`gap`/`alignItems`) and the
1957
1995
  bottom-margin rhythm at the call site — e.g.
1958
1996
  `style={{ display: 'flex', gap: 10, marginBottom: TIMELINE_ITEM_GAP, ...chatCardStyle(accent) }}`.
1959
1997
 
1998
+ A card that deepens its frame on hover sets the whole `border` to
1999
+ `chatCardStyle(accent, 70).border`, never `borderColor` alone: the frame is a shorthand
2000
+ holding a CSS variable, and a longhand written over it leaves its other longhands with no
2001
+ readable value (`getPropertyValue` returns `''`), in a browser and in the conformance kit.
2002
+
1960
2003
  ```typescript
1961
- function chatCardStyle(accent?: string): ChatCardStyle
2004
+ function chatCardStyle(accent?: string, borderPct?: number): ChatCardStyle
1962
2005
  ```
1963
2006
 
1964
2007
  - `accent` — Tint/border source colour. Defaults to the theme primary (neutral cards).
2008
+ - `borderPct` — Opacity of the accent in the border mix (percent). Defaults to the resting 40.
1965
2009
 
1966
2010
  **Returns:** The container `style` chrome (border, background, padding, radius).
1967
2011
 
2012
+ #### `relativeTime(iso)`
2013
+
2014
+ Formats an ISO timestamp as a relative time string (e.g. "5m ago", "2h ago").
2015
+
2016
+ ```typescript
2017
+ function relativeTime(iso: string): string
2018
+ ```
2019
+
2020
+ - `iso` — The ISO 8601 timestamp string.
2021
+
2022
+ **Returns:** A human-readable relative time string.
2023
+
2024
+ #### `allowanceResetCountdown(t, resetAt)`
2025
+
2026
+ Format an AI-allowance window reset (epoch ms) as a short countdown phrase for
2027
+ the /cost used-up line ("refreshes in about 3 hours"). Under an hour reads "in
2028
+ under an hour"; ≥ 6h out on a later local calendar day reads "tomorrow"; a day
2029
+ or more out reads "in about N days".
2030
+
2031
+ The day scale is what makes this usable on a BILLING-PERIOD allowance, which
2032
+ can be weeks out — an hours-only formatter capped at "tomorrow", so a window
2033
+ ending in 18 days told the user it came back in the morning.
2034
+
2035
+ ```typescript
2036
+ function allowanceResetCountdown(t: TranslateFunction, resetAt: number): string
2037
+ ```
2038
+
2039
+ - `t` — The translation function from `useTranslation()`.
2040
+ - `resetAt` — Epoch ms of the window end (always in the future from the API).
2041
+
2042
+ **Returns:** A localized human countdown phrase.
2043
+
2044
+ #### `fileToBase64(file)`
2045
+
2046
+ Reads a File as base64 (without data-URL prefix).
2047
+
2048
+ ```typescript
2049
+ function fileToBase64(file: File): Promise<string>
2050
+ ```
2051
+
2052
+ - `file` — The file to encode.
2053
+
2054
+ **Returns:** Base64-encoded string.
2055
+
2056
+ #### `formatSize(bytes)`
2057
+
2058
+ Formats a byte count as a human-readable size string.
2059
+
2060
+ ```typescript
2061
+ function formatSize(bytes: number): string
2062
+ ```
2063
+
2064
+ - `bytes` — The size in bytes.
2065
+
2066
+ **Returns:** Formatted string (e.g., "1.2MB").
2067
+
2068
+ #### `formatThinkingDuration(t, ms)`
2069
+
2070
+ Format a duration in milliseconds as a human-readable string.
2071
+
2072
+ ```typescript
2073
+ function formatThinkingDuration(t: TranslateFunction, ms: number): string
2074
+ ```
2075
+
2076
+ - `t` — The translation function from `useTranslation()`.
2077
+ - `ms` — Duration in milliseconds.
2078
+
2079
+ **Returns:** Formatted string like "Thought for 5 seconds" or "Thought for 2 minutes".
2080
+
2081
+ #### `panelOverlayHeading(t, overlay)`
2082
+
2083
+ The heading of the closeable panel overlay (/skills, /scripts, /settings) above the composer.
2084
+
2085
+ ```typescript
2086
+ function panelOverlayHeading(
2087
+ t: TranslateFunction,
2088
+ overlay: 'skills' | 'scripts' | 'settings' | 'tests',
2089
+ ): string
2090
+ ```
2091
+
2092
+ #### `streamingActivityLabel(t, msg)`
2093
+
2094
+ Derive a real current-activity label for the streaming indicator from the
2095
+ in-flight assistant message's latest block, so the user sees what's actually
2096
+ happening (e.g. "Reading App.tsx", "Writing the plan") instead of a generic
2097
+ spinner. Returns undefined when there's nothing specific to show (the
2098
+ indicator then falls back to its rotating generic messages).
2099
+
2100
+ ```typescript
2101
+ function streamingActivityLabel(
2102
+ t: TranslateFunction,
2103
+ msg: {
2104
+ blocks?: ChatMessage['blocks']
2105
+ toolCalls?: Array<Pick<NonNullable<ChatMessage['toolCalls']>[number], 'id' | 'name' | 'input'>>
2106
+ },
2107
+ ): string | undefined
2108
+ ```
2109
+
2110
+ - `t` — The translation function from `useTranslation()`.
2111
+ - `msg` — The streaming assistant message.
2112
+ - `msg.blocks` — The message's ordered blocks (a tool call is a `tool_call` block naming its id).
2113
+ - `msg.toolCalls` — The message's tool calls, looked up by block id.
2114
+
2115
+ **Returns:** A short activity label, or undefined.
2116
+
1968
2117
  #### `parseReportCommand(input)`
1969
2118
 
1970
2119
  Parses a `/report [title]` or `/bug [title]` command. Returns the (possibly
@@ -3108,6 +3257,139 @@ Window event dispatched (same tab) whenever the preference changes.
3108
3257
  const CHAT_TIMESTAMPS_EVENT: 'mol:chat-timestamps-changed'
3109
3258
  ```
3110
3259
 
3260
+ #### `CHAT_CARD_CODE_STYLE`
3261
+
3262
+ Subtle inline monospace code style for command/identifier spans in chat cards.
3263
+
3264
+ ```typescript
3265
+ const CHAT_CARD_CODE_STYLE: ChatCardCodeStyle
3266
+ ```
3267
+
3268
+ #### `CHAT_CARD_LINK_STYLE`
3269
+
3270
+ Inline link style for action segments in chat cards (theme primary, underlined).
3271
+
3272
+ ```typescript
3273
+ const CHAT_CARD_LINK_STYLE: ChatCardLinkStyle
3274
+ ```
3275
+
3276
+ #### `USER_ACCENT_STYLE`
3277
+
3278
+ User-message accent stripe. The left edge of a real user message draws a vertical,
3279
+ multi-tone BLUE gradient swept gently up and down (the same smooth single-gradient
3280
+ technique as the composer ring, but vertical + blue) — NOT a repeating barber-pole,
3281
+ which read busy + janky. The host supplies the curated blues via
3282
+ `--mol-chat-accent-gradient`; the fallback is a lightened primary so it stays blue +
3283
+ never dark in any theme (the theme's primary-light/-dark tokens are actually a medium
3284
+
3285
+ - a dark blue with no light tone). It's a full-box gradient (so the sweep has room to
3286
+ travel) clipped to a 3px LEFT band that follows the row's rounded corners. A
3287
+ `::before` + its keyframe can't be expressed inline (and inline `animation` can't be
3288
+ media-queried), so — like AutoCommitBadge — it is injected once and gated on the
3289
+ existing `data-mol-id`; the auto-sent row keeps its solid success accent.
3290
+
3291
+ ```typescript
3292
+ 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}'
3293
+ ```
3294
+
3295
+ #### `MAX_ATTACHMENT_SIZE`
3296
+
3297
+ Maximum file size for attachments (20 MB).
3298
+
3299
+ ```typescript
3300
+ const MAX_ATTACHMENT_SIZE: number
3301
+ ```
3302
+
3303
+ #### `ACCEPTED_FILE_TYPES`
3304
+
3305
+ MIME types accepted by the file input for AI provider attachments.
3306
+
3307
+ ```typescript
3308
+ 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'
3309
+ ```
3310
+
3311
+ #### `USER_MSG_COLLAPSE_HEIGHT`
3312
+
3313
+ Height threshold (px) above which user messages get collapsed.
3314
+
3315
+ ```typescript
3316
+ const USER_MSG_COLLAPSE_HEIGHT: 150
3317
+ ```
3318
+
3319
+ #### `LOAD_EARLIER_THRESHOLD_PX`
3320
+
3321
+ Distance from the top (px) at which scrolling up pages in older timeline
3322
+ items. Same idea as the 80px bottom threshold of the stick-to-bottom
3323
+ detector: a margin, so the trigger fires while the user is still moving,
3324
+ not only pinned exactly at scrollTop 0.
3325
+
3326
+ ```typescript
3327
+ const LOAD_EARLIER_THRESHOLD_PX: 120
3328
+ ```
3329
+
3330
+ #### `APP_VERSION`
3331
+
3332
+ The version this IDE reports — read by the `/version` command output AND the
3333
+ `/version` entry's description in the slash-command menu, so the menu shows
3334
+ the real number, not a stale literal.
3335
+
3336
+ ```typescript
3337
+ const APP_VERSION: '0.1.0'
3338
+ ```
3339
+
3340
+ #### `TIMELINE_ITEM_GAP`
3341
+
3342
+ Standard bottom margin (px) every chat-timeline item owns. 8px-grid rhythm unit.
3343
+
3344
+ ```typescript
3345
+ const TIMELINE_ITEM_GAP: 16
3346
+ ```
3347
+
3348
+ #### `TIMELINE_ITEM_GAP_DISCOVERY`
3349
+
3350
+ Roomier bottom margin (px) for discovery-phase message cards (intentionally looser).
3351
+
3352
+ ```typescript
3353
+ const TIMELINE_ITEM_GAP_DISCOVERY: 24
3354
+ ```
3355
+
3356
+ #### `AUTO_SENT_ACCENT`
3357
+
3358
+ Accent (success green) for an auto-sent message card — drives its tint, 1px border
3359
+ and `sync` icon via {@link chatCardStyle}, so an agent-sent message is unmistakably
3360
+ green while sharing the exact card shape of the user message and info cards.
3361
+
3362
+ ```typescript
3363
+ const AUTO_SENT_ACCENT: 'var(--mol-color-success, #16a34a)'
3364
+ ```
3365
+
3366
+ #### `NOTICE_TONE`
3367
+
3368
+ The accent + default icon per notice tone, keyed by tone id.
3369
+
3370
+ ```typescript
3371
+ const NOTICE_TONE: Record<
3372
+ 'info' | 'gold' | 'upgrade' | 'success' | 'signup',
3373
+ { accent: string; icon: IconName }
3374
+ >
3375
+ ```
3376
+
3377
+ #### `NOTICE_TONE_BUTTON_COLOR`
3378
+
3379
+ The SEMANTIC button colour each notice tone falls back to when the host gives
3380
+ an action no explicit `color`. Every notice-card action is a design-system
3381
+ button; this is only about which semantic it takes when the caller did not
3382
+ say. Without it a coloured action and a colourless one rendered side by side
3383
+ in the SAME card with two different box models (13px/3px vs a hand-rolled
3384
+ 12px/6px) — the exact mismatch this treatment exists to prevent.
3385
+
3386
+ ```typescript
3387
+ const NOTICE_TONE_BUTTON_COLOR: Record<
3388
+ 'info' | 'gold' | 'upgrade' | 'success' | 'signup',
3389
+ NonNullable<ChatEventCardAction['color']>
3390
+ >
3391
+ ```
3392
+
3111
3393
  #### `DEVICE_FRAMES`
3112
3394
 
3113
3395
  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,CAAA;KAAE,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAS3D"}
1
+ {"version":3,"file":"chatTimelineOrdering.d.ts","sourceRoot":"","sources":["../src/chatTimelineOrdering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAElF,OAAO,KAAK,EACV,iBA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