@zyro-sec/session-ui 0.0.0-stage → 1.0.4
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,619 @@
|
|
|
1
|
+
import type { SessionMessageAssistantTool } from "@zyro-sec/client/promise"
|
|
2
|
+
import { AnimatedNumber } from "@zyro-sec/ui/animated-number"
|
|
3
|
+
import { Badge } from "@zyro-sec/ui/badge"
|
|
4
|
+
import { type UiI18n, useI18n } from "@zyro-sec/ui/context/i18n"
|
|
5
|
+
import { TextShimmer } from "@zyro-sec/ui/text-shimmer"
|
|
6
|
+
import { createMemo, For, Index, Match, Show, Switch } from "solid-js"
|
|
7
|
+
import { BasicTool } from "../../components/basic-tool"
|
|
8
|
+
import {
|
|
9
|
+
currentToolError,
|
|
10
|
+
currentToolGroupedRead,
|
|
11
|
+
currentToolInput,
|
|
12
|
+
currentToolMetadata,
|
|
13
|
+
currentToolOutput,
|
|
14
|
+
} from "../../message/current-tool-state"
|
|
15
|
+
import { AssistantReasoningContent } from "../../message/message-content"
|
|
16
|
+
import {
|
|
17
|
+
CurrentReadToolGroup,
|
|
18
|
+
currentSkillName,
|
|
19
|
+
displayFolder,
|
|
20
|
+
scrollParent,
|
|
21
|
+
toolInput,
|
|
22
|
+
toolMetadata,
|
|
23
|
+
type ContextGroupPart,
|
|
24
|
+
} from "../../tools/tool-renderer"
|
|
25
|
+
import { TimelineEventRow } from "../event-row"
|
|
26
|
+
import { toolEvent, workKey, type TimelineEvent } from "../events"
|
|
27
|
+
import { toolRule } from "../rules"
|
|
28
|
+
import { sameFileFact, toolStopped } from "../../timeline/facts"
|
|
29
|
+
import { activityLabel, activityText, usedLabel } from "./activity-label"
|
|
30
|
+
import { FileGroup } from "./file-group"
|
|
31
|
+
import { ThoughtRow } from "./thought"
|
|
32
|
+
import { ToolDisplay } from "./tool-display"
|
|
33
|
+
|
|
34
|
+
/** A part of an activity group: a call, a thought, a notice, or background work reporting back. */
|
|
35
|
+
export type ActivityGroupPart = ContextGroupPart | { type: "event"; id: string; event: TimelineEvent }
|
|
36
|
+
|
|
37
|
+
// Subagents and background work listed one after another in an opened group, as one nested events row.
|
|
38
|
+
type WorkRun = { type: "work"; id: string; events: TimelineEvent[] }
|
|
39
|
+
|
|
40
|
+
type ThoughtPart = Extract<ActivityGroupPart, { type: "reasoning" }>
|
|
41
|
+
|
|
42
|
+
// Thoughts one after another in an opened group, as one thought.
|
|
43
|
+
type ThoughtRun = { type: "thoughts"; id: string; parts: ThoughtPart[] }
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A stretch of the agent's work folded into one row, named by what it did: "Explored 3 files · 2 commands". It only
|
|
47
|
+
* records what happened; the status line below the turn says what is live. A stretch of thoughts alone is those
|
|
48
|
+
* thoughts, without a group around them.
|
|
49
|
+
*/
|
|
50
|
+
export function ContextGroup(props: {
|
|
51
|
+
parts: ActivityGroupPart[]
|
|
52
|
+
open: boolean
|
|
53
|
+
onOpenChange: (open: boolean) => void
|
|
54
|
+
onSizeChange?: () => void
|
|
55
|
+
reasoningDefaultOpen?: boolean
|
|
56
|
+
reasoningOpen?: (id: string) => boolean | undefined
|
|
57
|
+
onReasoningOpenChange?: (id: string, open: boolean) => void
|
|
58
|
+
toolDefaultOpen?: (tool: SessionMessageAssistantTool) => boolean | undefined
|
|
59
|
+
toolOpen?: (id: string) => boolean | undefined
|
|
60
|
+
onToolOpenChange?: (id: string, open: boolean) => void
|
|
61
|
+
fileOpen?: (path: string) => boolean | undefined
|
|
62
|
+
onFileOpenChange?: (path: string, open: boolean) => void
|
|
63
|
+
patchGroupKey?: (tools: SessionMessageAssistantTool[]) => string
|
|
64
|
+
onRevealShell?: (shellID: string) => void
|
|
65
|
+
}) {
|
|
66
|
+
const i18n = useI18n()
|
|
67
|
+
const reasoning = createMemo(() => props.parts.flatMap((part) => (part.type === "reasoning" ? [part] : [])))
|
|
68
|
+
const thoughtsOnly = createMemo(() => reasoning().length > 0 && reasoning().length === props.parts.length)
|
|
69
|
+
const events = createMemo(() => [...workEvents(props.parts).values()])
|
|
70
|
+
|
|
71
|
+
const workOnly = createMemo(() => events().length > 0 && props.parts.every((part) => part.type === "event"))
|
|
72
|
+
|
|
73
|
+
const activity = createMemo(() => activityLabel(props.parts, i18n))
|
|
74
|
+
|
|
75
|
+
const label = createMemo(() => activityText(activity()) ?? usedLabel(props.parts, i18n))
|
|
76
|
+
|
|
77
|
+
const items = createMemo(() =>
|
|
78
|
+
(props.open ? props.parts : []).reduce<
|
|
79
|
+
(
|
|
80
|
+
| SessionMessageAssistantTool[]
|
|
81
|
+
| Exclude<ActivityGroupPart, SessionMessageAssistantTool | { type: "event" } | { type: "reasoning" }>
|
|
82
|
+
| WorkRun
|
|
83
|
+
| ThoughtRun
|
|
84
|
+
)[]
|
|
85
|
+
>((groups, tool) => {
|
|
86
|
+
const previous = groups.at(-1)
|
|
87
|
+
|
|
88
|
+
if (tool.type === "event") {
|
|
89
|
+
const event = tool.event
|
|
90
|
+
const run = previous && !Array.isArray(previous) && previous.type === "work" ? previous : undefined
|
|
91
|
+
|
|
92
|
+
if (run) {
|
|
93
|
+
run.events.push(event)
|
|
94
|
+
|
|
95
|
+
return groups
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
groups.push({ type: "work", id: tool.id, events: [event] })
|
|
99
|
+
|
|
100
|
+
return groups
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Thoughts one after another open as one.
|
|
104
|
+
if (tool.type === "reasoning") {
|
|
105
|
+
if (previous && !Array.isArray(previous) && previous.type === "thoughts") {
|
|
106
|
+
previous.parts.push(tool)
|
|
107
|
+
|
|
108
|
+
return groups
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
groups.push({ type: "thoughts", id: tool.id, parts: [tool] })
|
|
112
|
+
|
|
113
|
+
return groups
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (tool.type !== "tool") {
|
|
117
|
+
groups.push(tool)
|
|
118
|
+
|
|
119
|
+
return groups
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (Array.isArray(previous) && previous[0] && joins(previous[0], tool)) {
|
|
123
|
+
previous.push(tool)
|
|
124
|
+
|
|
125
|
+
return groups
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
groups.push([tool])
|
|
129
|
+
|
|
130
|
+
return groups
|
|
131
|
+
}, []),
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
const patchKeys = createMemo(() => {
|
|
135
|
+
const keys = new Map<SessionMessageAssistantTool, string>()
|
|
136
|
+
items().forEach((item) => {
|
|
137
|
+
if (!Array.isArray(item) || !item[0] || !changesFiles(item[0])) return
|
|
138
|
+
const key = props.patchGroupKey?.(item) ?? item[0].id
|
|
139
|
+
item.forEach((tool) => keys.set(tool, key))
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
return keys
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
let root: HTMLDivElement | undefined
|
|
146
|
+
|
|
147
|
+
const change = (open: boolean) => {
|
|
148
|
+
// Collapsing from the stuck header would leave the viewport far below the group, so keep the header in place.
|
|
149
|
+
// Scroll before collapsing because the shorter content would clamp the scroll position first.
|
|
150
|
+
const trigger = root?.querySelector(':scope > [data-component="collapsible"] > [data-slot="collapsible-trigger"]')
|
|
151
|
+
|
|
152
|
+
// The header rests its top margin away from the group's top, above it here. Anything past that is how far it is stuck.
|
|
153
|
+
const stuck =
|
|
154
|
+
!open && root && trigger
|
|
155
|
+
? trigger.getBoundingClientRect().top -
|
|
156
|
+
root.getBoundingClientRect().top -
|
|
157
|
+
parseFloat(getComputedStyle(trigger).marginTop)
|
|
158
|
+
: 0
|
|
159
|
+
|
|
160
|
+
if (stuck > 0 && root) scrollParent(root)?.scrollBy({ top: -stuck, behavior: "instant" })
|
|
161
|
+
props.onOpenChange(open)
|
|
162
|
+
props.onSizeChange?.()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<Show
|
|
167
|
+
when={!thoughtsOnly()}
|
|
168
|
+
fallback={
|
|
169
|
+
<ThoughtRow
|
|
170
|
+
parts={reasoning()}
|
|
171
|
+
streaming={reasoning().some((part) => part.streaming)}
|
|
172
|
+
defaultOpen={props.reasoningDefaultOpen}
|
|
173
|
+
open={props.reasoningOpen?.(reasoning()[0]!.id)}
|
|
174
|
+
onOpenChange={(open) => props.onReasoningOpenChange?.(reasoning()[0]!.id, open)}
|
|
175
|
+
onContentRendered={props.onSizeChange}
|
|
176
|
+
/>
|
|
177
|
+
}
|
|
178
|
+
>
|
|
179
|
+
<Show
|
|
180
|
+
when={!workOnly()}
|
|
181
|
+
fallback={
|
|
182
|
+
<div data-timeline-part-ids={props.parts.map((part) => part.id).join(",")}>
|
|
183
|
+
<TimelineEventRow
|
|
184
|
+
events={events()}
|
|
185
|
+
open={props.open}
|
|
186
|
+
onOpenChange={change}
|
|
187
|
+
onRevealShell={props.onRevealShell}
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
190
|
+
}
|
|
191
|
+
>
|
|
192
|
+
<div
|
|
193
|
+
ref={root}
|
|
194
|
+
data-component="collapsed-tool-group"
|
|
195
|
+
data-timeline-part-ids={props.parts.map((part) => part.id).join(",")}
|
|
196
|
+
>
|
|
197
|
+
<BasicTool
|
|
198
|
+
icon="glasses"
|
|
199
|
+
status="completed"
|
|
200
|
+
compact
|
|
201
|
+
hasContent
|
|
202
|
+
allowOpenWhilePending
|
|
203
|
+
open={props.open}
|
|
204
|
+
onOpenChange={change}
|
|
205
|
+
trigger={
|
|
206
|
+
<div data-component="context-tool-group-trigger" aria-label={label().text}>
|
|
207
|
+
<Show when={activity()} fallback={<UsedTitle label={usedLabel(props.parts, i18n)} />}>
|
|
208
|
+
{(value) => (
|
|
209
|
+
<span data-slot="context-tool-group-title" data-activity="">
|
|
210
|
+
<span data-slot="context-tool-group-verb">{value().verb}</span>
|
|
211
|
+
<Show when={value().main}>
|
|
212
|
+
<span data-slot="context-tool-group-detail">{value().main}</span>
|
|
213
|
+
</Show>
|
|
214
|
+
<Show when={value().others.length > 0}>
|
|
215
|
+
<span data-slot="context-tool-group-separator" aria-hidden="true">
|
|
216
|
+
·
|
|
217
|
+
</span>
|
|
218
|
+
<span data-slot="context-tool-group-detail">{value().others.join(", ")}</span>
|
|
219
|
+
</Show>
|
|
220
|
+
</span>
|
|
221
|
+
)}
|
|
222
|
+
</Show>
|
|
223
|
+
</div>
|
|
224
|
+
}
|
|
225
|
+
>
|
|
226
|
+
<div data-component="context-tool-group-list">
|
|
227
|
+
<Index each={items()}>
|
|
228
|
+
{(item) => {
|
|
229
|
+
const group = createMemo(() => {
|
|
230
|
+
const value = item()
|
|
231
|
+
|
|
232
|
+
return Array.isArray(value) ? value : undefined
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
const reasoning = createMemo(() => {
|
|
236
|
+
const value = item()
|
|
237
|
+
|
|
238
|
+
return !Array.isArray(value) && value.type === "thoughts" ? value : undefined
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
// A change keeps its card while progress reports rebuild the list around it.
|
|
242
|
+
const file = createMemo(
|
|
243
|
+
() => {
|
|
244
|
+
const value = item()
|
|
245
|
+
|
|
246
|
+
return !Array.isArray(value) && value.type === "file" ? value : undefined
|
|
247
|
+
},
|
|
248
|
+
undefined,
|
|
249
|
+
{
|
|
250
|
+
equals: (previous, next) =>
|
|
251
|
+
previous === next || (!!previous && !!next && sameFileFact(previous.file, next.file)),
|
|
252
|
+
},
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
const callback = createMemo(() => {
|
|
256
|
+
const value = item()
|
|
257
|
+
|
|
258
|
+
return !Array.isArray(value) &&
|
|
259
|
+
(value.type === "notice" || value.type === "shell" || value.type === "text")
|
|
260
|
+
? value
|
|
261
|
+
: undefined
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
const work = createMemo(() => {
|
|
265
|
+
const value = item()
|
|
266
|
+
|
|
267
|
+
return !Array.isArray(value) && value.type === "work" ? value : undefined
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
return (
|
|
271
|
+
<Show
|
|
272
|
+
when={group()}
|
|
273
|
+
fallback={
|
|
274
|
+
<Show
|
|
275
|
+
when={reasoning()}
|
|
276
|
+
fallback={
|
|
277
|
+
<Show
|
|
278
|
+
when={work()}
|
|
279
|
+
fallback={
|
|
280
|
+
<Show
|
|
281
|
+
when={file()}
|
|
282
|
+
keyed
|
|
283
|
+
fallback={
|
|
284
|
+
<Show when={callback()}>
|
|
285
|
+
{(part) => <div data-slot="context-tool-group-item">{part().render()}</div>}
|
|
286
|
+
</Show>
|
|
287
|
+
}
|
|
288
|
+
>
|
|
289
|
+
{(part) => <div data-slot="context-tool-group-item">{part.render()}</div>}
|
|
290
|
+
</Show>
|
|
291
|
+
}
|
|
292
|
+
>
|
|
293
|
+
{(work) => (
|
|
294
|
+
<div data-slot="context-tool-group-item">
|
|
295
|
+
<TimelineEventRow
|
|
296
|
+
events={work().events}
|
|
297
|
+
open={props.toolOpen?.(`events:${work().id}`) === true}
|
|
298
|
+
onOpenChange={(open) => {
|
|
299
|
+
props.onToolOpenChange?.(`events:${work().id}`, open)
|
|
300
|
+
props.onSizeChange?.()
|
|
301
|
+
}}
|
|
302
|
+
onRevealShell={props.onRevealShell}
|
|
303
|
+
/>
|
|
304
|
+
</div>
|
|
305
|
+
)}
|
|
306
|
+
</Show>
|
|
307
|
+
}
|
|
308
|
+
>
|
|
309
|
+
{(part) => (
|
|
310
|
+
<div data-slot="context-tool-group-item">
|
|
311
|
+
<AssistantReasoningContent
|
|
312
|
+
id={part().id}
|
|
313
|
+
content={part().parts[0]!}
|
|
314
|
+
more={part()
|
|
315
|
+
.parts.slice(1)
|
|
316
|
+
.map((item) => ({ id: item.id, content: item }))}
|
|
317
|
+
streaming={part().parts.some((item) => item.streaming)}
|
|
318
|
+
defaultOpen={props.reasoningDefaultOpen}
|
|
319
|
+
open={props.reasoningOpen?.(part().id)}
|
|
320
|
+
onOpenChange={(open) => props.onReasoningOpenChange?.(part().id, open)}
|
|
321
|
+
onContentRendered={props.onSizeChange}
|
|
322
|
+
/>
|
|
323
|
+
</div>
|
|
324
|
+
)}
|
|
325
|
+
</Show>
|
|
326
|
+
}
|
|
327
|
+
>
|
|
328
|
+
{(group) => (
|
|
329
|
+
<div data-slot="context-tool-group-item">
|
|
330
|
+
<GroupItem
|
|
331
|
+
tools={group()}
|
|
332
|
+
patchKey={patchKeys().get(group()[0]!)}
|
|
333
|
+
onSizeChange={props.onSizeChange}
|
|
334
|
+
toolDefaultOpen={props.toolDefaultOpen}
|
|
335
|
+
toolOpen={props.toolOpen}
|
|
336
|
+
onToolOpenChange={props.onToolOpenChange}
|
|
337
|
+
fileOpen={props.fileOpen}
|
|
338
|
+
onFileOpenChange={props.onFileOpenChange}
|
|
339
|
+
/>
|
|
340
|
+
</div>
|
|
341
|
+
)}
|
|
342
|
+
</Show>
|
|
343
|
+
)
|
|
344
|
+
}}
|
|
345
|
+
</Index>
|
|
346
|
+
</div>
|
|
347
|
+
</BasicTool>
|
|
348
|
+
</div>
|
|
349
|
+
</Show>
|
|
350
|
+
</Show>
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// One item in an opened group: files read together, a search, skills loaded together, files changed together, or a call.
|
|
355
|
+
function GroupItem(props: {
|
|
356
|
+
tools: SessionMessageAssistantTool[]
|
|
357
|
+
patchKey?: string
|
|
358
|
+
onSizeChange?: () => void
|
|
359
|
+
toolDefaultOpen?: (tool: SessionMessageAssistantTool) => boolean | undefined
|
|
360
|
+
toolOpen?: (id: string) => boolean | undefined
|
|
361
|
+
onToolOpenChange?: (id: string, open: boolean) => void
|
|
362
|
+
fileOpen?: (path: string) => boolean | undefined
|
|
363
|
+
onFileOpenChange?: (path: string, open: boolean) => void
|
|
364
|
+
}) {
|
|
365
|
+
const tool = createMemo(() => props.tools[0]!)
|
|
366
|
+
const name = createMemo(() => toolRule(tool()).name)
|
|
367
|
+
const defaultOpen = createMemo(() => props.toolDefaultOpen?.(tool()))
|
|
368
|
+
|
|
369
|
+
return (
|
|
370
|
+
<Switch
|
|
371
|
+
fallback={
|
|
372
|
+
<ToolDisplay
|
|
373
|
+
id={tool().id}
|
|
374
|
+
tool={name()}
|
|
375
|
+
input={currentToolInput(tool())}
|
|
376
|
+
metadata={currentToolMetadata(tool())}
|
|
377
|
+
output={currentToolOutput(tool())}
|
|
378
|
+
error={currentToolError(tool())}
|
|
379
|
+
stopped={toolStopped(tool())}
|
|
380
|
+
status={tool().state.status}
|
|
381
|
+
defaultOpen={defaultOpen() ?? false}
|
|
382
|
+
open={props.toolOpen?.(tool().id) ?? defaultOpen()}
|
|
383
|
+
onOpenChange={(open) => props.onToolOpenChange?.(tool().id, open)}
|
|
384
|
+
deferContent
|
|
385
|
+
virtualizeDiff={false}
|
|
386
|
+
onContentRendered={props.onSizeChange}
|
|
387
|
+
/>
|
|
388
|
+
}
|
|
389
|
+
>
|
|
390
|
+
<Match when={currentToolGroupedRead(tool())}>
|
|
391
|
+
<CurrentReadToolGroup
|
|
392
|
+
tools={props.tools}
|
|
393
|
+
names={2}
|
|
394
|
+
open={props.toolOpen?.(tool().id)}
|
|
395
|
+
onOpenChange={(open) => props.onToolOpenChange?.(tool().id, open)}
|
|
396
|
+
onSizeChange={props.onSizeChange}
|
|
397
|
+
/>
|
|
398
|
+
</Match>
|
|
399
|
+
<Match when={tool().state.status !== "error" && ["glob", "grep", "list"].includes(name())}>
|
|
400
|
+
<SearchItem tool={tool()} />
|
|
401
|
+
</Match>
|
|
402
|
+
<Match when={props.tools.length > 1 && props.tools.every(loadsSkill)}>
|
|
403
|
+
<SkillsItem tools={props.tools} />
|
|
404
|
+
</Match>
|
|
405
|
+
<Match when={changesFiles(tool())}>
|
|
406
|
+
<FileGroup
|
|
407
|
+
tools={props.tools}
|
|
408
|
+
fileOpen={props.fileOpen && ((path) => props.fileOpen?.(`${props.patchKey}:${path}`))}
|
|
409
|
+
onFileOpenChange={
|
|
410
|
+
props.onFileOpenChange && ((path, open) => props.onFileOpenChange?.(`${props.patchKey}:${path}`, open))
|
|
411
|
+
}
|
|
412
|
+
onSizeChange={props.onSizeChange}
|
|
413
|
+
/>
|
|
414
|
+
</Match>
|
|
415
|
+
</Switch>
|
|
416
|
+
)
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// A search in an opened group: what was searched, and how many matches it found.
|
|
420
|
+
function SearchItem(props: { tool: SessionMessageAssistantTool }) {
|
|
421
|
+
const i18n = useI18n()
|
|
422
|
+
const trigger = createMemo(() => searchTrigger(props.tool, i18n))
|
|
423
|
+
|
|
424
|
+
return (
|
|
425
|
+
<div data-component="tool-trigger">
|
|
426
|
+
<div data-slot="basic-tool-tool-trigger-content">
|
|
427
|
+
<div data-slot="basic-tool-tool-info">
|
|
428
|
+
<div data-slot="basic-tool-tool-info-structured">
|
|
429
|
+
<div data-slot="basic-tool-tool-info-main">
|
|
430
|
+
<span data-slot="basic-tool-tool-title">
|
|
431
|
+
<TextShimmer
|
|
432
|
+
text={trigger().title}
|
|
433
|
+
active={props.tool.state.status === "streaming" || props.tool.state.status === "running"}
|
|
434
|
+
/>
|
|
435
|
+
</span>
|
|
436
|
+
<Show when={trigger().subtitle}>
|
|
437
|
+
{(subtitle) => <span data-slot="basic-tool-tool-subtitle">{subtitle()}</span>}
|
|
438
|
+
</Show>
|
|
439
|
+
<For each={trigger().args}>{(arg) => <span data-slot="basic-tool-tool-arg">{arg}</span>}</For>
|
|
440
|
+
</div>
|
|
441
|
+
<Show when={trigger().count}>
|
|
442
|
+
{(count) => (
|
|
443
|
+
<Badge data-slot="context-tool-group-match-count">
|
|
444
|
+
{i18n.plural("ui.messagePart.context.matchCount", count())}
|
|
445
|
+
</Badge>
|
|
446
|
+
)}
|
|
447
|
+
</Show>
|
|
448
|
+
</div>
|
|
449
|
+
</div>
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
function SkillsItem(props: { tools: SessionMessageAssistantTool[] }) {
|
|
456
|
+
const i18n = useI18n()
|
|
457
|
+
|
|
458
|
+
const skills = createMemo(() =>
|
|
459
|
+
props.tools.flatMap((tool) => {
|
|
460
|
+
const name = currentSkillName(tool)
|
|
461
|
+
|
|
462
|
+
return name ? [name] : []
|
|
463
|
+
}),
|
|
464
|
+
)
|
|
465
|
+
|
|
466
|
+
const marker = "__OPENCODE_LOADED_SKILL__"
|
|
467
|
+
const loaded = createMemo(() => i18n.plural("ui.tool.loadedSkills", skills().length, { name: marker }))
|
|
468
|
+
|
|
469
|
+
return (
|
|
470
|
+
<div
|
|
471
|
+
data-component="tool-loaded-item"
|
|
472
|
+
data-timeline-part-ids={props.tools.map((item) => item.id).join(",")}
|
|
473
|
+
aria-label={i18n.plural("ui.tool.loadedSkills", skills().length, { name: skills().join(", ") })}
|
|
474
|
+
>
|
|
475
|
+
<span data-slot="tool-loaded-label" aria-hidden="true">
|
|
476
|
+
{loaded().split(marker)[0]?.trim()}
|
|
477
|
+
</span>
|
|
478
|
+
<span data-slot="tool-loaded-value" aria-hidden="true">
|
|
479
|
+
<For each={skills()}>
|
|
480
|
+
{(name, index) => (
|
|
481
|
+
<>
|
|
482
|
+
<Show when={index() > 0}>, </Show>
|
|
483
|
+
<TextShimmer
|
|
484
|
+
as="span"
|
|
485
|
+
text={name}
|
|
486
|
+
active={["streaming", "running"].includes(props.tools[index()]!.state.status)}
|
|
487
|
+
/>
|
|
488
|
+
</>
|
|
489
|
+
)}
|
|
490
|
+
</For>
|
|
491
|
+
</span>
|
|
492
|
+
<Show when={loaded().split(marker)[1]?.trim()}>
|
|
493
|
+
{(suffix) => (
|
|
494
|
+
<span data-slot="tool-loaded-kind" aria-hidden="true">
|
|
495
|
+
{suffix()}
|
|
496
|
+
</span>
|
|
497
|
+
)}
|
|
498
|
+
</Show>
|
|
499
|
+
</div>
|
|
500
|
+
)
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// A group with no calls says how many thoughts it holds, "Used 2 Thoughts", or else that it holds updates.
|
|
504
|
+
function UsedTitle(props: { label: ReturnType<typeof usedLabel> }) {
|
|
505
|
+
return (
|
|
506
|
+
<span data-slot="context-tool-group-title">
|
|
507
|
+
<Show when={props.label.before || props.label.count || props.label.between}>
|
|
508
|
+
<span data-slot="context-tool-group-usage">
|
|
509
|
+
<Show when={props.label.before}>
|
|
510
|
+
{(before) => <span data-slot="context-tool-group-prefix">{before()}</span>}
|
|
511
|
+
</Show>
|
|
512
|
+
<Show when={props.label.count}>
|
|
513
|
+
{(count) => (
|
|
514
|
+
<span data-slot="context-tool-group-count">
|
|
515
|
+
<AnimatedNumber value={count()} />
|
|
516
|
+
</span>
|
|
517
|
+
)}
|
|
518
|
+
</Show>
|
|
519
|
+
<Show when={props.label.between}>
|
|
520
|
+
{(between) => <span data-slot="context-tool-group-prefix">{between()}</span>}
|
|
521
|
+
</Show>
|
|
522
|
+
</span>
|
|
523
|
+
</Show>
|
|
524
|
+
<Show when={props.label.title}>{(title) => <span data-slot="basic-tool-tool-title">{title()}</span>}</Show>
|
|
525
|
+
<Show when={props.label.after}>{(after) => <span data-slot="context-tool-group-prefix">{after()}</span>}</Show>
|
|
526
|
+
</span>
|
|
527
|
+
)
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* What each background shell in a group did, for its label. Work that reports back anywhere in the group
|
|
532
|
+
* that started it is counted once, as how it ended: "Finished", not "Started" and "Finished".
|
|
533
|
+
*/
|
|
534
|
+
function workEvents(parts: ActivityGroupPart[]) {
|
|
535
|
+
const launch = (part: ActivityGroupPart) =>
|
|
536
|
+
part.type === "tool" && toolRule(part).layout === "event" ? toolEvent(part) : undefined
|
|
537
|
+
|
|
538
|
+
const launched = new Set(
|
|
539
|
+
parts.flatMap((part) => {
|
|
540
|
+
const event = launch(part)
|
|
541
|
+
const key = event && workKey(event)
|
|
542
|
+
|
|
543
|
+
return key ? [key] : []
|
|
544
|
+
}),
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
const reports = new Map(
|
|
548
|
+
parts.flatMap((part) => {
|
|
549
|
+
const key = part.type === "event" ? workKey(part.event) : undefined
|
|
550
|
+
|
|
551
|
+
return key && part.type === "event" ? [[key, part.event] as const] : []
|
|
552
|
+
}),
|
|
553
|
+
)
|
|
554
|
+
|
|
555
|
+
return new Map(
|
|
556
|
+
parts.flatMap((part): [ActivityGroupPart, TimelineEvent][] => {
|
|
557
|
+
if (part.type === "event") {
|
|
558
|
+
const key = workKey(part.event)
|
|
559
|
+
|
|
560
|
+
return key && launched.has(key) ? [] : [[part, part.event]]
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
const event = launch(part)
|
|
564
|
+
|
|
565
|
+
if (!event) return []
|
|
566
|
+
const key = workKey(event)
|
|
567
|
+
const outcome = key ? reports.get(key) : undefined
|
|
568
|
+
|
|
569
|
+
return [
|
|
570
|
+
[part, outcome && event.verb === "started" ? { ...event, verb: outcome.verb, failed: outcome.failed } : event],
|
|
571
|
+
]
|
|
572
|
+
}),
|
|
573
|
+
)
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// A search in an opened group: what was searched, and how many matches it found.
|
|
577
|
+
function searchTrigger(tool: SessionMessageAssistantTool, i18n: UiI18n) {
|
|
578
|
+
const input = toolInput(currentToolInput(tool))
|
|
579
|
+
const metadata = toolMetadata(currentToolMetadata(tool))
|
|
580
|
+
const subtitle = displayFolder(input.path)
|
|
581
|
+
const name = toolRule(tool).name
|
|
582
|
+
|
|
583
|
+
if (name === "list") return { title: i18n.t("ui.tool.list"), subtitle, args: [], count: undefined }
|
|
584
|
+
|
|
585
|
+
if (name === "glob")
|
|
586
|
+
return {
|
|
587
|
+
title: i18n.t("ui.tool.glob"),
|
|
588
|
+
subtitle,
|
|
589
|
+
args: input.pattern ? [`pattern=${input.pattern}`] : [],
|
|
590
|
+
count: metadata.count || undefined,
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return {
|
|
594
|
+
title: i18n.t("ui.tool.grep"),
|
|
595
|
+
subtitle,
|
|
596
|
+
args: [
|
|
597
|
+
...(input.pattern ? [`pattern=${input.pattern}`] : []),
|
|
598
|
+
...(input.include ? [`include=${input.include}`] : []),
|
|
599
|
+
],
|
|
600
|
+
count: metadata.matches || undefined,
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// Calls that read files, load skills or change files one after another read as one item.
|
|
605
|
+
function joins(previous: SessionMessageAssistantTool, tool: SessionMessageAssistantTool) {
|
|
606
|
+
return (
|
|
607
|
+
(changesFiles(previous) && changesFiles(tool)) ||
|
|
608
|
+
(currentToolGroupedRead(previous) && currentToolGroupedRead(tool)) ||
|
|
609
|
+
(loadsSkill(previous) && loadsSkill(tool))
|
|
610
|
+
)
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function changesFiles(tool: SessionMessageAssistantTool) {
|
|
614
|
+
return tool.state.status !== "error" && toolRule(tool).layout === "file"
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
function loadsSkill(tool: SessionMessageAssistantTool) {
|
|
618
|
+
return tool.name === "skill" && tool.state.status !== "error" && !!currentSkillName(tool)
|
|
619
|
+
}
|