@zyro-sec/session-ui 0.0.0-stage → 1.0.3
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/AGENTS.md +25 -0
- package/bunfig.toml +2 -0
- package/component-tests/basic-tool.fixture.tsx +46 -0
- package/component-tests/basic-tool.spec.ts +63 -0
- package/component-tests/file-media.fixture.tsx +39 -0
- package/component-tests/file-media.spec.ts +13 -0
- package/component-tests/file-tool.spec.ts +62 -0
- package/component-tests/file-viewer.fixture.tsx +109 -0
- package/component-tests/file-viewer.spec.ts +134 -0
- package/component-tests/file.spec.ts +33 -0
- package/component-tests/line-comment-v2.spec.ts +15 -0
- package/component-tests/markdown-code-wrap.spec.ts +94 -0
- package/component-tests/markdown-readiness.spec.ts +95 -0
- package/component-tests/markdown.fixture.tsx +104 -0
- package/component-tests/markdown.spec.ts +1564 -0
- package/component-tests/mermaid-preview.spec.ts +43 -0
- package/component-tests/patch-group.spec.ts +79 -0
- package/component-tests/read-group.spec.ts +72 -0
- package/component-tests/read-image.fixture.tsx +66 -0
- package/component-tests/read-image.spec.ts +154 -0
- package/component-tests/session-compaction.spec.ts +254 -0
- package/component-tests/session-lifecycle.spec.ts +190 -0
- package/component-tests/session-message-projection.spec.ts +639 -0
- package/component-tests/session-notice-projection.spec.ts +20 -0
- package/component-tests/session-review-comments.spec.ts +179 -0
- package/component-tests/session-shell.spec.ts +93 -0
- package/component-tests/session-timeline-mobile.spec.ts +201 -0
- package/component-tests/session-timeline-notices.spec.ts +38 -0
- package/component-tests/session-timeline-reasoning.spec.ts +107 -0
- package/component-tests/session-timeline.spec.ts +157 -0
- package/component-tests/session-tool-projection.spec.ts +323 -0
- package/component-tests/text-lifecycle.fixture.tsx +26 -0
- package/component-tests/text-lifecycle.spec.ts +42 -0
- package/component-tests/timeline-subagent-rows.spec.ts +33 -0
- package/component-tests/tool-disclosure.spec.ts +48 -0
- package/component-tests/tool-group-sticky.spec.ts +37 -0
- package/component-tests/tool-group.spec.ts +290 -0
- package/component-tests/tool-status-title.fixture.tsx +22 -0
- package/component-tests/tool-status-title.spec.ts +30 -0
- package/component-tests/user-message-quotes.spec.ts +111 -0
- package/package.json +91 -4
- package/playwright.components.config.ts +4 -0
- package/playwright.local.config.ts +2 -0
- package/src/actions.ts +54 -0
- package/src/components/apply-patch-file.ts +122 -0
- package/src/components/basic-tool.css +487 -0
- package/src/components/basic-tool.tsx +258 -0
- package/src/components/copy-machine.ts +78 -0
- package/src/components/copy.ts +85 -0
- package/src/components/diagram-preview.tsx +28 -0
- package/src/components/disclosure-machine.ts +188 -0
- package/src/components/disclosure.ts +129 -0
- package/src/components/dock-prompt.stories.tsx +73 -0
- package/src/components/dock-prompt.tsx +29 -0
- package/src/components/file-comment-selection.tsx +146 -0
- package/src/components/file-media-machine.ts +165 -0
- package/src/components/file-media.stories.tsx +112 -0
- package/src/components/file-media.tsx +323 -0
- package/src/components/file-search.tsx +73 -0
- package/src/components/file.css +59 -0
- package/src/components/file.tsx +1300 -0
- package/src/components/image-preview.tsx +35 -0
- package/src/components/line-comment-annotations.tsx +580 -0
- package/src/components/line-comment-machine.ts +262 -0
- package/src/components/line-comment-styles.ts +293 -0
- package/src/components/line-comment.stories.tsx +152 -0
- package/src/components/line-comment.tsx +448 -0
- package/src/components/link-segments.ts +20 -0
- package/src/components/linked-text.tsx +21 -0
- package/src/components/markdown-cache-machine.ts +257 -0
- package/src/components/markdown-cache.tsx +556 -0
- package/src/components/markdown-clipboard.ts +101 -0
- package/src/components/markdown-code-machine.ts +200 -0
- package/src/components/markdown-code-state.ts +22 -0
- package/src/components/markdown-fragment-links.ts +74 -0
- package/src/components/markdown-github.svg +3 -0
- package/src/components/markdown-globe.svg +5 -0
- package/src/components/markdown-image-machine.ts +170 -0
- package/src/components/markdown-image.ts +156 -0
- package/src/components/markdown-inline-code-kind.ts +39 -0
- package/src/components/markdown-mermaid.ts +18 -0
- package/src/components/markdown-phase-machine.ts +102 -0
- package/src/components/markdown-projection.ts +13 -0
- package/src/components/markdown-session-links.ts +183 -0
- package/src/components/markdown-solid.test.tsx +92 -0
- package/src/components/markdown-solid.tsx +113 -0
- package/src/components/markdown-stream.ts +95 -0
- package/src/components/markdown-worker-machine.ts +516 -0
- package/src/components/markdown-worker-protocol.ts +73 -0
- package/src/components/markdown-worker.ts +250 -0
- package/src/components/markdown.css +672 -0
- package/src/components/markdown.stories.tsx +199 -0
- package/src/components/markdown.tsx +1612 -0
- package/src/components/markdown.worker.ts +188 -0
- package/src/components/message-file.ts +102 -0
- package/src/components/message-nav.css +134 -0
- package/src/components/message-nav.tsx +159 -0
- package/src/components/message-part.css +2109 -0
- package/src/components/message-part.tsx +3 -0
- package/src/components/question-prompt-experimental.css +576 -0
- package/src/components/question-prompt.css +527 -0
- package/src/components/quote-highlight.css +59 -0
- package/src/components/review-focus-driver.ts +142 -0
- package/src/components/review-focus-machine.ts +95 -0
- package/src/components/session-compaction.css +270 -0
- package/src/components/session-diff.ts +358 -0
- package/src/components/session-error.tsx +41 -0
- package/src/components/session-retry.tsx +92 -0
- package/src/components/session-review-machine.ts +241 -0
- package/src/components/session-review.css +264 -0
- package/src/components/session-review.stories.tsx +232 -0
- package/src/components/session-review.tsx +733 -0
- package/src/components/session-turn.css +282 -0
- package/src/components/shell-submessage.css +24 -0
- package/src/components/timeline-separator.tsx +69 -0
- package/src/components/tool-count-label.css +57 -0
- package/src/components/tool-count-label.tsx +76 -0
- package/src/components/tool-count-summary.css +102 -0
- package/src/components/tool-count-summary.stories.tsx +99 -0
- package/src/components/tool-count-summary.tsx +44 -0
- package/src/components/tool-error-card.css +178 -0
- package/src/components/tool-error-card.stories.tsx +113 -0
- package/src/components/tool-error-card.tsx +202 -0
- package/src/components/tool-status-title-machine.ts +128 -0
- package/src/components/tool-status-title.css +89 -0
- package/src/components/tool-status-title.tsx +163 -0
- package/src/context/data.tsx +107 -0
- package/src/context/index.ts +1 -0
- package/src/context/markdown.tsx +129 -0
- package/src/context/sources.tsx +34 -0
- package/src/document.ts +8 -0
- package/src/file-presentation.ts +34 -0
- package/src/message/action-machine.ts +72 -0
- package/src/message/agent-label.ts +3 -0
- package/src/message/attachment-card.css +119 -0
- package/src/message/attachment-card.tsx +40 -0
- package/src/message/attachment-media-machine.ts +213 -0
- package/src/message/comment-card.tsx +155 -0
- package/src/message/compaction-entrance-machine.ts +93 -0
- package/src/message/current-message.tsx +157 -0
- package/src/message/current-tool-state.ts +161 -0
- package/src/message/message-content.tsx +1391 -0
- package/src/message/paced-text-machine.ts +73 -0
- package/src/message/prompt-message.stories.tsx +149 -0
- package/src/message/relative-time.ts +45 -0
- package/src/message/user-message-quote-parts.ts +16 -0
- package/src/message/user-message-quotes.stories.tsx +797 -0
- package/src/message/user-message-quotes.tsx +135 -0
- package/src/pierre/comment-hover-machine.ts +53 -0
- package/src/pierre/comment-hover.ts +131 -0
- package/src/pierre/comment-selection-machine.ts +257 -0
- package/src/pierre/commented-lines.ts +106 -0
- package/src/pierre/diff-selection.ts +91 -0
- package/src/pierre/file-find-machine.ts +323 -0
- package/src/pierre/file-find.ts +537 -0
- package/src/pierre/file-runtime.ts +42 -0
- package/src/pierre/file-selection.ts +140 -0
- package/src/pierre/index.ts +344 -0
- package/src/pierre/media.ts +140 -0
- package/src/pierre/render-machine.ts +381 -0
- package/src/pierre/selection-bridge.ts +82 -0
- package/src/pierre/selection-machine.ts +198 -0
- package/src/pierre/virtualizer.ts +114 -0
- package/src/pierre/worker.ts +46 -0
- package/src/sources/experiment.ts +59 -0
- package/src/sources/site-icon.tsx +53 -0
- package/src/sources/sources-chip.tsx +57 -0
- package/src/sources/sources-expand-machine.ts +101 -0
- package/src/sources/sources-panel.tsx +249 -0
- package/src/sources/sources-title.tsx +21 -0
- package/src/sources/sources.css +266 -0
- package/src/sources/sources.ts +141 -0
- package/src/storybook/current-session-fixtures.ts +1492 -0
- package/src/storybook/current-session-scenarios.ts +76 -0
- package/src/storybook/current-session-story.tsx +154 -0
- package/src/storybook/index.ts +43 -0
- package/src/styles/index.css +19 -0
- package/src/timeline/__snapshots__/group-labels.test.ts.snap +110 -0
- package/src/timeline/__snapshots__/placement.test.ts.snap +1041 -0
- package/src/timeline/code-blocks.stories.tsx +105 -0
- package/src/timeline/commentary.stories.tsx +70 -0
- package/src/timeline/commentary.ts +38 -0
- package/src/timeline/detail.ts +111 -0
- package/src/timeline/error-card.stories.tsx +134 -0
- package/src/timeline/error-spacing.stories.tsx +71 -0
- package/src/timeline/facts.ts +493 -0
- package/src/timeline/file-changes.stories.tsx +436 -0
- package/src/timeline/group-label-fixtures.ts +97 -0
- package/src/timeline/mermaid.stories.tsx +131 -0
- package/src/timeline/place.ts +280 -0
- package/src/timeline/placement-fixtures.ts +365 -0
- package/src/timeline/placement-reactivity.ts +133 -0
- package/src/timeline/projection.ts +1261 -0
- package/src/timeline/research-and-agents.stories.tsx +461 -0
- package/src/timeline/session-timeline-row.tsx +1675 -0
- package/src/timeline/session-timeline.tsx +68 -0
- package/src/timeline/steer-arrival-machine.ts +134 -0
- package/src/timeline/terminal-work.stories.tsx +464 -0
- package/src/timeline/timeline-row.stories.tsx +1069 -0
- package/src/timeline/timeline-row.ts +238 -0
- package/src/timeline/turn-phase-machine.ts +112 -0
- package/src/timeline/user-message-fold.stories.tsx +194 -0
- package/src/timeline/user-runs.ts +87 -0
- package/src/timeline-next/__snapshots__/placement.test.ts.snap +990 -0
- package/src/timeline-next/compaction.tsx +236 -0
- package/src/timeline-next/errors.ts +101 -0
- package/src/timeline-next/event-row.tsx +168 -0
- package/src/timeline-next/events.ts +103 -0
- package/src/timeline-next/index.ts +10 -0
- package/src/timeline-next/nested-rail.ts +125 -0
- package/src/timeline-next/projection.ts +1028 -0
- package/src/timeline-next/row.tsx +1728 -0
- package/src/timeline-next/rules.ts +89 -0
- package/src/timeline-next/separator.tsx +73 -0
- package/src/timeline-next/spacing.ts +127 -0
- package/src/timeline-next/status-line.tsx +41 -0
- package/src/timeline-next/status.ts +33 -0
- package/src/timeline-next/stories/compare-renderer.stories.tsx +190 -0
- package/src/timeline-next/stories/compare-sessions/.gitignore +3 -0
- package/src/timeline-next/stories/compare.stories.tsx +486 -0
- package/src/timeline-next/stories/playground.stories.tsx +297 -0
- package/src/timeline-next/stories/session-replay.ts +1156 -0
- package/src/timeline-next/stories/session-timeline.tsx +50 -0
- package/src/timeline-next/stories/subagent-status.stories.tsx +132 -0
- package/src/timeline-next/timeline-next.css +649 -0
- package/src/timeline-next/tools/__snapshots__/activity-label.test.ts.snap +39 -0
- package/src/timeline-next/tools/activity-label.ts +166 -0
- package/src/timeline-next/tools/assistant-content.tsx +84 -0
- package/src/timeline-next/tools/context-group.tsx +619 -0
- package/src/timeline-next/tools/error-card.tsx +147 -0
- package/src/timeline-next/tools/explore.tsx +119 -0
- package/src/timeline-next/tools/file-group.tsx +128 -0
- package/src/timeline-next/tools/patch.tsx +174 -0
- package/src/timeline-next/tools/shell.tsx +186 -0
- package/src/timeline-next/tools/thought.tsx +87 -0
- package/src/timeline-next/tools/tool-display.tsx +119 -0
- package/src/tools/ansi.ts +8 -0
- package/src/tools/context-group-label.ts +123 -0
- package/src/tools/file-runs.ts +35 -0
- package/src/tools/project-path.ts +18 -0
- package/src/tools/read-group.stories.tsx +159 -0
- package/src/tools/run-machine.ts +185 -0
- package/src/tools/shell-output-machine.ts +233 -0
- package/src/tools/shell-output.ts +91 -0
- package/src/tools/subagent-row-variants.stories.tsx +129 -0
- package/src/tools/tool-group.stories.tsx +345 -0
- package/src/tools/tool-renderer.tsx +2876 -0
- package/src/v2/components/line-comment-annotations-v2.tsx +215 -0
- package/src/v2/components/session-file-panel-v2.tsx +149 -0
- package/src/v2/components/session-progress-indicator-v2.css +5 -0
- package/src/v2/components/session-progress-indicator-v2.stories.tsx +86 -0
- package/src/v2/components/session-progress-indicator-v2.tsx +16 -0
- package/src/v2/components/session-review-empty-changes-v2.tsx +17 -0
- package/src/v2/components/session-review-empty-no-git-v2.tsx +28 -0
- package/src/v2/components/session-review-file-preview-v2-virtualize.ts +5 -0
- package/src/v2/components/session-review-file-preview-v2.tsx +266 -0
- package/src/v2/components/session-review-v2.css +653 -0
- package/src/v2/components/session-review-v2.tsx +422 -0
- package/src/v2/components/sidebar-presence-machine.ts +69 -0
- package/tsconfig.json +20 -0
- package/README.md +0 -3
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { SessionMessageCompaction } from "@zyro-sec/client/promise"
|
|
2
|
+
import { Card } from "@zyro-sec/ui/card"
|
|
3
|
+
import { useI18n } from "@zyro-sec/ui/context/i18n"
|
|
4
|
+
import { createEffect, createMemo, createSignal, onCleanup, Show, untrack } from "solid-js"
|
|
5
|
+
import { BasicTool } from "../components/basic-tool"
|
|
6
|
+
import { LinkedText } from "../components/linked-text"
|
|
7
|
+
import {
|
|
8
|
+
createCompactionEntranceState,
|
|
9
|
+
DISPOSED_COMPACTION_ENTRANCE_EVENT,
|
|
10
|
+
GRACE_ELAPSED_EVENT,
|
|
11
|
+
selectCompactionEnter,
|
|
12
|
+
transitionCompactionEntrance,
|
|
13
|
+
type CompactionEntranceEffect,
|
|
14
|
+
type CompactionEntranceEvent,
|
|
15
|
+
} from "../message/compaction-entrance-machine"
|
|
16
|
+
import { PacedMarkdown } from "../message/message-content"
|
|
17
|
+
import { Separator } from "./separator"
|
|
18
|
+
|
|
19
|
+
/** A compaction the server admitted but has not started, drawn as the divider a started one opens with. */
|
|
20
|
+
export function CompactionQueued() {
|
|
21
|
+
const i18n = useI18n()
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div data-component="session-compaction-message">
|
|
25
|
+
<Separator label={i18n.t("ui.messagePart.compaction.queued")} />
|
|
26
|
+
</div>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A compaction, drawn with the timeline's own dividers: as tall as their text, with a plain line, spaced like the rows
|
|
32
|
+
* around them. An automatic one is one quiet divider instead.
|
|
33
|
+
*/
|
|
34
|
+
export function CompactionMessage(props: { message: SessionMessageCompaction; error: string }) {
|
|
35
|
+
const i18n = useI18n()
|
|
36
|
+
const summary = () => (props.message.status === "failed" ? "" : props.message.summary)
|
|
37
|
+
|
|
38
|
+
const error = () => {
|
|
39
|
+
if (props.message.status !== "failed") return ""
|
|
40
|
+
|
|
41
|
+
if (props.message.error.type === "aborted" || props.message.error.type === "compaction.interrupted") return ""
|
|
42
|
+
|
|
43
|
+
return props.error
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const compact = createMemo(
|
|
47
|
+
() => new Intl.NumberFormat(i18n.locale(), { notation: "compact", maximumFractionDigits: 1 }),
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
// Usage of the compaction request itself; the resulting context size only shows on the next assistant step.
|
|
51
|
+
const usage = () => {
|
|
52
|
+
if (props.message.status === "running" || !props.message.tokens) return ""
|
|
53
|
+
const tokens = props.message.tokens
|
|
54
|
+
const input = tokens.input + tokens.cache.read + tokens.cache.write
|
|
55
|
+
const output = tokens.output + tokens.reasoning
|
|
56
|
+
|
|
57
|
+
if (input + output <= 0) return ""
|
|
58
|
+
|
|
59
|
+
return i18n.t("ui.messagePart.compaction.usage", {
|
|
60
|
+
input: compact().format(input),
|
|
61
|
+
output: compact().format(output),
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const outcome = () => {
|
|
66
|
+
if (props.message.status !== "failed")
|
|
67
|
+
return props.message.status === "completed" && props.message.native?.messages
|
|
68
|
+
? "ui.messagePart.providerCompaction"
|
|
69
|
+
: "ui.messagePart.compaction"
|
|
70
|
+
|
|
71
|
+
if (props.message.error.type === "aborted") return "ui.messagePart.compaction.cancelled"
|
|
72
|
+
|
|
73
|
+
if (props.message.error.type === "compaction.interrupted") return "ui.messagePart.compaction.interrupted"
|
|
74
|
+
|
|
75
|
+
return "ui.messagePart.compaction.failed"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const label = createMemo(() => [i18n.t(outcome()), usage()].filter(Boolean).join(" · "))
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Show
|
|
82
|
+
when={props.message.reason === "manual" || props.message.status === "failed"}
|
|
83
|
+
fallback={
|
|
84
|
+
<QuietCompaction
|
|
85
|
+
id={props.message.id}
|
|
86
|
+
created={props.message.time.created}
|
|
87
|
+
running={props.message.status === "running"}
|
|
88
|
+
summary={summary()}
|
|
89
|
+
usage={usage()}
|
|
90
|
+
/>
|
|
91
|
+
}
|
|
92
|
+
>
|
|
93
|
+
<div data-component="session-compaction-message" class="flex flex-col gap-[var(--timeline-gap-m)]">
|
|
94
|
+
<Separator label={i18n.t("ui.messagePart.compaction.started")} />
|
|
95
|
+
<Show when={summary().trim()}>
|
|
96
|
+
<div data-component="text-part" data-timeline-part-id={props.message.id}>
|
|
97
|
+
<div data-slot="text-part-body">
|
|
98
|
+
<PacedMarkdown
|
|
99
|
+
text={summary()}
|
|
100
|
+
cacheKey={props.message.id}
|
|
101
|
+
streaming={props.message.status === "running"}
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</Show>
|
|
106
|
+
<Show when={props.message.status === "running"}>
|
|
107
|
+
<div role="status">
|
|
108
|
+
<BasicTool
|
|
109
|
+
icon="archive"
|
|
110
|
+
trigger={{ title: i18n.t("ui.messagePart.compaction.running") }}
|
|
111
|
+
status="running"
|
|
112
|
+
locked
|
|
113
|
+
hideDetails
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
</Show>
|
|
117
|
+
<Show when={props.message.status !== "running"}>
|
|
118
|
+
<Separator label={label()} />
|
|
119
|
+
</Show>
|
|
120
|
+
<Show when={error()}>
|
|
121
|
+
<Card variant="error" class="error-card">
|
|
122
|
+
<LinkedText text={error()} />
|
|
123
|
+
</Card>
|
|
124
|
+
</Show>
|
|
125
|
+
</div>
|
|
126
|
+
</Show>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* An automatic compaction, drawn as one divider that reads Compacting, then Compacted. Its height never changes, and
|
|
132
|
+
* clicking it opens the summary.
|
|
133
|
+
*/
|
|
134
|
+
function QuietCompaction(props: { id: string; created: number; running: boolean; summary: string; usage: string }) {
|
|
135
|
+
const i18n = useI18n()
|
|
136
|
+
const [open, setOpen] = createSignal(false)
|
|
137
|
+
// A new one waits out the grace before showing Compacting; one that ends inside it, as a precomputed summary does,
|
|
138
|
+
// only fades in as Compacted. One already running or finished when the history loads shows without an entrance.
|
|
139
|
+
const initial = createCompactionEntranceState({ ageMs: Date.now() - props.created, running: props.running })
|
|
140
|
+
const [entrance, setEntrance] = createSignal(initial.state)
|
|
141
|
+
const enter = createMemo(() => selectCompactionEnter(entrance()))
|
|
142
|
+
let graceTimer: ReturnType<typeof setTimeout> | undefined
|
|
143
|
+
|
|
144
|
+
const runEntrance = (effect: CompactionEntranceEffect) => {
|
|
145
|
+
clearTimeout(graceTimer)
|
|
146
|
+
graceTimer = undefined
|
|
147
|
+
|
|
148
|
+
if (effect.type === "schedule-grace")
|
|
149
|
+
graceTimer = setTimeout(() => dispatchEntrance(GRACE_ELAPSED_EVENT), effect.delayMs)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const dispatchEntrance = (event: CompactionEntranceEvent) => {
|
|
153
|
+
const result = transitionCompactionEntrance(untrack(entrance), event)
|
|
154
|
+
setEntrance(result.state)
|
|
155
|
+
result.effects.forEach(runEntrance)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
initial.effects.forEach(runEntrance)
|
|
159
|
+
createEffect(() => dispatchEntrance({ type: "running.changed", running: props.running }))
|
|
160
|
+
onCleanup(() => dispatchEntrance(DISPOSED_COMPACTION_ENTRANCE_EVENT))
|
|
161
|
+
|
|
162
|
+
const expandable = () => !props.running && !!props.summary.trim()
|
|
163
|
+
|
|
164
|
+
const label = createMemo(() =>
|
|
165
|
+
splitEnding(i18n.t("ui.messagePart.compaction.running"), i18n.t("ui.messagePart.compaction.done")),
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div
|
|
170
|
+
data-component="session-compaction-message"
|
|
171
|
+
data-quiet=""
|
|
172
|
+
data-enter={enter()}
|
|
173
|
+
class="flex flex-col gap-[var(--timeline-gap-m)]"
|
|
174
|
+
>
|
|
175
|
+
<button
|
|
176
|
+
type="button"
|
|
177
|
+
data-slot="session-compaction-divider"
|
|
178
|
+
data-state={props.running ? "running" : "done"}
|
|
179
|
+
class="flex h-4 w-full items-center gap-3 text-v2-text-text-faint"
|
|
180
|
+
disabled={!expandable()}
|
|
181
|
+
aria-busy={props.running}
|
|
182
|
+
aria-expanded={expandable() ? open() : undefined}
|
|
183
|
+
aria-controls={expandable() && open() ? `${props.id}-summary` : undefined}
|
|
184
|
+
aria-label={props.running ? label().running : label().done}
|
|
185
|
+
onClick={() => setOpen((value) => !value)}
|
|
186
|
+
>
|
|
187
|
+
<span data-slot="session-compaction-line" data-side="start" class="h-px min-w-0 flex-1">
|
|
188
|
+
<span data-slot="session-compaction-light" />
|
|
189
|
+
</span>
|
|
190
|
+
<span
|
|
191
|
+
data-slot="session-compaction-label"
|
|
192
|
+
class="relative flex shrink-0 whitespace-pre text-[13px] font-[440] leading-text-compact tracking-[-0.04px]"
|
|
193
|
+
>
|
|
194
|
+
<span>{label().stem}</span>
|
|
195
|
+
<span data-slot="session-compaction-ending" class="grid justify-items-start">
|
|
196
|
+
<span data-slot="session-compaction-running">{label().ending.running}</span>
|
|
197
|
+
<span data-slot="session-compaction-done">{label().ending.done}</span>
|
|
198
|
+
</span>
|
|
199
|
+
<span data-slot="session-compaction-glint" aria-hidden="true">
|
|
200
|
+
<span data-slot="session-compaction-glint-stem">{label().stem}</span>
|
|
201
|
+
<span data-slot="session-compaction-glint-ending">{label().ending.running}</span>
|
|
202
|
+
</span>
|
|
203
|
+
</span>
|
|
204
|
+
<span data-slot="session-compaction-line" data-side="end" class="h-px min-w-0 flex-1">
|
|
205
|
+
<span data-slot="session-compaction-light" />
|
|
206
|
+
</span>
|
|
207
|
+
</button>
|
|
208
|
+
<Show when={expandable() && open()}>
|
|
209
|
+
<div id={`${props.id}-summary`} data-slot="session-compaction-summary">
|
|
210
|
+
<div data-component="text-part" data-timeline-part-id={props.id}>
|
|
211
|
+
<div data-slot="text-part-body">
|
|
212
|
+
<PacedMarkdown text={props.summary} cacheKey={props.id} streaming={false} />
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
<Show when={props.usage}>
|
|
216
|
+
<div class="mt-2 text-[13px] leading-text-compact text-v2-text-text-faint tabular-nums">{props.usage}</div>
|
|
217
|
+
</Show>
|
|
218
|
+
</div>
|
|
219
|
+
</Show>
|
|
220
|
+
</div>
|
|
221
|
+
)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Splits Compacting and Compacted at their shared stem, so only the ending changes when the compaction ends. It splits
|
|
226
|
+
* between whole characters as they are read, so a vowel sign stays with its consonant.
|
|
227
|
+
*/
|
|
228
|
+
function splitEnding(running: string, done: string) {
|
|
229
|
+
const graphemes = new Intl.Segmenter(undefined, { granularity: "grapheme" })
|
|
230
|
+
const chars = Array.from(graphemes.segment(running), (part) => part.segment)
|
|
231
|
+
const others = Array.from(graphemes.segment(done), (part) => part.segment)
|
|
232
|
+
const at = chars.findIndex((char, index) => char !== others[index])
|
|
233
|
+
const stem = chars.slice(0, at === -1 ? chars.length : at).join("")
|
|
234
|
+
|
|
235
|
+
return { running, done, stem, ending: { running: running.slice(stem.length), done: done.slice(stem.length) } }
|
|
236
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { SessionMessageAssistant } from "@zyro-sec/client/promise"
|
|
2
|
+
import { Effect, Option, Schema } from "effect"
|
|
3
|
+
import type { TurnErrorInfo } from "../timeline/turn-phase-machine"
|
|
4
|
+
|
|
5
|
+
const decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown))
|
|
6
|
+
|
|
7
|
+
const decodeString = Schema.decodeUnknownOption(Schema.String)
|
|
8
|
+
|
|
9
|
+
// A field of the wrong type decodes as absent, so one bad field does not discard its neighbours.
|
|
10
|
+
function lenient<S extends Schema.Top>(schema: S) {
|
|
11
|
+
return Schema.optionalKey(schema.pipe(Schema.catchDecoding(() => Effect.succeedNone)))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const decodeErrorEnvelope = Schema.decodeUnknownOption(
|
|
15
|
+
Schema.Struct({ error: Schema.optionalKey(Schema.Unknown), message: lenient(Schema.String) }),
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const decodeErrorDetails = Schema.decodeUnknownOption(
|
|
19
|
+
Schema.Struct({ type: lenient(Schema.String), message: lenient(Schema.String), code: lenient(Schema.String) }),
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
/** What a failed step or turn shows: its message, and when a usage limit or budget comes back. */
|
|
23
|
+
export function errorInfo(message: Parameters<typeof usageLimit>[0]): TurnErrorInfo {
|
|
24
|
+
return {
|
|
25
|
+
text: unwrapErrorMessage(message.error?.message ?? ""),
|
|
26
|
+
...usageLimit(message),
|
|
27
|
+
...budgetLimit(message),
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const MAX_RETRY_AFTER_MS = 45 * 86_400_000
|
|
32
|
+
|
|
33
|
+
function usageLimit(
|
|
34
|
+
message: Pick<SessionMessageAssistant, "error"> & { time: { created: number; completed?: number } },
|
|
35
|
+
) {
|
|
36
|
+
const type = message.error?.type
|
|
37
|
+
|
|
38
|
+
if (type !== "provider.free-limit" && type !== "provider.go-limit") return {}
|
|
39
|
+
|
|
40
|
+
const kind = type === "provider.go-limit" ? ("go-limit" as const) : ("free-limit" as const)
|
|
41
|
+
const delay = message.error?.retryAfterMs
|
|
42
|
+
const base = message.time.completed ?? message.time.created
|
|
43
|
+
|
|
44
|
+
if (
|
|
45
|
+
delay === undefined ||
|
|
46
|
+
!Number.isFinite(delay) ||
|
|
47
|
+
delay < 0 ||
|
|
48
|
+
delay > MAX_RETRY_AFTER_MS ||
|
|
49
|
+
!Number.isFinite(base) ||
|
|
50
|
+
Number.isNaN(new Date(base + delay).getTime())
|
|
51
|
+
)
|
|
52
|
+
return { kind }
|
|
53
|
+
|
|
54
|
+
return { kind, resetAt: base + delay }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// OpenCode Console says when the budget resets in its refusal's metadata, which every protocol's envelope names `resetsAt`.
|
|
58
|
+
function budgetLimit(message: Pick<SessionMessageAssistant, "error">) {
|
|
59
|
+
const type = message.error?.type
|
|
60
|
+
|
|
61
|
+
if (type !== "provider.budget-limit" && type !== "provider.model-budget-limit") return {}
|
|
62
|
+
const kind = type === "provider.budget-limit" ? ("budget-limit" as const) : ("model-budget-limit" as const)
|
|
63
|
+
const at = Date.parse(/"resetsAt"\s*:\s*"([^"]+)"/.exec(message.error?.response?.body ?? "")?.[1] ?? "")
|
|
64
|
+
|
|
65
|
+
if (Number.isNaN(at)) return { kind }
|
|
66
|
+
|
|
67
|
+
return { kind, resetAt: at }
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function unwrapErrorMessage(message: string) {
|
|
71
|
+
const text = message.replace(/^Error:\s*/, "").trim()
|
|
72
|
+
const parse = (value: string) => Option.getOrUndefined(decodeJson(value))
|
|
73
|
+
|
|
74
|
+
// A JSON string that itself holds JSON is unwrapped once.
|
|
75
|
+
const read = (value: string) => {
|
|
76
|
+
const first = parse(value)
|
|
77
|
+
|
|
78
|
+
return Option.match(decodeString(first), { onNone: () => first, onSome: (inner) => parse(inner.trim()) })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const whole = read(text)
|
|
82
|
+
const start = text.indexOf("{")
|
|
83
|
+
const end = text.lastIndexOf("}")
|
|
84
|
+
const json = whole === undefined && start !== -1 && end > start ? read(text.slice(start, end + 1)) : whole
|
|
85
|
+
const envelope = Option.getOrUndefined(decodeErrorEnvelope(json))
|
|
86
|
+
|
|
87
|
+
if (!envelope) return message
|
|
88
|
+
const error = Option.getOrUndefined(decodeErrorDetails(envelope.error))
|
|
89
|
+
|
|
90
|
+
if (error?.type && error.message) return `${error.type}: ${error.message}`
|
|
91
|
+
|
|
92
|
+
if (error?.message) return error.message
|
|
93
|
+
|
|
94
|
+
if (error?.type) return error.type
|
|
95
|
+
|
|
96
|
+
if (error?.code) return error.code
|
|
97
|
+
|
|
98
|
+
if (envelope.message) return envelope.message
|
|
99
|
+
|
|
100
|
+
return Option.getOrUndefined(decodeString(envelope.error)) || message
|
|
101
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Badge } from "@zyro-sec/ui/badge"
|
|
2
|
+
import { useI18n } from "@zyro-sec/ui/context/i18n"
|
|
3
|
+
import { For, Show, createMemo } from "solid-js"
|
|
4
|
+
import { BasicTool } from "../components/basic-tool"
|
|
5
|
+
import { useData } from "../context/data"
|
|
6
|
+
import { taskAgentName } from "../tools/tool-renderer"
|
|
7
|
+
import { factsOf, summarize } from "../timeline/facts"
|
|
8
|
+
import { verbKeys, type TimelineEvent } from "./events"
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A run of background shells. Opening its summary lists each command and links back to its call.
|
|
12
|
+
*/
|
|
13
|
+
export function TimelineEventRow(props: {
|
|
14
|
+
events: readonly TimelineEvent[]
|
|
15
|
+
open?: boolean
|
|
16
|
+
onOpenChange?: (open: boolean) => void
|
|
17
|
+
onRevealShell?: (shellID: string) => void
|
|
18
|
+
}) {
|
|
19
|
+
const i18n = useI18n()
|
|
20
|
+
|
|
21
|
+
const summary = createMemo(
|
|
22
|
+
() =>
|
|
23
|
+
summarize(
|
|
24
|
+
factsOf(
|
|
25
|
+
props.events.map(({ kind, verb, failed }, index) => ({
|
|
26
|
+
type: "outcome" as const,
|
|
27
|
+
id: String(index),
|
|
28
|
+
outcome: { kind, verb, failed },
|
|
29
|
+
})),
|
|
30
|
+
),
|
|
31
|
+
).background,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
const items = createMemo(() => props.events.filter((event) => event.title))
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Show when={summary().verbs.length > 0}>
|
|
38
|
+
<div data-component="timeline-event-row">
|
|
39
|
+
<BasicTool
|
|
40
|
+
icon="task"
|
|
41
|
+
compact
|
|
42
|
+
hasContent={items().length > 0}
|
|
43
|
+
open={props.open}
|
|
44
|
+
onOpenChange={props.onOpenChange}
|
|
45
|
+
trigger={
|
|
46
|
+
<div data-component="context-tool-group-trigger" data-timeline-event="">
|
|
47
|
+
<span data-slot="context-tool-group-title" data-activity="">
|
|
48
|
+
<For each={summary().verbs}>
|
|
49
|
+
{(bucket, index) => (
|
|
50
|
+
<>
|
|
51
|
+
<Show when={index() > 0}>
|
|
52
|
+
<span data-slot="context-tool-group-separator">·</span>
|
|
53
|
+
</Show>
|
|
54
|
+
<span data-slot="context-tool-group-verb">{i18n.t(verbKeys[bucket.verb])}</span>
|
|
55
|
+
<span data-slot="context-tool-group-detail">
|
|
56
|
+
{i18n.plural("ui.timeline.event.shells", bucket.count)}
|
|
57
|
+
</span>
|
|
58
|
+
</>
|
|
59
|
+
)}
|
|
60
|
+
</For>
|
|
61
|
+
{/* Where every one failed, the tag says so without counting them again. */}
|
|
62
|
+
<Show when={summary().failed}>
|
|
63
|
+
{(count) => (
|
|
64
|
+
<Badge data-slot="timeline-event-failed" variant="danger">
|
|
65
|
+
{count() === props.events.length
|
|
66
|
+
? i18n.t("ui.timeline.event.allFailed")
|
|
67
|
+
: i18n.t("ui.timeline.event.failed", { count: count() })}
|
|
68
|
+
</Badge>
|
|
69
|
+
)}
|
|
70
|
+
</Show>
|
|
71
|
+
</span>
|
|
72
|
+
</div>
|
|
73
|
+
}
|
|
74
|
+
>
|
|
75
|
+
<div data-component="timeline-event-list">
|
|
76
|
+
<For each={items()}>
|
|
77
|
+
{(event) => <TimelineEventItem event={event} onRevealShell={props.onRevealShell} />}
|
|
78
|
+
</For>
|
|
79
|
+
</div>
|
|
80
|
+
</BasicTool>
|
|
81
|
+
</div>
|
|
82
|
+
</Show>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
type SubagentState = "started" | "updated" | "completed" | "failed" | "stopped"
|
|
87
|
+
|
|
88
|
+
const statusKeys = {
|
|
89
|
+
started: verbKeys.started,
|
|
90
|
+
updated: "ui.timeline.subagent.updated",
|
|
91
|
+
completed: "ui.timeline.subagent.completed",
|
|
92
|
+
failed: "ui.toolErrorCard.failed",
|
|
93
|
+
stopped: verbKeys.stopped,
|
|
94
|
+
} as const
|
|
95
|
+
|
|
96
|
+
/** One subagent or shell an events row or an opened activity group lists: who did it and what it was. */
|
|
97
|
+
export function TimelineEventItem(props: { event: TimelineEvent; onRevealShell?: (shellID: string) => void }) {
|
|
98
|
+
const i18n = useI18n()
|
|
99
|
+
const data = useData()
|
|
100
|
+
|
|
101
|
+
const name = () => {
|
|
102
|
+
if (props.event.kind === "shell") return i18n.t("ui.tool.shell")
|
|
103
|
+
const agent = taskAgentName(props.event.agent, data.store.agent)
|
|
104
|
+
|
|
105
|
+
return agent ? i18n.t("ui.timeline.subagent.name", { name: agent }) : i18n.t("ui.tool.agent.default")
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const href = () => (props.event.sessionID ? data.sessionHref?.(props.event.sessionID) : undefined)
|
|
109
|
+
|
|
110
|
+
const open = () => {
|
|
111
|
+
const session = props.event.sessionID
|
|
112
|
+
|
|
113
|
+
if (session && data.navigateToSession) return data.navigateToSession(session)
|
|
114
|
+
|
|
115
|
+
if (props.event.shellID) props.onRevealShell?.(props.event.shellID)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const clickable = () => !!((props.event.sessionID && (data.navigateToSession || href())) || props.event.shellID)
|
|
119
|
+
|
|
120
|
+
const state = (): SubagentState => {
|
|
121
|
+
if (props.event.failed) return "failed"
|
|
122
|
+
|
|
123
|
+
if (props.event.verb === "ran" || props.event.verb === "finished") return "completed"
|
|
124
|
+
|
|
125
|
+
return props.event.verb
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<a
|
|
130
|
+
data-slot="timeline-event-item"
|
|
131
|
+
data-kind={props.event.kind}
|
|
132
|
+
href={href()}
|
|
133
|
+
role={clickable() && !href() ? (props.event.kind === "subagent" ? "link" : "button") : undefined}
|
|
134
|
+
tabIndex={clickable() ? 0 : undefined}
|
|
135
|
+
aria-disabled={clickable() ? undefined : "true"}
|
|
136
|
+
onClick={(event) => {
|
|
137
|
+
if (event.button !== 0 || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return
|
|
138
|
+
|
|
139
|
+
if (href() && !data.navigateToSession) return
|
|
140
|
+
|
|
141
|
+
if (!clickable()) return
|
|
142
|
+
event.preventDefault()
|
|
143
|
+
open()
|
|
144
|
+
}}
|
|
145
|
+
onKeyDown={(event) => {
|
|
146
|
+
if (!clickable() || href() || (event.key !== "Enter" && event.key !== " ")) return
|
|
147
|
+
event.preventDefault()
|
|
148
|
+
open()
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{/* A subagent leads with its status. */}
|
|
152
|
+
<Show when={props.event.kind === "subagent"}>
|
|
153
|
+
<span data-slot="timeline-event-item-status" data-state={state()}>
|
|
154
|
+
{i18n.t(statusKeys[state()])}
|
|
155
|
+
</span>
|
|
156
|
+
</Show>
|
|
157
|
+
<span data-slot="timeline-event-item-name">{name()}</span>
|
|
158
|
+
<Show when={props.event.title}>
|
|
159
|
+
<bdi dir="auto" data-slot="timeline-event-item-title">
|
|
160
|
+
{props.event.title}
|
|
161
|
+
</bdi>
|
|
162
|
+
</Show>
|
|
163
|
+
<Show when={props.event.failed && props.event.kind === "shell"}>
|
|
164
|
+
<Badge variant="danger">{i18n.t("ui.toolErrorCard.failed")}</Badge>
|
|
165
|
+
</Show>
|
|
166
|
+
</a>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { SessionMessageAssistantTool, SessionMessageInfo } from "@zyro-sec/client/promise"
|
|
2
|
+
import { Option, Schema } from "effect"
|
|
3
|
+
import { currentToolInput, currentToolMetadata } from "../message/current-tool-state"
|
|
4
|
+
import { toolRule } from "./rules"
|
|
5
|
+
|
|
6
|
+
export type TimelineEventKind = "subagent" | "shell"
|
|
7
|
+
|
|
8
|
+
export type TimelineEventVerb = "started" | "ran" | "finished" | "stopped"
|
|
9
|
+
|
|
10
|
+
export type TimelineEvent = {
|
|
11
|
+
verb: TimelineEventVerb | "updated"
|
|
12
|
+
kind: TimelineEventKind
|
|
13
|
+
failed: boolean
|
|
14
|
+
/** What opening the row lists: a subagent's task or a shell's command, and where each leads. */
|
|
15
|
+
title?: string
|
|
16
|
+
agent?: string
|
|
17
|
+
sessionID?: string
|
|
18
|
+
shellID?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Status labels shared by task rows and shell summaries. */
|
|
22
|
+
export const verbKeys = {
|
|
23
|
+
started: "ui.timeline.event.started",
|
|
24
|
+
ran: "ui.timeline.activity.ran",
|
|
25
|
+
finished: "ui.timeline.event.finished",
|
|
26
|
+
stopped: "ui.timeline.event.stopped",
|
|
27
|
+
} as const
|
|
28
|
+
|
|
29
|
+
/** How a group's label counts work that runs on, beside its other calls: "1 command, started 1 shell". */
|
|
30
|
+
export const launchKeys = {
|
|
31
|
+
started: "ui.timeline.activity.startedShells",
|
|
32
|
+
ran: "ui.timeline.activity.commands",
|
|
33
|
+
finished: "ui.timeline.activity.finishedShells",
|
|
34
|
+
stopped: "ui.timeline.activity.stoppedShells",
|
|
35
|
+
} as const
|
|
36
|
+
|
|
37
|
+
// Text a call or notice carries, where it is not empty.
|
|
38
|
+
const decodeText = Schema.decodeUnknownOption(Schema.NonEmptyString)
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* What a call says happened. A call still being written has nothing to count yet. Older sessions marked a
|
|
42
|
+
* foreground subagent's result as completed; current subagent calls only launch the work.
|
|
43
|
+
*/
|
|
44
|
+
export function toolEvent(tool: SessionMessageAssistantTool): TimelineEvent | undefined {
|
|
45
|
+
const kind = toolRule(tool).name === "shell" ? "shell" : "subagent"
|
|
46
|
+
const state = tool.state
|
|
47
|
+
|
|
48
|
+
if (state.status === "streaming") return undefined
|
|
49
|
+
const input = currentToolInput(tool)
|
|
50
|
+
const metadata = currentToolMetadata(tool)
|
|
51
|
+
const followUp = kind === "subagent" ? Option.getOrUndefined(decodeText(input.sessionID)) : undefined
|
|
52
|
+
|
|
53
|
+
const item = {
|
|
54
|
+
kind,
|
|
55
|
+
title: Option.getOrUndefined(decodeText(kind === "shell" ? input.command : input.description)),
|
|
56
|
+
agent: kind === "subagent" ? Option.getOrUndefined(decodeText(input.agent ?? input.subagent_type)) : undefined,
|
|
57
|
+
sessionID: kind === "subagent" ? (Option.getOrUndefined(decodeText(metadata.sessionID)) ?? followUp) : undefined,
|
|
58
|
+
shellID: kind === "shell" ? Option.getOrUndefined(decodeText(metadata.shellID)) : undefined,
|
|
59
|
+
} as const
|
|
60
|
+
|
|
61
|
+
if (state.status === "running") return { ...item, verb: followUp ? "updated" : "started", failed: false }
|
|
62
|
+
|
|
63
|
+
const background =
|
|
64
|
+
kind === "subagent" ? metadata.status !== "completed" : metadata.status === "running" || input.background === true
|
|
65
|
+
|
|
66
|
+
if (state.status === "error") {
|
|
67
|
+
if (state.error.type === "aborted") return { ...item, verb: "stopped", failed: false }
|
|
68
|
+
|
|
69
|
+
return { ...item, verb: background ? "started" : "ran", failed: true }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (followUp) return { ...item, verb: "updated", failed: false }
|
|
73
|
+
|
|
74
|
+
return { ...item, verb: background ? "started" : "ran", failed: false }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The outcome a background subagent or shell reports when it finishes. */
|
|
78
|
+
export function noticeEvent(message: SessionMessageInfo): TimelineEvent | undefined {
|
|
79
|
+
if (message.type !== "synthetic") return undefined
|
|
80
|
+
const source = message.metadata?.source
|
|
81
|
+
|
|
82
|
+
if (source !== "subagent" && source !== "shell") return undefined
|
|
83
|
+
const state = message.metadata?.state
|
|
84
|
+
|
|
85
|
+
const item = {
|
|
86
|
+
kind: source,
|
|
87
|
+
title: Option.getOrUndefined(decodeText(message.description)),
|
|
88
|
+
agent: Option.getOrUndefined(decodeText(message.metadata?.agent)),
|
|
89
|
+
sessionID: Option.getOrUndefined(decodeText(message.metadata?.childID)),
|
|
90
|
+
shellID: Option.getOrUndefined(decodeText(message.metadata?.shellID)),
|
|
91
|
+
} as const
|
|
92
|
+
|
|
93
|
+
if (state === "cancelled") return { ...item, verb: "stopped", failed: false }
|
|
94
|
+
|
|
95
|
+
return { ...item, verb: "finished", failed: state === "error" }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Which subagent or shell an event is about, where it says. */
|
|
99
|
+
export function workKey(event: TimelineEvent) {
|
|
100
|
+
const id = event.kind === "shell" ? event.shellID : event.sessionID
|
|
101
|
+
|
|
102
|
+
return id ? `${event.kind}:${id}` : undefined
|
|
103
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The New timeline, as the app sees it: its rows, how they draw, and the status line below a working turn. */
|
|
2
|
+
export { createNextTimelineProjection } from "./projection"
|
|
3
|
+
|
|
4
|
+
export { createNextTimelineRowRenderer } from "./row"
|
|
5
|
+
|
|
6
|
+
export { laneGap } from "./spacing"
|
|
7
|
+
|
|
8
|
+
export { timelineStatus } from "./status"
|
|
9
|
+
|
|
10
|
+
export { StatusLane } from "./status-line"
|