@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,21 @@
|
|
|
1
|
+
import { useI18n } from "@zyro-sec/ui/context/i18n"
|
|
2
|
+
import { Icon } from "@zyro-sec/ui/icon"
|
|
3
|
+
import { Show } from "solid-js"
|
|
4
|
+
|
|
5
|
+
/** The Sources panel's title in its side-panel tab: "Sources · 87". */
|
|
6
|
+
export function SourcesTitle(props: { count: number }) {
|
|
7
|
+
const i18n = useI18n()
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div class="flex min-w-0 items-center gap-1.5">
|
|
11
|
+
<Icon name="globe" class="shrink-0" />
|
|
12
|
+
<span class="truncate">{i18n.t("ui.sources.title")}</span>
|
|
13
|
+
<Show when={props.count > 0}>
|
|
14
|
+
<span class="shrink-0 text-v2-text-text-faint" aria-hidden="true">
|
|
15
|
+
·
|
|
16
|
+
</span>
|
|
17
|
+
<span class="shrink-0 tabular-nums text-v2-text-text-faint">{props.count}</span>
|
|
18
|
+
</Show>
|
|
19
|
+
</div>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
[data-component="site-icon"] {
|
|
2
|
+
--site-icon-size: 16px;
|
|
3
|
+
position: relative;
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
flex: none;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
width: var(--site-icon-size);
|
|
9
|
+
height: var(--site-icon-size);
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
border-radius: 9999px;
|
|
12
|
+
background-color: var(--site-icon-bg);
|
|
13
|
+
box-shadow: inset 0 0 0 0.5px var(--v2-alpha-dark-12);
|
|
14
|
+
color: var(--v2-avatar-fg);
|
|
15
|
+
font-family: var(--font-family-sans);
|
|
16
|
+
font-size: 9px;
|
|
17
|
+
font-weight: var(--font-weight-medium);
|
|
18
|
+
line-height: 1;
|
|
19
|
+
user-select: none;
|
|
20
|
+
|
|
21
|
+
&[data-state] {
|
|
22
|
+
background-color: var(--v2-background-bg-layer-02);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
[data-slot="site-icon-image"] {
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
object-fit: cover;
|
|
29
|
+
opacity: 0;
|
|
30
|
+
transition: opacity 150ms ease-out;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&[data-state="loaded"] [data-slot="site-icon-image"] {
|
|
34
|
+
opacity: 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:root[data-motion="reduce"] [data-component="site-icon"] [data-slot="site-icon-image"] {
|
|
39
|
+
transition: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[data-component="sources-chip"] {
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
flex: none;
|
|
45
|
+
align-items: center;
|
|
46
|
+
gap: 6px;
|
|
47
|
+
height: 20px;
|
|
48
|
+
padding-inline: 2px 8px;
|
|
49
|
+
border-radius: 9999px;
|
|
50
|
+
background-color: var(--v2-overlay-simple-overlay-hover);
|
|
51
|
+
color: var(--v2-text-text-muted);
|
|
52
|
+
font-family: var(--v2-font-family-sans);
|
|
53
|
+
font-size: 12px;
|
|
54
|
+
font-weight: 440;
|
|
55
|
+
line-height: var(--line-height-compact);
|
|
56
|
+
letter-spacing: 0.05px;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
cursor: default;
|
|
59
|
+
transition:
|
|
60
|
+
background-color 150ms ease-out,
|
|
61
|
+
color 150ms ease-out;
|
|
62
|
+
|
|
63
|
+
&:hover,
|
|
64
|
+
&:focus-visible {
|
|
65
|
+
background-color: var(--v2-overlay-simple-overlay-pressed);
|
|
66
|
+
color: var(--v2-text-text-base);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&:focus-visible {
|
|
70
|
+
outline: 2px solid var(--v2-border-border-focus);
|
|
71
|
+
outline-offset: 2px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
[data-slot="sources-chip-icons"] {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
|
|
78
|
+
> [data-slot="icon-svg"] {
|
|
79
|
+
margin-inline-start: 4px;
|
|
80
|
+
color: var(--v2-text-text-faint);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Each later site tucks under the one before it, cut by a mask so the gap shows whatever is behind the chip. */
|
|
85
|
+
[data-component="site-icon"] + [data-component="site-icon"] {
|
|
86
|
+
margin-inline-start: -3px;
|
|
87
|
+
mask-image: radial-gradient(circle at -5px 50%, transparent 9.5px, #000 10px);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:root[data-motion="reduce"] [data-component="sources-chip"] {
|
|
92
|
+
transition: none;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* The turn's footer, set off from the reply by the same gap as its changed-files footer (`session-turn-diffs`). */
|
|
96
|
+
[data-component="text-part"] [data-slot="text-part-footer"] {
|
|
97
|
+
display: flex;
|
|
98
|
+
align-items: center;
|
|
99
|
+
gap: 8px;
|
|
100
|
+
min-height: 20px;
|
|
101
|
+
margin-top: 16px;
|
|
102
|
+
|
|
103
|
+
> [data-slot="text-part-copy-wrapper"] {
|
|
104
|
+
flex: 1;
|
|
105
|
+
min-width: 0;
|
|
106
|
+
margin-top: 0;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[data-component="sources-panel"] {
|
|
111
|
+
display: flex;
|
|
112
|
+
flex-direction: column;
|
|
113
|
+
gap: 2px;
|
|
114
|
+
padding: 8px;
|
|
115
|
+
|
|
116
|
+
[data-slot="sources-step-row"] {
|
|
117
|
+
display: grid;
|
|
118
|
+
grid-template-columns: 16px minmax(0, 1fr) auto;
|
|
119
|
+
column-gap: 10px;
|
|
120
|
+
width: 100%;
|
|
121
|
+
padding: 8px;
|
|
122
|
+
border-radius: 8px;
|
|
123
|
+
color: inherit;
|
|
124
|
+
text-align: start;
|
|
125
|
+
text-decoration: none;
|
|
126
|
+
cursor: default;
|
|
127
|
+
transition: background-color 150ms ease-out;
|
|
128
|
+
|
|
129
|
+
&:not(:disabled):hover,
|
|
130
|
+
&:focus-visible {
|
|
131
|
+
background-color: var(--v2-overlay-simple-overlay-hover);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&:focus-visible {
|
|
135
|
+
outline: 2px solid var(--v2-border-border-focus);
|
|
136
|
+
outline-offset: -2px;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
[data-slot="sources-step-icon"] {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
height: 16px;
|
|
144
|
+
color: var(--v2-text-text-faint);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
[data-slot="sources-step-text"] {
|
|
148
|
+
display: flex;
|
|
149
|
+
flex-direction: column;
|
|
150
|
+
gap: 2px;
|
|
151
|
+
min-width: 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
[data-slot="sources-step-label"] {
|
|
155
|
+
font-size: 12px;
|
|
156
|
+
font-weight: 440;
|
|
157
|
+
line-height: var(--line-height-compact);
|
|
158
|
+
letter-spacing: 0.05px;
|
|
159
|
+
color: var(--v2-text-text-faint);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
[data-slot="sources-step-detail"],
|
|
163
|
+
[data-slot="sources-result-title"],
|
|
164
|
+
[data-slot="sources-result-site"] {
|
|
165
|
+
overflow: hidden;
|
|
166
|
+
white-space: nowrap;
|
|
167
|
+
mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
[data-slot="sources-step-detail"] {
|
|
171
|
+
font-family: var(--font-family-mono);
|
|
172
|
+
font-size: 13px;
|
|
173
|
+
font-weight: 440;
|
|
174
|
+
line-height: var(--line-height-compact);
|
|
175
|
+
letter-spacing: -0.04px;
|
|
176
|
+
color: var(--v2-text-text-base);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
[data-slot="sources-step-path"] {
|
|
180
|
+
color: var(--v2-text-text-muted);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
[data-slot="sources-step-error"] {
|
|
184
|
+
font-size: 12px;
|
|
185
|
+
line-height: var(--line-height-compact);
|
|
186
|
+
color: var(--v2-state-fg-danger);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
[data-slot="sources-step-count"] {
|
|
190
|
+
align-self: start;
|
|
191
|
+
height: 16px;
|
|
192
|
+
font-size: 12px;
|
|
193
|
+
font-weight: 440;
|
|
194
|
+
line-height: var(--line-height-compact);
|
|
195
|
+
font-variant-numeric: tabular-nums;
|
|
196
|
+
color: var(--v2-text-text-faint);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
[data-slot="sources-step"][data-open] [data-slot="sources-step-count"] {
|
|
200
|
+
color: var(--v2-text-text-base);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
[data-slot="sources-step-results"] {
|
|
204
|
+
overflow: clip;
|
|
205
|
+
|
|
206
|
+
&[data-moving] {
|
|
207
|
+
mask-image: linear-gradient(to bottom, #000 calc(100% - 16px), transparent);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
[data-slot="sources-step-list"] {
|
|
212
|
+
display: flex;
|
|
213
|
+
flex-direction: column;
|
|
214
|
+
padding-block: 2px 6px;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* The site icon sits on the step's text edge; the row's highlight bleeds out past it. */
|
|
218
|
+
[data-slot="sources-result"] {
|
|
219
|
+
display: grid;
|
|
220
|
+
grid-template-columns: 16px minmax(0, 1fr);
|
|
221
|
+
column-gap: 10px;
|
|
222
|
+
margin-inline-start: 26px;
|
|
223
|
+
padding: 6px 8px;
|
|
224
|
+
border-radius: 8px;
|
|
225
|
+
color: inherit;
|
|
226
|
+
text-decoration: none;
|
|
227
|
+
cursor: default;
|
|
228
|
+
transition: background-color 150ms ease-out;
|
|
229
|
+
|
|
230
|
+
&:hover,
|
|
231
|
+
&:focus-visible {
|
|
232
|
+
background-color: var(--v2-overlay-simple-overlay-hover);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
&:focus-visible {
|
|
236
|
+
outline: 2px solid var(--v2-border-border-focus);
|
|
237
|
+
outline-offset: -2px;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
[data-slot="sources-result-text"] {
|
|
242
|
+
display: flex;
|
|
243
|
+
flex-direction: column;
|
|
244
|
+
min-width: 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
[data-slot="sources-result-title"] {
|
|
248
|
+
font-size: 13px;
|
|
249
|
+
line-height: var(--line-height-compact);
|
|
250
|
+
color: var(--v2-text-text-base);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
[data-slot="sources-result-site"] {
|
|
254
|
+
font-size: 12px;
|
|
255
|
+
line-height: var(--line-height-compact);
|
|
256
|
+
letter-spacing: 0.05px;
|
|
257
|
+
color: var(--v2-text-text-faint);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
:root[data-motion="reduce"] [data-component="sources-panel"] {
|
|
262
|
+
[data-slot="sources-step-row"],
|
|
263
|
+
[data-slot="sources-result"] {
|
|
264
|
+
transition: none;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { SessionMessageAssistant, SessionMessageAssistantTool, SessionMessageInfo } from "@zyro-sec/client/promise"
|
|
2
|
+
import { Option, Schema } from "effect"
|
|
3
|
+
import { currentToolError, currentToolInput, currentToolOutput } from "../message/current-tool-state"
|
|
4
|
+
|
|
5
|
+
const decodeQuery = Schema.decodeUnknownOption(Schema.Struct({ query: Schema.String }))
|
|
6
|
+
|
|
7
|
+
const decodeURL = Schema.decodeUnknownOption(Schema.Struct({ url: Schema.String }))
|
|
8
|
+
|
|
9
|
+
export type SourceResult = {
|
|
10
|
+
url: string
|
|
11
|
+
title?: string
|
|
12
|
+
/** The hostname without `www.`, as shown and as the letter tile's seed. */
|
|
13
|
+
site: string
|
|
14
|
+
/** The full hostname, where its favicon lives. */
|
|
15
|
+
host: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type StepStatus = "running" | "completed" | "error"
|
|
19
|
+
|
|
20
|
+
export type SourceStep =
|
|
21
|
+
| { type: "search"; id: string; query: string; status: StepStatus; results: SourceResult[]; error?: string }
|
|
22
|
+
| ({ type: "fetch"; id: string; path: string; status: StepStatus; error?: string } & SourceResult)
|
|
23
|
+
|
|
24
|
+
export type TurnSources = {
|
|
25
|
+
steps: SourceStep[]
|
|
26
|
+
/** Distinct sources in the order the turn met them: search results and opened pages, deduped by URL. */
|
|
27
|
+
sources: SourceResult[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The web searches and page fetches of one turn's assistant messages, in the order they ran. */
|
|
31
|
+
export function turnSources(messages: readonly SessionMessageAssistant[]): TurnSources {
|
|
32
|
+
const steps = messages.flatMap((message) => message.content.flatMap((content) => step(content)))
|
|
33
|
+
const seen = new Set<string>()
|
|
34
|
+
|
|
35
|
+
const sources = steps
|
|
36
|
+
.flatMap((item) => (item.type === "search" ? item.results : item.status === "error" ? [] : [item]))
|
|
37
|
+
.filter((item) => {
|
|
38
|
+
const key = identity(item.url)
|
|
39
|
+
|
|
40
|
+
if (seen.has(key)) return false
|
|
41
|
+
seen.add(key)
|
|
42
|
+
|
|
43
|
+
return true
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
return { steps, sources }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The assistant messages of the turn a user message opened, grouped as the timeline groups them. */
|
|
50
|
+
export function turnMessages(messages: readonly SessionMessageInfo[], from: string) {
|
|
51
|
+
const start = messages.findIndex((message) => message.id === from)
|
|
52
|
+
|
|
53
|
+
if (start === -1) return []
|
|
54
|
+
|
|
55
|
+
const end = messages.findIndex(
|
|
56
|
+
(message, index) => index > start && (message.type === "user" || message.type === "shell"),
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
return messages
|
|
60
|
+
.slice(start + 1, end === -1 ? undefined : end)
|
|
61
|
+
.filter((message): message is SessionMessageAssistant => message.type === "assistant")
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function step(content: SessionMessageAssistant["content"][number]): SourceStep[] {
|
|
65
|
+
if (content.type !== "tool" || content.state.status === "streaming") return []
|
|
66
|
+
|
|
67
|
+
if (content.name === "websearch") return [search(content)]
|
|
68
|
+
|
|
69
|
+
if (content.name !== "webfetch") return []
|
|
70
|
+
|
|
71
|
+
const page = Option.getOrUndefined(
|
|
72
|
+
decodeURL(currentToolInput(content)).pipe(Option.flatMapNullishOr((input) => source(input.url))),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
if (!page) return []
|
|
76
|
+
|
|
77
|
+
return [
|
|
78
|
+
{
|
|
79
|
+
type: "fetch",
|
|
80
|
+
id: content.id,
|
|
81
|
+
...page,
|
|
82
|
+
path: path(page.url),
|
|
83
|
+
status: content.state.status,
|
|
84
|
+
error: currentToolError(content),
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function search(tool: SessionMessageAssistantTool): SourceStep {
|
|
90
|
+
return {
|
|
91
|
+
type: "search",
|
|
92
|
+
id: tool.id,
|
|
93
|
+
query: Option.match(decodeQuery(currentToolInput(tool)), { onNone: () => "", onSome: (input) => input.query }),
|
|
94
|
+
status: tool.state.status === "streaming" ? "running" : tool.state.status,
|
|
95
|
+
results: tool.state.status === "completed" ? results(currentToolOutput(tool) ?? "") : [],
|
|
96
|
+
error: currentToolError(tool),
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// The websearch tool keeps its structured results out of the message and writes each one as a `## [title](url)`
|
|
101
|
+
// heading in its text content (packages/core/src/tool/plugin/websearch.ts); a result without a title repeats its URL.
|
|
102
|
+
function results(text: string) {
|
|
103
|
+
return text.split("\n").flatMap((line): SourceResult[] => {
|
|
104
|
+
if (!line.startsWith("## [") || !line.endsWith(")")) return []
|
|
105
|
+
|
|
106
|
+
const split = line.lastIndexOf("](")
|
|
107
|
+
|
|
108
|
+
if (split < 4) return []
|
|
109
|
+
|
|
110
|
+
const result = source(line.slice(split + 2, -1))
|
|
111
|
+
|
|
112
|
+
if (!result) return []
|
|
113
|
+
|
|
114
|
+
const title = line.slice(4, split).trim()
|
|
115
|
+
|
|
116
|
+
return [{ ...result, title: title && title !== result.url ? title : undefined }]
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function source(url: string): SourceResult | undefined {
|
|
121
|
+
if (!URL.canParse(url)) return undefined
|
|
122
|
+
|
|
123
|
+
const parsed = new URL(url)
|
|
124
|
+
|
|
125
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return undefined
|
|
126
|
+
|
|
127
|
+
return { url, host: parsed.hostname, site: parsed.hostname.replace(/^www\./, "") }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// One source per page: the scheme, `www.`, a trailing slash and the fragment don't make another.
|
|
131
|
+
function identity(url: string) {
|
|
132
|
+
const parsed = new URL(url)
|
|
133
|
+
|
|
134
|
+
return `${parsed.hostname.replace(/^www\./, "")}${parsed.pathname.replace(/\/+$/, "")}${parsed.search}`
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function path(url: string) {
|
|
138
|
+
const parsed = new URL(url)
|
|
139
|
+
|
|
140
|
+
return `${parsed.pathname.replace(/\/+$/, "")}${parsed.search}`
|
|
141
|
+
}
|