@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,129 @@
|
|
|
1
|
+
import { createComputed, createMemo, createSignal, on, onCleanup, onMount, untrack } from "solid-js"
|
|
2
|
+
import {
|
|
3
|
+
createDisclosureState,
|
|
4
|
+
transitionDisclosure,
|
|
5
|
+
viewDisclosure,
|
|
6
|
+
type DisclosureEffect,
|
|
7
|
+
type DisclosureEvent,
|
|
8
|
+
type DisclosureQueue,
|
|
9
|
+
} from "./disclosure-machine"
|
|
10
|
+
|
|
11
|
+
const deferredMounts: Array<() => void> = []
|
|
12
|
+
|
|
13
|
+
let deferredFrame: number | undefined
|
|
14
|
+
|
|
15
|
+
function flushDeferredMounts() {
|
|
16
|
+
// Timeline tools are mounted top-to-bottom, but the viewport starts at the latest turn.
|
|
17
|
+
// Pop from the end so heavy default-open bodies near the bottom become interactive first.
|
|
18
|
+
const mount = deferredMounts.pop()
|
|
19
|
+
deferredFrame = deferredMounts.length > 0 ? requestAnimationFrame(flushDeferredMounts) : undefined
|
|
20
|
+
mount?.()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function scheduleDeferredMount(mount: () => void) {
|
|
24
|
+
deferredMounts.push(mount)
|
|
25
|
+
|
|
26
|
+
if (deferredFrame === undefined)
|
|
27
|
+
deferredFrame = requestAnimationFrame(() => {
|
|
28
|
+
deferredFrame = requestAnimationFrame(flushDeferredMounts)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
return () => {
|
|
32
|
+
const index = deferredMounts.indexOf(mount)
|
|
33
|
+
|
|
34
|
+
if (index >= 0) deferredMounts.splice(index, 1)
|
|
35
|
+
|
|
36
|
+
if (deferredMounts.length > 0 || deferredFrame === undefined) return
|
|
37
|
+
cancelAnimationFrame(deferredFrame)
|
|
38
|
+
deferredFrame = undefined
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function scheduleFrameMount(mount: () => void) {
|
|
43
|
+
const frame = requestAnimationFrame(mount)
|
|
44
|
+
|
|
45
|
+
return () => cancelAnimationFrame(frame)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Open state for a collapsible body, controlled when `open` returns a boolean and uncontrolled otherwise. An
|
|
50
|
+
* uncontrolled one follows `defaultOpen` until the user toggles it. With `defer`, the body mounts a frame after it opens.
|
|
51
|
+
*/
|
|
52
|
+
export function createDisclosure(options: {
|
|
53
|
+
open?: () => boolean | undefined
|
|
54
|
+
defaultOpen?: () => boolean
|
|
55
|
+
forceOpen?: () => boolean
|
|
56
|
+
defer?: () => boolean
|
|
57
|
+
/** How a body that starts open and deferred waits for its first frame. */
|
|
58
|
+
queue?: DisclosureQueue
|
|
59
|
+
locked?: () => boolean
|
|
60
|
+
pending?: () => boolean
|
|
61
|
+
allowOpenWhilePending?: () => boolean
|
|
62
|
+
onOpenChange?: (open: boolean) => void
|
|
63
|
+
}) {
|
|
64
|
+
const props = () => ({
|
|
65
|
+
open: options.open?.(),
|
|
66
|
+
defaultOpen: options.defaultOpen?.() ?? false,
|
|
67
|
+
forceOpen: options.forceOpen?.() ?? false,
|
|
68
|
+
defer: options.defer?.() ?? false,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const capabilities = () => ({
|
|
72
|
+
locked: options.locked?.() ?? false,
|
|
73
|
+
pending: options.pending?.() ?? false,
|
|
74
|
+
allowOpenWhilePending: options.allowOpenWhilePending?.() ?? false,
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const initial = createDisclosureState(untrack(props), options.queue ?? "frame")
|
|
78
|
+
const [state, setState] = createSignal(initial.state)
|
|
79
|
+
const cancels = new Map<number, () => void>()
|
|
80
|
+
|
|
81
|
+
const dispatch = (event: DisclosureEvent) => {
|
|
82
|
+
const next = transitionDisclosure(untrack(state), event)
|
|
83
|
+
|
|
84
|
+
if (next.state !== untrack(state)) setState(next.state)
|
|
85
|
+
next.effects.forEach(run)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const run = (effect: DisclosureEffect) => {
|
|
89
|
+
if (effect.type === "notify") return options.onOpenChange?.(effect.open)
|
|
90
|
+
|
|
91
|
+
if (effect.type === "cancel-mount") {
|
|
92
|
+
cancels.get(effect.attempt)?.()
|
|
93
|
+
cancels.delete(effect.attempt)
|
|
94
|
+
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const ready = () => {
|
|
99
|
+
cancels.delete(effect.attempt)
|
|
100
|
+
dispatch({ type: "mount.ready", attempt: effect.attempt })
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
cancels.set(effect.attempt, (effect.queue === "deferred" ? scheduleDeferredMount : scheduleFrameMount)(ready))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Synchronous, so a closed body never renders as mounted for a pass.
|
|
107
|
+
createComputed(on(props, (value) => dispatch({ type: "props.sync", props: value }), { defer: true }))
|
|
108
|
+
onMount(() => initial.effects.forEach(run))
|
|
109
|
+
onCleanup(() => dispatch({ type: "disposed" }))
|
|
110
|
+
|
|
111
|
+
const view = createMemo(() => viewDisclosure(state(), capabilities()))
|
|
112
|
+
const open = () => view().open
|
|
113
|
+
|
|
114
|
+
const setOpen = (value: boolean) =>
|
|
115
|
+
dispatch({
|
|
116
|
+
type: "toggle.requested",
|
|
117
|
+
open: value,
|
|
118
|
+
defer: untrack(props).defer,
|
|
119
|
+
capabilities: untrack(capabilities),
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
open,
|
|
124
|
+
mounted: () => view().mounted,
|
|
125
|
+
canToggle: () => view().canToggle,
|
|
126
|
+
setOpen,
|
|
127
|
+
toggle: () => setOpen(!untrack(open)),
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Button } from "@zyro-sec/ui/button"
|
|
2
|
+
import { DockPrompt } from "./dock-prompt"
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: "OpenCode/Requests/Prompt frame",
|
|
6
|
+
id: "components-dock-prompt",
|
|
7
|
+
component: DockPrompt,
|
|
8
|
+
args: { experimental: false },
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: {
|
|
11
|
+
description: {
|
|
12
|
+
component:
|
|
13
|
+
"The shared production frame for active questions and permission requests. Complete interactive examples live under Session/Complete workspace.",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Question = {
|
|
20
|
+
args: { prompt: "Which Session layout should I implement?", hint: "Select one answer" },
|
|
21
|
+
render: (args: { experimental: boolean; prompt: string; hint: string }) => (
|
|
22
|
+
<DockPrompt
|
|
23
|
+
kind="question"
|
|
24
|
+
variant={args.experimental ? "experimental" : undefined}
|
|
25
|
+
header={
|
|
26
|
+
<>
|
|
27
|
+
<div data-slot="question-header-top">
|
|
28
|
+
<div data-slot="question-header-title">Question</div>
|
|
29
|
+
</div>
|
|
30
|
+
<div data-slot="question-details">
|
|
31
|
+
<div data-slot="question-text">{args.prompt}</div>
|
|
32
|
+
<div data-slot="question-hint">{args.hint}</div>
|
|
33
|
+
</div>
|
|
34
|
+
</>
|
|
35
|
+
}
|
|
36
|
+
footer={
|
|
37
|
+
<>
|
|
38
|
+
<Button size="large" variant="ghost">
|
|
39
|
+
Dismiss
|
|
40
|
+
</Button>
|
|
41
|
+
<Button size="large" variant="submit">
|
|
42
|
+
Submit
|
|
43
|
+
</Button>
|
|
44
|
+
</>
|
|
45
|
+
}
|
|
46
|
+
>
|
|
47
|
+
<div data-slot="question-options" />
|
|
48
|
+
</DockPrompt>
|
|
49
|
+
),
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const Permission = {
|
|
53
|
+
args: { command: "npm publish --tag canary" },
|
|
54
|
+
render: (args: { experimental: boolean; command: string }) => (
|
|
55
|
+
<DockPrompt
|
|
56
|
+
kind="permission"
|
|
57
|
+
variant={args.experimental ? "experimental" : undefined}
|
|
58
|
+
header={<div class="text-13-medium text-text-strong">Permission required</div>}
|
|
59
|
+
footer={
|
|
60
|
+
<>
|
|
61
|
+
<Button size="normal" variant="ghost">
|
|
62
|
+
Deny
|
|
63
|
+
</Button>
|
|
64
|
+
<Button size="normal" variant="contrast">
|
|
65
|
+
Allow once
|
|
66
|
+
</Button>
|
|
67
|
+
</>
|
|
68
|
+
}
|
|
69
|
+
>
|
|
70
|
+
<code class="text-12-regular text-text-base">{args.command}</code>
|
|
71
|
+
</DockPrompt>
|
|
72
|
+
),
|
|
73
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { JSX } from "solid-js"
|
|
2
|
+
|
|
3
|
+
export function DockPrompt(props: {
|
|
4
|
+
kind: "question" | "permission"
|
|
5
|
+
variant?: "experimental"
|
|
6
|
+
header: JSX.Element
|
|
7
|
+
children: JSX.Element
|
|
8
|
+
footer: JSX.Element
|
|
9
|
+
ref?: (el: HTMLDivElement) => void
|
|
10
|
+
onKeyDown?: JSX.EventHandlerUnion<HTMLDivElement, KeyboardEvent>
|
|
11
|
+
}) {
|
|
12
|
+
const slot = (name: string) => `${props.kind}-${name}`
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
data-component="dock-prompt"
|
|
17
|
+
data-kind={props.kind}
|
|
18
|
+
data-variant={props.variant}
|
|
19
|
+
ref={props.ref}
|
|
20
|
+
onKeyDown={props.onKeyDown}
|
|
21
|
+
>
|
|
22
|
+
<div data-slot={slot("body")}>
|
|
23
|
+
<div data-slot={slot("header")}>{props.header}</div>
|
|
24
|
+
<div data-slot={slot("content")}>{props.children}</div>
|
|
25
|
+
</div>
|
|
26
|
+
<div data-slot={slot("footer")}>{props.footer}</div>
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { SelectedLineRange } from "@pierre/diffs"
|
|
2
|
+
import { createMemo, createSignal, onCleanup, Show, untrack } from "solid-js"
|
|
3
|
+
import { Portal } from "solid-js/web"
|
|
4
|
+
import { makeEventListener } from "@solid-primitives/event-listener"
|
|
5
|
+
import { createMediaQuery } from "@solid-primitives/media"
|
|
6
|
+
import { createResizeObserver } from "@solid-primitives/resize-observer"
|
|
7
|
+
import { Button } from "@zyro-sec/ui/button"
|
|
8
|
+
import { useI18n } from "@zyro-sec/ui/context/i18n"
|
|
9
|
+
import {
|
|
10
|
+
createCommentSelectionState,
|
|
11
|
+
selectCommentSelectionToolbar,
|
|
12
|
+
transitionCommentSelection,
|
|
13
|
+
type CommentSelectionEffect,
|
|
14
|
+
type CommentSelectionEvent,
|
|
15
|
+
type CommentSelectionSample,
|
|
16
|
+
} from "../pierre/comment-selection-machine"
|
|
17
|
+
|
|
18
|
+
const RELEASED: CommentSelectionEvent = Object.freeze({ type: "pointer.released" })
|
|
19
|
+
|
|
20
|
+
const CHANGED: CommentSelectionEvent = Object.freeze({ type: "selection.changed" })
|
|
21
|
+
|
|
22
|
+
const MOVED: CommentSelectionEvent = Object.freeze({ type: "layout.changed" })
|
|
23
|
+
|
|
24
|
+
/** Offers to comment on text selected in a file or diff viewer, like the timeline's Quote button. */
|
|
25
|
+
export function FileCommentSelection(props: {
|
|
26
|
+
wrapper: HTMLElement
|
|
27
|
+
sample: () => CommentSelectionSample | undefined
|
|
28
|
+
onComment: (range: SelectedLineRange) => void
|
|
29
|
+
}) {
|
|
30
|
+
const i18n = useI18n()
|
|
31
|
+
const [state, setState] = createSignal(createCommentSelectionState())
|
|
32
|
+
let element: HTMLElement | undefined
|
|
33
|
+
let settleTimer: ReturnType<typeof setTimeout> | undefined
|
|
34
|
+
let placeFrame: number | undefined
|
|
35
|
+
|
|
36
|
+
const run = (effect: CommentSelectionEffect) => {
|
|
37
|
+
if (effect.type === "schedule-settle") {
|
|
38
|
+
clearTimeout(settleTimer)
|
|
39
|
+
settleTimer = setTimeout(() => {
|
|
40
|
+
settleTimer = undefined
|
|
41
|
+
dispatch({ type: "settle.sampled", attempt: effect.attempt, sample: props.sample() })
|
|
42
|
+
}, effect.delayMs)
|
|
43
|
+
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (effect.type === "cancel-settle") {
|
|
48
|
+
clearTimeout(settleTimer)
|
|
49
|
+
settleTimer = undefined
|
|
50
|
+
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (effect.type === "schedule-place") {
|
|
55
|
+
if (placeFrame !== undefined) cancelAnimationFrame(placeFrame)
|
|
56
|
+
placeFrame = requestAnimationFrame(() => {
|
|
57
|
+
placeFrame = undefined
|
|
58
|
+
dispatch({ type: "place.sampled", attempt: effect.attempt, sample: props.sample() })
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (effect.type === "cancel-place") {
|
|
65
|
+
if (placeFrame !== undefined) cancelAnimationFrame(placeFrame)
|
|
66
|
+
placeFrame = undefined
|
|
67
|
+
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (effect.type === "clear-selection") return window.getSelection()?.removeAllRanges()
|
|
72
|
+
|
|
73
|
+
props.onComment(effect.range)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const dispatch = (event: CommentSelectionEvent) =>
|
|
77
|
+
untrack(() => {
|
|
78
|
+
const step = transitionCommentSelection(state(), event)
|
|
79
|
+
|
|
80
|
+
if (step.state !== state()) setState(step.state)
|
|
81
|
+
step.effects.forEach(run)
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
// Touch screens show their own menu over the selection.
|
|
85
|
+
const docked = createMediaQuery("(hover: none)")
|
|
86
|
+
const toolbar = createMemo(() => selectCommentSelectionToolbar(state(), docked()))
|
|
87
|
+
|
|
88
|
+
const inside = (target: EventTarget | null) => target instanceof Node && !!element?.contains(target)
|
|
89
|
+
|
|
90
|
+
makeEventListener(document, "pointerdown", (event) => {
|
|
91
|
+
if (inside(event.target)) return
|
|
92
|
+
dispatch({ type: "pointer.down", button: event.button, inside: event.composedPath().includes(props.wrapper) })
|
|
93
|
+
})
|
|
94
|
+
// A cancelled touch, a long-press or Ctrl+click menu, or leaving the window can end a press without `pointerup`.
|
|
95
|
+
makeEventListener(document, "pointerup", () => dispatch(RELEASED))
|
|
96
|
+
makeEventListener(document, "pointercancel", () => dispatch(RELEASED))
|
|
97
|
+
makeEventListener(document, "contextmenu", () => dispatch(RELEASED))
|
|
98
|
+
makeEventListener(window, "blur", () => dispatch(RELEASED))
|
|
99
|
+
makeEventListener(document, "selectionchange", () => dispatch(CHANGED))
|
|
100
|
+
makeEventListener(document, "keydown", (event) => {
|
|
101
|
+
if (event.key === "Escape" && !event.defaultPrevented) dispatch({ type: "escape" })
|
|
102
|
+
})
|
|
103
|
+
makeEventListener(document, "scroll", () => dispatch(MOVED), { capture: true, passive: true })
|
|
104
|
+
makeEventListener(window, "resize", () => dispatch(MOVED))
|
|
105
|
+
createResizeObserver(
|
|
106
|
+
() => props.wrapper,
|
|
107
|
+
() => dispatch(MOVED),
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
onCleanup(() => dispatch({ type: "disposed" }))
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Show when={toolbar()}>
|
|
114
|
+
{(view) => (
|
|
115
|
+
<Portal>
|
|
116
|
+
<div
|
|
117
|
+
ref={(value) => {
|
|
118
|
+
element = value
|
|
119
|
+
createResizeObserver(value, () =>
|
|
120
|
+
dispatch({ type: "toolbar.measured", size: { width: value.offsetWidth, height: value.offsetHeight } }),
|
|
121
|
+
)
|
|
122
|
+
onCleanup(() => {
|
|
123
|
+
element = undefined
|
|
124
|
+
})
|
|
125
|
+
}}
|
|
126
|
+
data-component="file-comment-selection"
|
|
127
|
+
data-prevent-autofocus
|
|
128
|
+
role="toolbar"
|
|
129
|
+
aria-label={i18n.t("ui.lineComment.actions")}
|
|
130
|
+
class="fixed z-50 flex items-center gap-0.5 rounded-[8px] p-0.5 shadow-[var(--v2-elevation-raised)]"
|
|
131
|
+
style={{
|
|
132
|
+
top: `${view().place.top}px`,
|
|
133
|
+
left: `${view().place.left}px`,
|
|
134
|
+
visibility: view().measured ? undefined : "hidden",
|
|
135
|
+
}}
|
|
136
|
+
onMouseDown={(event) => event.preventDefault()}
|
|
137
|
+
>
|
|
138
|
+
<Button size="small" variant="ghost" icon="comment" onClick={() => dispatch({ type: "comment.added" })}>
|
|
139
|
+
{i18n.t("ui.lineComment.add")}
|
|
140
|
+
</Button>
|
|
141
|
+
</div>
|
|
142
|
+
</Portal>
|
|
143
|
+
)}
|
|
144
|
+
</Show>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export const FILE_MEDIA_READ_TIMEOUT_MS = 15_000
|
|
2
|
+
|
|
3
|
+
export type RemoteMediaKind = "image" | "audio"
|
|
4
|
+
|
|
5
|
+
export type LoadedMedia = {
|
|
6
|
+
readonly src: string
|
|
7
|
+
readonly mime: string | undefined
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type RemoteMediaTarget = {
|
|
11
|
+
readonly key: string
|
|
12
|
+
readonly kind: RemoteMediaKind
|
|
13
|
+
readonly path: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A remote image or audio read. `loading` carries the media a same-file refresh replaces, so a refresh that fails or
|
|
18
|
+
* hangs keeps showing it; `attempt` lets only the latest read and its own timeout settle the load.
|
|
19
|
+
*/
|
|
20
|
+
export type FileMediaState =
|
|
21
|
+
| { readonly status: "idle"; readonly attempt: number }
|
|
22
|
+
| {
|
|
23
|
+
readonly status: "loading"
|
|
24
|
+
readonly attempt: number
|
|
25
|
+
readonly key: string
|
|
26
|
+
readonly kind: RemoteMediaKind
|
|
27
|
+
readonly previous: LoadedMedia | undefined
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
readonly status: "ready"
|
|
31
|
+
readonly attempt: number
|
|
32
|
+
readonly key: string
|
|
33
|
+
readonly kind: RemoteMediaKind
|
|
34
|
+
readonly media: LoadedMedia
|
|
35
|
+
}
|
|
36
|
+
| { readonly status: "failed"; readonly attempt: number; readonly key: string; readonly kind: RemoteMediaKind }
|
|
37
|
+
| { readonly status: "disposed" }
|
|
38
|
+
|
|
39
|
+
export type FileMediaEvent =
|
|
40
|
+
| { readonly type: "request.changed"; readonly target: RemoteMediaTarget | undefined }
|
|
41
|
+
| { readonly type: "read.succeeded"; readonly attempt: number; readonly media: LoadedMedia }
|
|
42
|
+
| { readonly type: "read.failed"; readonly attempt: number }
|
|
43
|
+
| { readonly type: "read.timed-out"; readonly attempt: number }
|
|
44
|
+
| { readonly type: "disposed" }
|
|
45
|
+
|
|
46
|
+
export type FileMediaEffect =
|
|
47
|
+
| { readonly type: "read-file"; readonly attempt: number; readonly kind: RemoteMediaKind; readonly path: string }
|
|
48
|
+
| { readonly type: "arm-timeout"; readonly attempt: number; readonly delayMs: number }
|
|
49
|
+
| { readonly type: "clear-timeout" }
|
|
50
|
+
| { readonly type: "notify-error"; readonly kind: RemoteMediaKind }
|
|
51
|
+
|
|
52
|
+
export type FileMediaTransition = {
|
|
53
|
+
readonly state: FileMediaState
|
|
54
|
+
readonly effects: readonly FileMediaEffect[]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const INITIAL_FILE_MEDIA_STATE: FileMediaState = Object.freeze({ status: "idle", attempt: 0 })
|
|
58
|
+
|
|
59
|
+
export const DISPOSED_FILE_MEDIA_STATE: FileMediaState = Object.freeze({ status: "disposed" })
|
|
60
|
+
|
|
61
|
+
export const DISPOSED_FILE_MEDIA_EVENT: FileMediaEvent = Object.freeze({ type: "disposed" })
|
|
62
|
+
|
|
63
|
+
const NO_EFFECTS: readonly FileMediaEffect[] = Object.freeze([])
|
|
64
|
+
|
|
65
|
+
const CLEAR_TIMEOUT: FileMediaEffect = Object.freeze({ type: "clear-timeout" })
|
|
66
|
+
|
|
67
|
+
const CLEAR_ONLY: readonly FileMediaEffect[] = Object.freeze([CLEAR_TIMEOUT])
|
|
68
|
+
|
|
69
|
+
export function transitionFileMedia(state: FileMediaState, event: FileMediaEvent): FileMediaTransition {
|
|
70
|
+
if (state.status === "disposed") return { state, effects: NO_EFFECTS }
|
|
71
|
+
|
|
72
|
+
if (event.type === "disposed")
|
|
73
|
+
return { state: DISPOSED_FILE_MEDIA_STATE, effects: state.status === "loading" ? CLEAR_ONLY : NO_EFFECTS }
|
|
74
|
+
|
|
75
|
+
if (event.type === "request.changed") return request(state, event.target)
|
|
76
|
+
|
|
77
|
+
if (state.status !== "loading" || event.attempt !== state.attempt) return { state, effects: NO_EFFECTS }
|
|
78
|
+
|
|
79
|
+
if (event.type === "read.succeeded")
|
|
80
|
+
return {
|
|
81
|
+
state: { status: "ready", attempt: state.attempt, key: state.key, kind: state.kind, media: event.media },
|
|
82
|
+
effects: CLEAR_ONLY,
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The timer already fired, so only a failed read has one to clear.
|
|
86
|
+
const clear = event.type === "read.failed" ? CLEAR_ONLY : NO_EFFECTS
|
|
87
|
+
|
|
88
|
+
if (state.previous)
|
|
89
|
+
return {
|
|
90
|
+
state: { status: "ready", attempt: state.attempt, key: state.key, kind: state.kind, media: state.previous },
|
|
91
|
+
effects: clear,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
state: { status: "failed", attempt: state.attempt, key: state.key, kind: state.kind },
|
|
96
|
+
effects: [...clear, { type: "notify-error", kind: state.kind }],
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function request(
|
|
101
|
+
state: Exclude<FileMediaState, { status: "disposed" }>,
|
|
102
|
+
target: RemoteMediaTarget | undefined,
|
|
103
|
+
): FileMediaTransition {
|
|
104
|
+
if (!target) {
|
|
105
|
+
if (state.status === "idle") return { state, effects: NO_EFFECTS }
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
state: { status: "idle", attempt: state.attempt },
|
|
109
|
+
effects: state.status === "loading" ? CLEAR_ONLY : NO_EFFECTS,
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const attempt = state.attempt + 1
|
|
114
|
+
const previous = sameFileMedia(state, target.key)
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
state: { status: "loading", attempt, key: target.key, kind: target.kind, previous },
|
|
118
|
+
effects: [
|
|
119
|
+
...(state.status === "loading" ? CLEAR_ONLY : NO_EFFECTS),
|
|
120
|
+
{ type: "read-file", attempt, kind: target.kind, path: target.path },
|
|
121
|
+
{ type: "arm-timeout", attempt, delayMs: FILE_MEDIA_READ_TIMEOUT_MS },
|
|
122
|
+
],
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// A re-read of the same file (a VCS diff refresh) keeps what it already shows; another file starts blank.
|
|
127
|
+
function sameFileMedia(state: Exclude<FileMediaState, { status: "disposed" }>, key: string) {
|
|
128
|
+
if (state.status === "ready" && state.key === key) return state.media
|
|
129
|
+
|
|
130
|
+
if (state.status === "loading" && state.key === key) return state.previous
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type FileMediaView = {
|
|
134
|
+
readonly status: "idle" | "loading" | "error" | "ready"
|
|
135
|
+
readonly src: string | undefined
|
|
136
|
+
readonly mime: string | undefined
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const IDLE_VIEW: FileMediaView = Object.freeze({ status: "idle", src: undefined, mime: undefined })
|
|
140
|
+
|
|
141
|
+
const LOADING_VIEW: FileMediaView = Object.freeze({ status: "loading", src: undefined, mime: undefined })
|
|
142
|
+
|
|
143
|
+
const ERROR_VIEW: FileMediaView = Object.freeze({ status: "error", src: undefined, mime: undefined })
|
|
144
|
+
|
|
145
|
+
/** `direct` is media already in the props; `targetKey` is the read the current props ask for. */
|
|
146
|
+
export function viewFileMedia(
|
|
147
|
+
state: FileMediaState,
|
|
148
|
+
direct: string | undefined,
|
|
149
|
+
targetKey: string | undefined,
|
|
150
|
+
): FileMediaView {
|
|
151
|
+
if (direct) return { status: "ready", src: direct, mime: undefined }
|
|
152
|
+
|
|
153
|
+
if (!targetKey) return IDLE_VIEW
|
|
154
|
+
|
|
155
|
+
// Before the effect dispatches a new key, the state still describes the previous file: never show its media.
|
|
156
|
+
if (state.status === "idle" || state.status === "disposed" || state.key !== targetKey) return LOADING_VIEW
|
|
157
|
+
|
|
158
|
+
if (state.status === "failed") return ERROR_VIEW
|
|
159
|
+
|
|
160
|
+
const media = state.status === "ready" ? state.media : state.previous
|
|
161
|
+
|
|
162
|
+
if (!media) return LOADING_VIEW
|
|
163
|
+
|
|
164
|
+
return { status: "ready", src: media.src, mime: media.mime }
|
|
165
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Button } from "@zyro-sec/ui/button"
|
|
2
|
+
import { FileComponentProvider } from "@zyro-sec/ui/context/file"
|
|
3
|
+
import { createMemo, createSignal, onCleanup, Show } from "solid-js"
|
|
4
|
+
import audio from "@zyro-sec/ui/audio/alert-03.mp3?inline"
|
|
5
|
+
import image from "../../../ui/src/assets/favicon/web-app-manifest-192x192.png?inline"
|
|
6
|
+
import type { PresentationFileContent, PresentationFileDiff } from "../file-presentation"
|
|
7
|
+
import { File } from "./file"
|
|
8
|
+
import { SessionReview } from "./session-review"
|
|
9
|
+
|
|
10
|
+
const states = ["ready", "loading", "unavailable", "failed", "deleted"] as const
|
|
11
|
+
|
|
12
|
+
type Args = { kind: "image" | "audio"; state: (typeof states)[number] }
|
|
13
|
+
|
|
14
|
+
function MediaReview(props: Args) {
|
|
15
|
+
const path = props.kind === "image" ? "assets/app-icon.png" : "assets/notification.mp3"
|
|
16
|
+
|
|
17
|
+
const payload: PresentationFileContent = {
|
|
18
|
+
type: "binary",
|
|
19
|
+
encoding: "base64",
|
|
20
|
+
mimeType: props.kind === "image" ? "image/png" : "audio/mpeg",
|
|
21
|
+
content: (props.kind === "image" ? image : audio).split(",")[1]!,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// A Git LFS pointer is a text diff. Review expands it and FileMedia reads the underlying asset by path.
|
|
25
|
+
const pointer = (hash: string) =>
|
|
26
|
+
`version https://git-lfs.github.com/spec/v1\noid sha256:${hash.repeat(64)}\nsize 8102\n`
|
|
27
|
+
|
|
28
|
+
const diffs: PresentationFileDiff[] = [
|
|
29
|
+
{
|
|
30
|
+
file: path,
|
|
31
|
+
status: props.state === "deleted" ? "deleted" : "modified",
|
|
32
|
+
before: pointer("0"),
|
|
33
|
+
after: props.state === "deleted" ? "" : pointer("1"),
|
|
34
|
+
additions: props.state === "deleted" ? 0 : 1,
|
|
35
|
+
deletions: props.state === "deleted" ? 3 : 1,
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
const [state, setState] = createSignal(props.state)
|
|
40
|
+
|
|
41
|
+
let finish: ((content?: PresentationFileContent) => void) | undefined
|
|
42
|
+
|
|
43
|
+
onCleanup(() => finish?.())
|
|
44
|
+
|
|
45
|
+
const readFile = createMemo(() => {
|
|
46
|
+
const scenario = state()
|
|
47
|
+
|
|
48
|
+
if (scenario === "unavailable" || scenario === "deleted") return undefined
|
|
49
|
+
|
|
50
|
+
return async (file: string) => {
|
|
51
|
+
if (file !== path) return
|
|
52
|
+
|
|
53
|
+
if (scenario === "failed") throw new Error(`Could not read ${file}`)
|
|
54
|
+
|
|
55
|
+
if (scenario === "loading")
|
|
56
|
+
return new Promise<PresentationFileContent | undefined>((resolve) => {
|
|
57
|
+
finish = resolve
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
return payload
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const complete = () => {
|
|
65
|
+
finish?.(payload)
|
|
66
|
+
setState("ready")
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<FileComponentProvider component={File}>
|
|
71
|
+
<div class="mx-auto h-[min(70dvh,480px)] w-full max-w-[800px]">
|
|
72
|
+
<SessionReview
|
|
73
|
+
title="Session changes"
|
|
74
|
+
diffs={diffs}
|
|
75
|
+
open={[path]}
|
|
76
|
+
readFile={readFile()}
|
|
77
|
+
actions={
|
|
78
|
+
<Show when={state() === "loading" || state() === "failed"}>
|
|
79
|
+
<Button size="small" variant="neutral" onClick={complete}>
|
|
80
|
+
{state() === "failed" ? "Retry read" : "Complete read"}
|
|
81
|
+
</Button>
|
|
82
|
+
</Show>
|
|
83
|
+
}
|
|
84
|
+
/>
|
|
85
|
+
</div>
|
|
86
|
+
</FileComponentProvider>
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default {
|
|
91
|
+
title: "OpenCode/Review/File media",
|
|
92
|
+
id: "review-file-media",
|
|
93
|
+
args: { kind: "image", state: "ready" } satisfies Args,
|
|
94
|
+
argTypes: { kind: { options: ["image", "audio"] }, state: { options: states } },
|
|
95
|
+
render: (args: Args) => (
|
|
96
|
+
<Show when={{ kind: args.kind, state: args.state }} keyed>
|
|
97
|
+
{(scenario) => <MediaReview {...scenario} />}
|
|
98
|
+
</Show>
|
|
99
|
+
),
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const ImagePreview = {}
|
|
103
|
+
|
|
104
|
+
export const AudioPreview = { args: { kind: "audio" } }
|
|
105
|
+
|
|
106
|
+
export const Loading = { args: { state: "loading" } }
|
|
107
|
+
|
|
108
|
+
export const Unavailable = { args: { state: "unavailable" } }
|
|
109
|
+
|
|
110
|
+
export const FailedRead = { args: { state: "failed" } }
|
|
111
|
+
|
|
112
|
+
export const Removed = { args: { state: "deleted" } }
|