@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,128 @@
|
|
|
1
|
+
/** How long the width and crossfade transitions keep both titles mounted. */
|
|
2
|
+
export const TOOL_STATUS_ANIMATION_MS = 600
|
|
3
|
+
|
|
4
|
+
/** `suffix` animates only the differing tail after a shared prefix; `swap` animates the whole title. */
|
|
5
|
+
export type ToolStatusMode = "suffix" | "swap"
|
|
6
|
+
|
|
7
|
+
type Shared = {
|
|
8
|
+
readonly active: boolean
|
|
9
|
+
readonly mode: ToolStatusMode
|
|
10
|
+
/** The tail the user sees: the active text while active, the done text after. */
|
|
11
|
+
readonly text: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A title that animates between its active and done text. `idle` shows one text at its natural width. `measuring` pins
|
|
16
|
+
* the previous width for one frame with both texts mounted, `animating` transitions to the measured width until the
|
|
17
|
+
* transition ends. `crossfade` keeps the animation even at an unchanged width, so the two texts still fade. `attempts`
|
|
18
|
+
* counts started animations, so a frame or timer of an earlier one is stale.
|
|
19
|
+
*/
|
|
20
|
+
export type ToolStatusTitleState =
|
|
21
|
+
| (Shared & { readonly status: "idle"; readonly attempts: number })
|
|
22
|
+
| (Shared & {
|
|
23
|
+
readonly status: "measuring"
|
|
24
|
+
readonly attempt: number
|
|
25
|
+
readonly from: string
|
|
26
|
+
readonly crossfade: boolean
|
|
27
|
+
})
|
|
28
|
+
| (Shared & { readonly status: "animating"; readonly attempt: number; readonly width: string })
|
|
29
|
+
| { readonly status: "disposed" }
|
|
30
|
+
|
|
31
|
+
export type ToolStatusTitleEvent =
|
|
32
|
+
| {
|
|
33
|
+
readonly type: "sync"
|
|
34
|
+
readonly active: boolean
|
|
35
|
+
readonly mode: ToolStatusMode
|
|
36
|
+
readonly text: string
|
|
37
|
+
/** The current width, or `undefined` while the title is hidden, detached or has no width. */
|
|
38
|
+
readonly width: string | undefined
|
|
39
|
+
readonly reducedMotion: boolean
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
readonly type: "measured"
|
|
43
|
+
readonly attempt: number
|
|
44
|
+
/** The new text's width, or `undefined` while the title is hidden, detached or has no width. */
|
|
45
|
+
readonly width: string | undefined
|
|
46
|
+
}
|
|
47
|
+
| { readonly type: "settled"; readonly attempt: number }
|
|
48
|
+
| { readonly type: "disposed" }
|
|
49
|
+
|
|
50
|
+
export const DISPOSED_TOOL_STATUS_TITLE_STATE: ToolStatusTitleState = Object.freeze({ status: "disposed" })
|
|
51
|
+
|
|
52
|
+
export const DISPOSED_TOOL_STATUS_TITLE_EVENT: ToolStatusTitleEvent = Object.freeze({ type: "disposed" })
|
|
53
|
+
|
|
54
|
+
export function createToolStatusTitleState(input: Shared): ToolStatusTitleState {
|
|
55
|
+
return { status: "idle", active: input.active, mode: input.mode, text: input.text, attempts: 0 }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function transitionToolStatusTitle(
|
|
59
|
+
state: ToolStatusTitleState,
|
|
60
|
+
event: ToolStatusTitleEvent,
|
|
61
|
+
): ToolStatusTitleState {
|
|
62
|
+
if (state.status === "disposed") return state
|
|
63
|
+
|
|
64
|
+
if (event.type === "disposed") return DISPOSED_TOOL_STATUS_TITLE_STATE
|
|
65
|
+
const attempts = state.status === "idle" ? state.attempts : state.attempt
|
|
66
|
+
|
|
67
|
+
if (event.type === "sync") {
|
|
68
|
+
// A change to the hidden text shows nothing new.
|
|
69
|
+
if (event.active === state.active && event.mode === state.mode && event.text === state.text) return state
|
|
70
|
+
|
|
71
|
+
// A hidden title has no width to animate from, and a width from the other mode's container would jump the layout.
|
|
72
|
+
if (!event.width || event.reducedMotion || event.mode !== state.mode)
|
|
73
|
+
return { status: "idle", active: event.active, mode: event.mode, text: event.text, attempts }
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
status: "measuring",
|
|
77
|
+
active: event.active,
|
|
78
|
+
mode: event.mode,
|
|
79
|
+
text: event.text,
|
|
80
|
+
attempt: attempts + 1,
|
|
81
|
+
from: event.width,
|
|
82
|
+
crossfade: event.active !== state.active || state.status !== "idle",
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (event.type === "measured") {
|
|
87
|
+
if (state.status !== "measuring" || event.attempt !== state.attempt) return state
|
|
88
|
+
|
|
89
|
+
if (!event.width || (!state.crossfade && event.width === state.from))
|
|
90
|
+
return { status: "idle", active: state.active, mode: state.mode, text: state.text, attempts: state.attempt }
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
status: "animating",
|
|
94
|
+
active: state.active,
|
|
95
|
+
mode: state.mode,
|
|
96
|
+
text: state.text,
|
|
97
|
+
attempt: state.attempt,
|
|
98
|
+
width: event.width,
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (state.status !== "animating" || event.attempt !== state.attempt) return state
|
|
103
|
+
|
|
104
|
+
return { status: "idle", active: state.active, mode: state.mode, text: state.text, attempts: state.attempt }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function viewToolStatusTitle(state: ToolStatusTitleState) {
|
|
108
|
+
if (state.status === "disposed")
|
|
109
|
+
return { active: false, animating: false, width: undefined, showActive: false, showDone: true }
|
|
110
|
+
|
|
111
|
+
if (state.status === "idle")
|
|
112
|
+
return {
|
|
113
|
+
active: state.active,
|
|
114
|
+
animating: false,
|
|
115
|
+
width: undefined,
|
|
116
|
+
showActive: state.active,
|
|
117
|
+
showDone: !state.active,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Both texts stay mounted so one fades out while the other fades in.
|
|
121
|
+
return {
|
|
122
|
+
active: state.active,
|
|
123
|
+
animating: true,
|
|
124
|
+
width: state.status === "measuring" ? state.from : state.width,
|
|
125
|
+
showActive: true,
|
|
126
|
+
showDone: true,
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
[data-component="tool-status-title"] {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: baseline;
|
|
4
|
+
white-space: nowrap;
|
|
5
|
+
text-align: start;
|
|
6
|
+
|
|
7
|
+
[data-slot="tool-status-suffix"] {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: baseline;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[data-slot="tool-status-prefix"] {
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
flex-shrink: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[data-slot="tool-status-swap"],
|
|
19
|
+
[data-slot="tool-status-tail"] {
|
|
20
|
+
display: inline-grid;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
justify-items: start;
|
|
23
|
+
transition: width var(--tool-motion-spring-ms, 480ms) var(--tool-motion-ease, cubic-bezier(0.22, 1, 0.36, 1));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[data-slot="tool-status-active"],
|
|
27
|
+
[data-slot="tool-status-done"] {
|
|
28
|
+
grid-area: 1 / 1;
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
justify-self: start;
|
|
31
|
+
text-align: start;
|
|
32
|
+
transition-property: opacity, filter, transform;
|
|
33
|
+
transition-duration:
|
|
34
|
+
var(--tool-motion-fade-ms, 240ms), calc(var(--tool-motion-fade-ms, 240ms) * 0.8),
|
|
35
|
+
calc(var(--tool-motion-fade-ms, 240ms) * 0.8);
|
|
36
|
+
transition-timing-function: ease-out, ease-out, ease-out;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&[data-ready="false"] {
|
|
40
|
+
[data-slot="tool-status-swap"],
|
|
41
|
+
[data-slot="tool-status-tail"] {
|
|
42
|
+
transition-duration: 0ms;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-slot="tool-status-active"],
|
|
46
|
+
[data-slot="tool-status-done"] {
|
|
47
|
+
transition-duration: 0ms;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[data-slot="tool-status-active"] {
|
|
52
|
+
opacity: 0;
|
|
53
|
+
filter: blur(calc(var(--tool-motion-blur, 2px) * 0.45));
|
|
54
|
+
transform: translateY(0.03em);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[data-slot="tool-status-done"] {
|
|
58
|
+
color: var(--v2-text-text-base);
|
|
59
|
+
opacity: 1;
|
|
60
|
+
filter: blur(0);
|
|
61
|
+
transform: translateY(0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&[data-active="true"] {
|
|
65
|
+
[data-slot="tool-status-active"] {
|
|
66
|
+
opacity: 1;
|
|
67
|
+
filter: blur(0);
|
|
68
|
+
transform: translateY(0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
[data-slot="tool-status-done"] {
|
|
72
|
+
opacity: 0;
|
|
73
|
+
filter: blur(calc(var(--tool-motion-blur, 2px) * 0.45));
|
|
74
|
+
transform: translateY(0.03em);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
:root[data-motion="reduce"] {
|
|
80
|
+
[data-component="tool-status-title"] [data-slot="tool-status-swap"],
|
|
81
|
+
[data-component="tool-status-title"] [data-slot="tool-status-tail"] {
|
|
82
|
+
transition-duration: 0ms;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[data-component="tool-status-title"] [data-slot="tool-status-active"],
|
|
86
|
+
[data-component="tool-status-title"] [data-slot="tool-status-done"] {
|
|
87
|
+
transition-duration: 0ms;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Show, createEffect, createMemo, createSignal, on, onCleanup, untrack } from "solid-js"
|
|
2
|
+
import { TextShimmer } from "@zyro-sec/ui/text-shimmer"
|
|
3
|
+
import { prefersReducedMotion } from "@zyro-sec/ui/motion"
|
|
4
|
+
import {
|
|
5
|
+
createToolStatusTitleState,
|
|
6
|
+
DISPOSED_TOOL_STATUS_TITLE_EVENT,
|
|
7
|
+
TOOL_STATUS_ANIMATION_MS,
|
|
8
|
+
transitionToolStatusTitle,
|
|
9
|
+
viewToolStatusTitle,
|
|
10
|
+
type ToolStatusMode,
|
|
11
|
+
type ToolStatusTitleEvent,
|
|
12
|
+
} from "./tool-status-title-machine"
|
|
13
|
+
|
|
14
|
+
function common(active: string, done: string) {
|
|
15
|
+
const a = Array.from(active)
|
|
16
|
+
const b = Array.from(done)
|
|
17
|
+
let i = 0
|
|
18
|
+
|
|
19
|
+
while (i < a.length && i < b.length && a[i] === b[i]) i++
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
prefix: a.slice(0, i).join(""),
|
|
23
|
+
active: a.slice(i).join(""),
|
|
24
|
+
done: b.slice(i).join(""),
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// A title in a hidden tab or a detached row measures 0px; pinning that width would clip it until the animation ends.
|
|
29
|
+
function contentWidth(el: HTMLSpanElement | undefined) {
|
|
30
|
+
if (!el?.isConnected) return
|
|
31
|
+
const width = Math.ceil(el.getBoundingClientRect().width)
|
|
32
|
+
|
|
33
|
+
return width > 0 ? `${width}px` : undefined
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function ToolStatusTitle(props: {
|
|
37
|
+
active: boolean
|
|
38
|
+
activeText: string
|
|
39
|
+
doneText: string
|
|
40
|
+
class?: string
|
|
41
|
+
split?: boolean
|
|
42
|
+
}) {
|
|
43
|
+
const split = createMemo(() => common(props.activeText, props.doneText))
|
|
44
|
+
|
|
45
|
+
const suffix = createMemo(
|
|
46
|
+
() => (props.split ?? true) && split().prefix.length >= 2 && split().active.length > 0 && split().done.length > 0,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
const prefixLen = createMemo(() => Array.from(split().prefix).length)
|
|
50
|
+
const activeTail = createMemo(() => (suffix() ? split().active : props.activeText))
|
|
51
|
+
const doneTail = createMemo(() => (suffix() ? split().done : props.doneText))
|
|
52
|
+
const mode = createMemo<ToolStatusMode>(() => (suffix() ? "suffix" : "swap"))
|
|
53
|
+
const text = createMemo(() => (props.active ? activeTail() : doneTail()))
|
|
54
|
+
|
|
55
|
+
const [machine, setMachine] = createSignal(
|
|
56
|
+
createToolStatusTitleState({ active: props.active, mode: untrack(mode), text: untrack(text) }),
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
const view = createMemo(() => viewToolStatusTitle(machine()))
|
|
60
|
+
let activeRef: HTMLSpanElement | undefined
|
|
61
|
+
let doneRef: HTMLSpanElement | undefined
|
|
62
|
+
let widthRef: HTMLSpanElement | undefined
|
|
63
|
+
let frame: number | undefined
|
|
64
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
65
|
+
|
|
66
|
+
const dispatch = (event: ToolStatusTitleEvent) => {
|
|
67
|
+
const previous = untrack(machine)
|
|
68
|
+
const next = transitionToolStatusTitle(previous, event)
|
|
69
|
+
|
|
70
|
+
if (next === previous) return
|
|
71
|
+
|
|
72
|
+
if (frame !== undefined) cancelAnimationFrame(frame)
|
|
73
|
+
clearTimeout(timer)
|
|
74
|
+
frame = undefined
|
|
75
|
+
timer = undefined
|
|
76
|
+
|
|
77
|
+
if (next.status === "disposed") return
|
|
78
|
+
setMachine(next)
|
|
79
|
+
|
|
80
|
+
if (next.status === "measuring") {
|
|
81
|
+
const attempt = next.attempt
|
|
82
|
+
|
|
83
|
+
frame = requestAnimationFrame(() => {
|
|
84
|
+
frame = undefined
|
|
85
|
+
dispatch({ type: "measured", attempt, width: contentWidth(next.active ? activeRef : doneRef) })
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (next.status === "animating") {
|
|
90
|
+
const attempt = next.attempt
|
|
91
|
+
|
|
92
|
+
timer = setTimeout(() => {
|
|
93
|
+
timer = undefined
|
|
94
|
+
dispatch({ type: "settled", attempt })
|
|
95
|
+
}, TOOL_STATUS_ANIMATION_MS)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
createEffect(
|
|
100
|
+
on(
|
|
101
|
+
[() => props.active, mode, text],
|
|
102
|
+
() =>
|
|
103
|
+
dispatch({
|
|
104
|
+
type: "sync",
|
|
105
|
+
active: props.active,
|
|
106
|
+
mode: mode(),
|
|
107
|
+
text: text(),
|
|
108
|
+
width: contentWidth(widthRef),
|
|
109
|
+
reducedMotion: prefersReducedMotion(),
|
|
110
|
+
}),
|
|
111
|
+
{ defer: true },
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
onCleanup(() => dispatch(DISPOSED_TOOL_STATUS_TITLE_EVENT))
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<span
|
|
119
|
+
data-component="tool-status-title"
|
|
120
|
+
data-active={view().active ? "true" : "false"}
|
|
121
|
+
data-ready={view().animating ? "true" : "false"}
|
|
122
|
+
data-mode={mode()}
|
|
123
|
+
class={props.class}
|
|
124
|
+
aria-label={view().active ? props.activeText : props.doneText}
|
|
125
|
+
>
|
|
126
|
+
<Show
|
|
127
|
+
when={suffix()}
|
|
128
|
+
fallback={
|
|
129
|
+
<span data-slot="tool-status-swap" ref={widthRef} style={{ width: view().width }}>
|
|
130
|
+
<Show when={view().showActive}>
|
|
131
|
+
<span data-slot="tool-status-active" ref={activeRef}>
|
|
132
|
+
<TextShimmer text={activeTail()} active={view().active} offset={0} />
|
|
133
|
+
</span>
|
|
134
|
+
</Show>
|
|
135
|
+
<Show when={view().showDone}>
|
|
136
|
+
<span data-slot="tool-status-done" ref={doneRef}>
|
|
137
|
+
<TextShimmer text={doneTail()} active={false} offset={0} />
|
|
138
|
+
</span>
|
|
139
|
+
</Show>
|
|
140
|
+
</span>
|
|
141
|
+
}
|
|
142
|
+
>
|
|
143
|
+
<span data-slot="tool-status-suffix">
|
|
144
|
+
<span data-slot="tool-status-prefix">
|
|
145
|
+
<TextShimmer text={split().prefix} active={view().active} offset={0} />
|
|
146
|
+
</span>
|
|
147
|
+
<span data-slot="tool-status-tail" ref={widthRef} style={{ width: view().width }}>
|
|
148
|
+
<Show when={view().showActive}>
|
|
149
|
+
<span data-slot="tool-status-active" ref={activeRef}>
|
|
150
|
+
<TextShimmer text={activeTail()} active={view().active} offset={prefixLen()} />
|
|
151
|
+
</span>
|
|
152
|
+
</Show>
|
|
153
|
+
<Show when={view().showDone}>
|
|
154
|
+
<span data-slot="tool-status-done" ref={doneRef}>
|
|
155
|
+
<TextShimmer text={doneTail()} active={false} offset={prefixLen()} />
|
|
156
|
+
</span>
|
|
157
|
+
</Show>
|
|
158
|
+
</span>
|
|
159
|
+
</span>
|
|
160
|
+
</Show>
|
|
161
|
+
</span>
|
|
162
|
+
)
|
|
163
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FileDiffInfo,
|
|
3
|
+
SessionInfo,
|
|
4
|
+
SessionStatus,
|
|
5
|
+
ShellOutputInput,
|
|
6
|
+
ShellOutputOutput,
|
|
7
|
+
} from "@zyro-sec/client/promise"
|
|
8
|
+
import { createSimpleContext } from "@zyro-sec/ui/context"
|
|
9
|
+
import { PreloadMultiFileDiffResult } from "@pierre/diffs/ssr"
|
|
10
|
+
|
|
11
|
+
export type SessionSummary = Pick<SessionInfo, "id" | "parentID" | "title" | "time">
|
|
12
|
+
|
|
13
|
+
type ProviderCatalog = {
|
|
14
|
+
all: Map<string, { models: Record<string, { name: string; speed?: { base: string; id: string } }> }>
|
|
15
|
+
default: {
|
|
16
|
+
[key: string]: string
|
|
17
|
+
}
|
|
18
|
+
connected: Array<string>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Data = {
|
|
22
|
+
agent?: {
|
|
23
|
+
name: string
|
|
24
|
+
color?: string
|
|
25
|
+
}[]
|
|
26
|
+
provider?: ProviderCatalog
|
|
27
|
+
session: SessionSummary[]
|
|
28
|
+
session_status: {
|
|
29
|
+
[sessionID: string]: SessionStatus
|
|
30
|
+
}
|
|
31
|
+
session_diff: {
|
|
32
|
+
[sessionID: string]: FileDiffInfo[]
|
|
33
|
+
}
|
|
34
|
+
session_diff_preload?: {
|
|
35
|
+
[sessionID: string]: PreloadMultiFileDiffResult<unknown, undefined>[]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Names a finished turn by its Session and the user message that opened it. */
|
|
40
|
+
export type TurnDiffInput = { sessionID: string; from: string }
|
|
41
|
+
|
|
42
|
+
/** A turn's diff load as the host reports it; a turn not loaded yet reads as `loading`. */
|
|
43
|
+
export type TurnDiffState =
|
|
44
|
+
| { readonly status: "loading" }
|
|
45
|
+
| { readonly status: "ready"; readonly diffs: readonly FileDiffInfo[] }
|
|
46
|
+
| { readonly status: "failed" }
|
|
47
|
+
|
|
48
|
+
/** The host's cache of the files each finished turn changed. */
|
|
49
|
+
export type TurnDiffSource = {
|
|
50
|
+
state: (input: TurnDiffInput) => TurnDiffState
|
|
51
|
+
/** Starts loading the turn's diffs, or retries a failed load; does nothing while loading or once loaded. */
|
|
52
|
+
load: (input: TurnDiffInput) => void
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type NavigateToSessionFn = (sessionID: string) => void
|
|
56
|
+
|
|
57
|
+
export type SessionHrefFn = (sessionID: string) => string
|
|
58
|
+
|
|
59
|
+
export type ReadMediaUrlFn = (uri: string, mime: string, signal?: AbortSignal) => Promise<string | undefined>
|
|
60
|
+
|
|
61
|
+
export type PeekMediaUrlFn = (uri: string, mime: string) => string | undefined
|
|
62
|
+
|
|
63
|
+
export const {
|
|
64
|
+
use: useData,
|
|
65
|
+
provider: DataProvider,
|
|
66
|
+
context: DataContext,
|
|
67
|
+
} = createSimpleContext({
|
|
68
|
+
name: "Data",
|
|
69
|
+
init: (props: {
|
|
70
|
+
data: Data
|
|
71
|
+
directory: string
|
|
72
|
+
sessionID?: string
|
|
73
|
+
/** Whether message meta names the agent; the app follows its Show agent setting. Defaults to true. */
|
|
74
|
+
agents?: boolean
|
|
75
|
+
shellRunning?: (id: string) => boolean
|
|
76
|
+
shellOutput?: (input: ShellOutputInput) => Promise<ShellOutputOutput>
|
|
77
|
+
turnDiff?: TurnDiffSource
|
|
78
|
+
readMedia?: ReadMediaUrlFn
|
|
79
|
+
peekMedia?: PeekMediaUrlFn
|
|
80
|
+
onNavigateToSession?: NavigateToSessionFn
|
|
81
|
+
onSessionHref?: SessionHrefFn
|
|
82
|
+
}) => {
|
|
83
|
+
return {
|
|
84
|
+
get store() {
|
|
85
|
+
return props.data
|
|
86
|
+
},
|
|
87
|
+
get directory() {
|
|
88
|
+
return props.directory
|
|
89
|
+
},
|
|
90
|
+
get sessionID() {
|
|
91
|
+
return props.sessionID
|
|
92
|
+
},
|
|
93
|
+
get agents() {
|
|
94
|
+
return props.agents ?? true
|
|
95
|
+
},
|
|
96
|
+
navigateToSession: props.onNavigateToSession,
|
|
97
|
+
sessionHref: props.onSessionHref,
|
|
98
|
+
shellRunning: props.shellRunning,
|
|
99
|
+
shellOutput: props.shellOutput,
|
|
100
|
+
get turnDiff() {
|
|
101
|
+
return props.turnDiff
|
|
102
|
+
},
|
|
103
|
+
readMedia: props.readMedia,
|
|
104
|
+
peekMedia: props.peekMedia,
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./data"
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { IconProps } from "@zyro-sec/ui/icon"
|
|
2
|
+
import { createContext, useContext, type ParentProps } from "solid-js"
|
|
3
|
+
import type { SessionReferenceMenu } from "../components/markdown-session-links"
|
|
4
|
+
|
|
5
|
+
export type ReadMarkdownImage = (path: string, signal: AbortSignal) => Promise<Blob | undefined>
|
|
6
|
+
|
|
7
|
+
/** Open a local file path linked from markdown. The path is decoded and may be relative or absolute. */
|
|
8
|
+
export type OpenMarkdownLocalFile = (path: string) => void
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether an inline-code path names a file that exists. Inline code is styled as a file link only when this says yes;
|
|
12
|
+
* without it, inline code stays plain.
|
|
13
|
+
*/
|
|
14
|
+
export type MarkdownLocalFileExists = (path: string) => boolean | Promise<boolean>
|
|
15
|
+
|
|
16
|
+
/** A complete fenced code block, as `MarkdownCodeBlocks` receives it. */
|
|
17
|
+
export type MarkdownCodeBlock = {
|
|
18
|
+
/** The source between the fences, without the final line break. */
|
|
19
|
+
readonly code: string
|
|
20
|
+
/** The first word of the fence's info string, lowercased, e.g. `mermaid`. Empty without one. */
|
|
21
|
+
readonly language: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The languages that have content of their own; a new object whenever a block's content may change. */
|
|
25
|
+
export type MarkdownCodeBlockMatch = {
|
|
26
|
+
/** Languages whose blocks `render` replaces once complete. */
|
|
27
|
+
readonly render: ReadonlySet<string>
|
|
28
|
+
/** Languages whose blocks get `actions` beside Copy once complete. */
|
|
29
|
+
readonly actions: ReadonlySet<string>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A button beside a code block's Copy button. */
|
|
33
|
+
export type MarkdownCodeAction = {
|
|
34
|
+
/** The button's icon: a catalog name, or the name of registered artwork. */
|
|
35
|
+
readonly icon: IconProps["name"]
|
|
36
|
+
/** The accessible name and tooltip. */
|
|
37
|
+
readonly title: string
|
|
38
|
+
/** Runs when the user clicks the button. */
|
|
39
|
+
run(block: MarkdownCodeBlock): void
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Content for fenced code blocks in place of the highlighted code, and buttons beside Copy. Markdown asks only for blocks
|
|
44
|
+
* whose language `current` lists, and only once the closing fence arrived; every other block costs a set lookup.
|
|
45
|
+
*/
|
|
46
|
+
export type MarkdownCodeBlocks = {
|
|
47
|
+
/** The languages with content. Reactive: markdown decorates its blocks again when it returns a new object. */
|
|
48
|
+
readonly current: () => MarkdownCodeBlockMatch
|
|
49
|
+
/**
|
|
50
|
+
* Mounts content for a block into `target`. Returns the content's dispose, or undefined to keep the code. Calls
|
|
51
|
+
* `fallback` when the content fails later; markdown then shows the code again.
|
|
52
|
+
*/
|
|
53
|
+
readonly render: (target: HTMLElement, block: MarkdownCodeBlock, fallback: () => void) => (() => void) | undefined
|
|
54
|
+
/** The buttons for a language, in order. Reactive. */
|
|
55
|
+
readonly actions: (language: string) => readonly MarkdownCodeAction[]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const context = createContext<{
|
|
59
|
+
readonly appLinks?: boolean
|
|
60
|
+
readonly readImage?: ReadMarkdownImage
|
|
61
|
+
readonly openLocalFile?: OpenMarkdownLocalFile
|
|
62
|
+
readonly localFileExists?: MarkdownLocalFileExists
|
|
63
|
+
readonly openSession?: (sessionID: string) => void
|
|
64
|
+
readonly sessionTitle?: (sessionID: string) => string | undefined
|
|
65
|
+
readonly sessionMenu?: SessionReferenceMenu
|
|
66
|
+
readonly codeBlocks?: MarkdownCodeBlocks
|
|
67
|
+
readonly codeWrap?: boolean
|
|
68
|
+
}>()
|
|
69
|
+
|
|
70
|
+
export function MarkdownProvider(
|
|
71
|
+
props: ParentProps<{
|
|
72
|
+
appLinks?: boolean
|
|
73
|
+
readImage?: ReadMarkdownImage
|
|
74
|
+
openLocalFile?: OpenMarkdownLocalFile
|
|
75
|
+
localFileExists?: MarkdownLocalFileExists
|
|
76
|
+
openSession?: (id: string) => void
|
|
77
|
+
sessionTitle?: (id: string) => string | undefined
|
|
78
|
+
sessionMenu?: SessionReferenceMenu
|
|
79
|
+
/** Content for code blocks; inherited when omitted. `false` turns it off below, e.g. inside such content. */
|
|
80
|
+
codeBlocks?: MarkdownCodeBlocks | false
|
|
81
|
+
/** Whether code blocks wrap long lines by default; inherited when omitted. Each block can still switch. */
|
|
82
|
+
codeWrap?: boolean
|
|
83
|
+
}>,
|
|
84
|
+
) {
|
|
85
|
+
const parent = useMarkdown()
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<context.Provider
|
|
89
|
+
value={{
|
|
90
|
+
get appLinks() {
|
|
91
|
+
return props.appLinks ?? parent?.appLinks
|
|
92
|
+
},
|
|
93
|
+
get readImage() {
|
|
94
|
+
return props.readImage
|
|
95
|
+
},
|
|
96
|
+
get openLocalFile() {
|
|
97
|
+
return props.openLocalFile
|
|
98
|
+
},
|
|
99
|
+
get localFileExists() {
|
|
100
|
+
return props.localFileExists ?? parent?.localFileExists
|
|
101
|
+
},
|
|
102
|
+
get openSession() {
|
|
103
|
+
return props.openSession ?? parent?.openSession
|
|
104
|
+
},
|
|
105
|
+
get sessionTitle() {
|
|
106
|
+
return props.sessionTitle ?? parent?.sessionTitle
|
|
107
|
+
},
|
|
108
|
+
get sessionMenu() {
|
|
109
|
+
return props.sessionMenu ?? parent?.sessionMenu
|
|
110
|
+
},
|
|
111
|
+
get codeBlocks() {
|
|
112
|
+
if (props.codeBlocks === false) return undefined
|
|
113
|
+
|
|
114
|
+
return props.codeBlocks ?? parent?.codeBlocks
|
|
115
|
+
},
|
|
116
|
+
get codeWrap() {
|
|
117
|
+
return props.codeWrap ?? parent?.codeWrap
|
|
118
|
+
},
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
{props.children}
|
|
122
|
+
</context.Provider>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export const useMarkdown = () => useContext(context)
|
|
127
|
+
|
|
128
|
+
/** Provides markdown handlers as they are, e.g. the ones a detached view keeps while another Location is selected. */
|
|
129
|
+
export const MarkdownContext = context
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createContext, useContext, type ParentProps } from "solid-js"
|
|
2
|
+
import type { SiteIconMode } from "../sources/experiment"
|
|
3
|
+
|
|
4
|
+
const context = createContext<{
|
|
5
|
+
readonly enabled: boolean
|
|
6
|
+
readonly icons: SiteIconMode
|
|
7
|
+
readonly open: (from: string) => void
|
|
8
|
+
}>()
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Shows a turn's sources chip, which opens the turn's searches and fetches. `open` receives the ID of the user message
|
|
12
|
+
* that opened the turn. Without this provider no chip shows.
|
|
13
|
+
*/
|
|
14
|
+
export function SourcesProvider(
|
|
15
|
+
props: ParentProps<{ enabled: boolean; icons: SiteIconMode; onOpen: (from: string) => void }>,
|
|
16
|
+
) {
|
|
17
|
+
return (
|
|
18
|
+
<context.Provider
|
|
19
|
+
value={{
|
|
20
|
+
get enabled() {
|
|
21
|
+
return props.enabled
|
|
22
|
+
},
|
|
23
|
+
get icons() {
|
|
24
|
+
return props.icons
|
|
25
|
+
},
|
|
26
|
+
open: (from) => props.onOpen(from),
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
{props.children}
|
|
30
|
+
</context.Provider>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const useSources = () => useContext(context)
|
package/src/document.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type PresentationFileDiff = {
|
|
2
|
+
file?: string
|
|
3
|
+
patch?: string
|
|
4
|
+
before?: string
|
|
5
|
+
after?: string
|
|
6
|
+
additions: number
|
|
7
|
+
deletions: number
|
|
8
|
+
status?: "added" | "deleted" | "modified"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type PresentationFileContent = {
|
|
12
|
+
type: "text" | "binary"
|
|
13
|
+
content: string
|
|
14
|
+
encoding?: "base64"
|
|
15
|
+
mimeType?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type FilePartSourceText = {
|
|
19
|
+
value: string
|
|
20
|
+
start: number
|
|
21
|
+
end: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type FilePartSource =
|
|
25
|
+
| { type: "file"; text: FilePartSourceText; path: string }
|
|
26
|
+
| {
|
|
27
|
+
type: "symbol"
|
|
28
|
+
text: FilePartSourceText
|
|
29
|
+
path: string
|
|
30
|
+
range: { start: { line: number; character: number }; end: { line: number; character: number } }
|
|
31
|
+
name: string
|
|
32
|
+
kind: number
|
|
33
|
+
}
|
|
34
|
+
| { type: "resource"; text: FilePartSourceText; clientName: string; uri: string }
|