@zyro-sec/session-ui 0.0.0-stage → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +25 -0
- package/bunfig.toml +2 -0
- package/component-tests/basic-tool.fixture.tsx +46 -0
- package/component-tests/basic-tool.spec.ts +63 -0
- package/component-tests/file-media.fixture.tsx +39 -0
- package/component-tests/file-media.spec.ts +13 -0
- package/component-tests/file-tool.spec.ts +62 -0
- package/component-tests/file-viewer.fixture.tsx +109 -0
- package/component-tests/file-viewer.spec.ts +134 -0
- package/component-tests/file.spec.ts +33 -0
- package/component-tests/line-comment-v2.spec.ts +15 -0
- package/component-tests/markdown-code-wrap.spec.ts +94 -0
- package/component-tests/markdown-readiness.spec.ts +95 -0
- package/component-tests/markdown.fixture.tsx +104 -0
- package/component-tests/markdown.spec.ts +1564 -0
- package/component-tests/mermaid-preview.spec.ts +43 -0
- package/component-tests/patch-group.spec.ts +79 -0
- package/component-tests/read-group.spec.ts +72 -0
- package/component-tests/read-image.fixture.tsx +66 -0
- package/component-tests/read-image.spec.ts +154 -0
- package/component-tests/session-compaction.spec.ts +254 -0
- package/component-tests/session-lifecycle.spec.ts +190 -0
- package/component-tests/session-message-projection.spec.ts +639 -0
- package/component-tests/session-notice-projection.spec.ts +20 -0
- package/component-tests/session-review-comments.spec.ts +179 -0
- package/component-tests/session-shell.spec.ts +93 -0
- package/component-tests/session-timeline-mobile.spec.ts +201 -0
- package/component-tests/session-timeline-notices.spec.ts +38 -0
- package/component-tests/session-timeline-reasoning.spec.ts +107 -0
- package/component-tests/session-timeline.spec.ts +157 -0
- package/component-tests/session-tool-projection.spec.ts +323 -0
- package/component-tests/text-lifecycle.fixture.tsx +26 -0
- package/component-tests/text-lifecycle.spec.ts +42 -0
- package/component-tests/timeline-subagent-rows.spec.ts +33 -0
- package/component-tests/tool-disclosure.spec.ts +48 -0
- package/component-tests/tool-group-sticky.spec.ts +37 -0
- package/component-tests/tool-group.spec.ts +290 -0
- package/component-tests/tool-status-title.fixture.tsx +22 -0
- package/component-tests/tool-status-title.spec.ts +30 -0
- package/component-tests/user-message-quotes.spec.ts +111 -0
- package/package.json +91 -4
- package/playwright.components.config.ts +4 -0
- package/playwright.local.config.ts +2 -0
- package/src/actions.ts +54 -0
- package/src/components/apply-patch-file.ts +122 -0
- package/src/components/basic-tool.css +487 -0
- package/src/components/basic-tool.tsx +258 -0
- package/src/components/copy-machine.ts +78 -0
- package/src/components/copy.ts +85 -0
- package/src/components/diagram-preview.tsx +28 -0
- package/src/components/disclosure-machine.ts +188 -0
- package/src/components/disclosure.ts +129 -0
- package/src/components/dock-prompt.stories.tsx +73 -0
- package/src/components/dock-prompt.tsx +29 -0
- package/src/components/file-comment-selection.tsx +146 -0
- package/src/components/file-media-machine.ts +165 -0
- package/src/components/file-media.stories.tsx +112 -0
- package/src/components/file-media.tsx +323 -0
- package/src/components/file-search.tsx +73 -0
- package/src/components/file.css +59 -0
- package/src/components/file.tsx +1300 -0
- package/src/components/image-preview.tsx +35 -0
- package/src/components/line-comment-annotations.tsx +580 -0
- package/src/components/line-comment-machine.ts +262 -0
- package/src/components/line-comment-styles.ts +293 -0
- package/src/components/line-comment.stories.tsx +152 -0
- package/src/components/line-comment.tsx +448 -0
- package/src/components/link-segments.ts +20 -0
- package/src/components/linked-text.tsx +21 -0
- package/src/components/markdown-cache-machine.ts +257 -0
- package/src/components/markdown-cache.tsx +556 -0
- package/src/components/markdown-clipboard.ts +101 -0
- package/src/components/markdown-code-machine.ts +200 -0
- package/src/components/markdown-code-state.ts +22 -0
- package/src/components/markdown-fragment-links.ts +74 -0
- package/src/components/markdown-github.svg +3 -0
- package/src/components/markdown-globe.svg +5 -0
- package/src/components/markdown-image-machine.ts +170 -0
- package/src/components/markdown-image.ts +156 -0
- package/src/components/markdown-inline-code-kind.ts +39 -0
- package/src/components/markdown-mermaid.ts +18 -0
- package/src/components/markdown-phase-machine.ts +102 -0
- package/src/components/markdown-projection.ts +13 -0
- package/src/components/markdown-session-links.ts +183 -0
- package/src/components/markdown-solid.test.tsx +92 -0
- package/src/components/markdown-solid.tsx +113 -0
- package/src/components/markdown-stream.ts +95 -0
- package/src/components/markdown-worker-machine.ts +516 -0
- package/src/components/markdown-worker-protocol.ts +73 -0
- package/src/components/markdown-worker.ts +250 -0
- package/src/components/markdown.css +672 -0
- package/src/components/markdown.stories.tsx +199 -0
- package/src/components/markdown.tsx +1612 -0
- package/src/components/markdown.worker.ts +188 -0
- package/src/components/message-file.ts +102 -0
- package/src/components/message-nav.css +134 -0
- package/src/components/message-nav.tsx +159 -0
- package/src/components/message-part.css +2109 -0
- package/src/components/message-part.tsx +3 -0
- package/src/components/question-prompt-experimental.css +576 -0
- package/src/components/question-prompt.css +527 -0
- package/src/components/quote-highlight.css +59 -0
- package/src/components/review-focus-driver.ts +142 -0
- package/src/components/review-focus-machine.ts +95 -0
- package/src/components/session-compaction.css +270 -0
- package/src/components/session-diff.ts +358 -0
- package/src/components/session-error.tsx +41 -0
- package/src/components/session-retry.tsx +92 -0
- package/src/components/session-review-machine.ts +241 -0
- package/src/components/session-review.css +264 -0
- package/src/components/session-review.stories.tsx +232 -0
- package/src/components/session-review.tsx +733 -0
- package/src/components/session-turn.css +282 -0
- package/src/components/shell-submessage.css +24 -0
- package/src/components/timeline-separator.tsx +69 -0
- package/src/components/tool-count-label.css +57 -0
- package/src/components/tool-count-label.tsx +76 -0
- package/src/components/tool-count-summary.css +102 -0
- package/src/components/tool-count-summary.stories.tsx +99 -0
- package/src/components/tool-count-summary.tsx +44 -0
- package/src/components/tool-error-card.css +178 -0
- package/src/components/tool-error-card.stories.tsx +113 -0
- package/src/components/tool-error-card.tsx +202 -0
- package/src/components/tool-status-title-machine.ts +128 -0
- package/src/components/tool-status-title.css +89 -0
- package/src/components/tool-status-title.tsx +163 -0
- package/src/context/data.tsx +107 -0
- package/src/context/index.ts +1 -0
- package/src/context/markdown.tsx +129 -0
- package/src/context/sources.tsx +34 -0
- package/src/document.ts +8 -0
- package/src/file-presentation.ts +34 -0
- package/src/message/action-machine.ts +72 -0
- package/src/message/agent-label.ts +3 -0
- package/src/message/attachment-card.css +119 -0
- package/src/message/attachment-card.tsx +40 -0
- package/src/message/attachment-media-machine.ts +213 -0
- package/src/message/comment-card.tsx +155 -0
- package/src/message/compaction-entrance-machine.ts +93 -0
- package/src/message/current-message.tsx +157 -0
- package/src/message/current-tool-state.ts +161 -0
- package/src/message/message-content.tsx +1391 -0
- package/src/message/paced-text-machine.ts +73 -0
- package/src/message/prompt-message.stories.tsx +149 -0
- package/src/message/relative-time.ts +45 -0
- package/src/message/user-message-quote-parts.ts +16 -0
- package/src/message/user-message-quotes.stories.tsx +797 -0
- package/src/message/user-message-quotes.tsx +135 -0
- package/src/pierre/comment-hover-machine.ts +53 -0
- package/src/pierre/comment-hover.ts +131 -0
- package/src/pierre/comment-selection-machine.ts +257 -0
- package/src/pierre/commented-lines.ts +106 -0
- package/src/pierre/diff-selection.ts +91 -0
- package/src/pierre/file-find-machine.ts +323 -0
- package/src/pierre/file-find.ts +537 -0
- package/src/pierre/file-runtime.ts +42 -0
- package/src/pierre/file-selection.ts +140 -0
- package/src/pierre/index.ts +344 -0
- package/src/pierre/media.ts +140 -0
- package/src/pierre/render-machine.ts +381 -0
- package/src/pierre/selection-bridge.ts +82 -0
- package/src/pierre/selection-machine.ts +198 -0
- package/src/pierre/virtualizer.ts +114 -0
- package/src/pierre/worker.ts +46 -0
- package/src/sources/experiment.ts +59 -0
- package/src/sources/site-icon.tsx +53 -0
- package/src/sources/sources-chip.tsx +57 -0
- package/src/sources/sources-expand-machine.ts +101 -0
- package/src/sources/sources-panel.tsx +249 -0
- package/src/sources/sources-title.tsx +21 -0
- package/src/sources/sources.css +266 -0
- package/src/sources/sources.ts +141 -0
- package/src/storybook/current-session-fixtures.ts +1492 -0
- package/src/storybook/current-session-scenarios.ts +76 -0
- package/src/storybook/current-session-story.tsx +154 -0
- package/src/storybook/index.ts +43 -0
- package/src/styles/index.css +19 -0
- package/src/timeline/__snapshots__/group-labels.test.ts.snap +110 -0
- package/src/timeline/__snapshots__/placement.test.ts.snap +1041 -0
- package/src/timeline/code-blocks.stories.tsx +105 -0
- package/src/timeline/commentary.stories.tsx +70 -0
- package/src/timeline/commentary.ts +38 -0
- package/src/timeline/detail.ts +111 -0
- package/src/timeline/error-card.stories.tsx +134 -0
- package/src/timeline/error-spacing.stories.tsx +71 -0
- package/src/timeline/facts.ts +493 -0
- package/src/timeline/file-changes.stories.tsx +436 -0
- package/src/timeline/group-label-fixtures.ts +97 -0
- package/src/timeline/mermaid.stories.tsx +131 -0
- package/src/timeline/place.ts +280 -0
- package/src/timeline/placement-fixtures.ts +365 -0
- package/src/timeline/placement-reactivity.ts +133 -0
- package/src/timeline/projection.ts +1261 -0
- package/src/timeline/research-and-agents.stories.tsx +461 -0
- package/src/timeline/session-timeline-row.tsx +1675 -0
- package/src/timeline/session-timeline.tsx +68 -0
- package/src/timeline/steer-arrival-machine.ts +134 -0
- package/src/timeline/terminal-work.stories.tsx +464 -0
- package/src/timeline/timeline-row.stories.tsx +1069 -0
- package/src/timeline/timeline-row.ts +238 -0
- package/src/timeline/turn-phase-machine.ts +112 -0
- package/src/timeline/user-message-fold.stories.tsx +194 -0
- package/src/timeline/user-runs.ts +87 -0
- package/src/timeline-next/__snapshots__/placement.test.ts.snap +990 -0
- package/src/timeline-next/compaction.tsx +236 -0
- package/src/timeline-next/errors.ts +101 -0
- package/src/timeline-next/event-row.tsx +168 -0
- package/src/timeline-next/events.ts +103 -0
- package/src/timeline-next/index.ts +10 -0
- package/src/timeline-next/nested-rail.ts +125 -0
- package/src/timeline-next/projection.ts +1028 -0
- package/src/timeline-next/row.tsx +1728 -0
- package/src/timeline-next/rules.ts +89 -0
- package/src/timeline-next/separator.tsx +73 -0
- package/src/timeline-next/spacing.ts +127 -0
- package/src/timeline-next/status-line.tsx +41 -0
- package/src/timeline-next/status.ts +33 -0
- package/src/timeline-next/stories/compare-renderer.stories.tsx +190 -0
- package/src/timeline-next/stories/compare-sessions/.gitignore +3 -0
- package/src/timeline-next/stories/compare.stories.tsx +486 -0
- package/src/timeline-next/stories/playground.stories.tsx +297 -0
- package/src/timeline-next/stories/session-replay.ts +1156 -0
- package/src/timeline-next/stories/session-timeline.tsx +50 -0
- package/src/timeline-next/stories/subagent-status.stories.tsx +132 -0
- package/src/timeline-next/timeline-next.css +649 -0
- package/src/timeline-next/tools/__snapshots__/activity-label.test.ts.snap +39 -0
- package/src/timeline-next/tools/activity-label.ts +166 -0
- package/src/timeline-next/tools/assistant-content.tsx +84 -0
- package/src/timeline-next/tools/context-group.tsx +619 -0
- package/src/timeline-next/tools/error-card.tsx +147 -0
- package/src/timeline-next/tools/explore.tsx +119 -0
- package/src/timeline-next/tools/file-group.tsx +128 -0
- package/src/timeline-next/tools/patch.tsx +174 -0
- package/src/timeline-next/tools/shell.tsx +186 -0
- package/src/timeline-next/tools/thought.tsx +87 -0
- package/src/timeline-next/tools/tool-display.tsx +119 -0
- package/src/tools/ansi.ts +8 -0
- package/src/tools/context-group-label.ts +123 -0
- package/src/tools/file-runs.ts +35 -0
- package/src/tools/project-path.ts +18 -0
- package/src/tools/read-group.stories.tsx +159 -0
- package/src/tools/run-machine.ts +185 -0
- package/src/tools/shell-output-machine.ts +233 -0
- package/src/tools/shell-output.ts +91 -0
- package/src/tools/subagent-row-variants.stories.tsx +129 -0
- package/src/tools/tool-group.stories.tsx +345 -0
- package/src/tools/tool-renderer.tsx +2876 -0
- package/src/v2/components/line-comment-annotations-v2.tsx +215 -0
- package/src/v2/components/session-file-panel-v2.tsx +149 -0
- package/src/v2/components/session-progress-indicator-v2.css +5 -0
- package/src/v2/components/session-progress-indicator-v2.stories.tsx +86 -0
- package/src/v2/components/session-progress-indicator-v2.tsx +16 -0
- package/src/v2/components/session-review-empty-changes-v2.tsx +17 -0
- package/src/v2/components/session-review-empty-no-git-v2.tsx +28 -0
- package/src/v2/components/session-review-file-preview-v2-virtualize.ts +5 -0
- package/src/v2/components/session-review-file-preview-v2.tsx +266 -0
- package/src/v2/components/session-review-v2.css +653 -0
- package/src/v2/components/session-review-v2.tsx +422 -0
- package/src/v2/components/sidebar-presence-machine.ts +69 -0
- package/tsconfig.json +20 -0
- package/README.md +0 -3
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import type { PresentationFileContent } from "../file-presentation"
|
|
2
|
+
import { createEffect, createMemo, createSignal, Match, on, onCleanup, Show, Switch, untrack, type JSX } from "solid-js"
|
|
3
|
+
import { useI18n } from "@zyro-sec/ui/context/i18n"
|
|
4
|
+
import {
|
|
5
|
+
DISPOSED_FILE_MEDIA_EVENT,
|
|
6
|
+
INITIAL_FILE_MEDIA_STATE,
|
|
7
|
+
transitionFileMedia,
|
|
8
|
+
viewFileMedia,
|
|
9
|
+
type FileMediaEffect,
|
|
10
|
+
type FileMediaEvent,
|
|
11
|
+
} from "./file-media-machine"
|
|
12
|
+
import {
|
|
13
|
+
dataUrlFromMediaValue,
|
|
14
|
+
hasMediaValue,
|
|
15
|
+
isBinaryContent,
|
|
16
|
+
mediaKindFromPath,
|
|
17
|
+
normalizeMimeType,
|
|
18
|
+
svgTextFromValue,
|
|
19
|
+
} from "../pierre/media"
|
|
20
|
+
|
|
21
|
+
export type FileMediaOptions = {
|
|
22
|
+
mode?: "auto" | "off"
|
|
23
|
+
path?: string
|
|
24
|
+
current?: unknown
|
|
25
|
+
before?: unknown
|
|
26
|
+
after?: unknown
|
|
27
|
+
deleted?: boolean
|
|
28
|
+
readFile?: (path: string) => Promise<PresentationFileContent | undefined>
|
|
29
|
+
onLoad?: () => void
|
|
30
|
+
onError?: (ctx: { kind: "image" | "audio" | "svg" }) => void
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function mediaValue(cfg: FileMediaOptions, mode: "image" | "audio") {
|
|
34
|
+
if (cfg.current !== undefined) return cfg.current
|
|
35
|
+
|
|
36
|
+
if (mode === "image") return cfg.after ?? cfg.before
|
|
37
|
+
|
|
38
|
+
return cfg.after ?? cfg.before
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function FileMedia(props: { media?: FileMediaOptions; fallback: () => JSX.Element }) {
|
|
42
|
+
const i18n = useI18n()
|
|
43
|
+
|
|
44
|
+
let remote = INITIAL_FILE_MEDIA_STATE
|
|
45
|
+
const [remoteState, setRemoteState] = createSignal(remote)
|
|
46
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
47
|
+
|
|
48
|
+
const cfg = () => props.media
|
|
49
|
+
|
|
50
|
+
const kind = createMemo(() => {
|
|
51
|
+
const media = cfg()
|
|
52
|
+
|
|
53
|
+
if (!media || media.mode === "off") return
|
|
54
|
+
|
|
55
|
+
return mediaKindFromPath(media.path)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
const isBinary = createMemo(() => {
|
|
59
|
+
const media = cfg()
|
|
60
|
+
|
|
61
|
+
if (!media || media.mode === "off") return false
|
|
62
|
+
|
|
63
|
+
if (kind()) return false
|
|
64
|
+
|
|
65
|
+
return isBinaryContent(media.current)
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const onLoad = () => props.media?.onLoad?.()
|
|
69
|
+
|
|
70
|
+
const deleted = createMemo(() => {
|
|
71
|
+
const media = cfg()
|
|
72
|
+
const k = kind()
|
|
73
|
+
|
|
74
|
+
if (!media || !k) return false
|
|
75
|
+
|
|
76
|
+
if (media.deleted) return true
|
|
77
|
+
|
|
78
|
+
if (k === "svg") return false
|
|
79
|
+
|
|
80
|
+
if (media.current !== undefined) return false
|
|
81
|
+
|
|
82
|
+
return !hasMediaValue(media.after) && hasMediaValue(media.before)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const direct = createMemo(() => {
|
|
86
|
+
const media = cfg()
|
|
87
|
+
const k = kind()
|
|
88
|
+
|
|
89
|
+
if (!media || (k !== "image" && k !== "audio")) return
|
|
90
|
+
|
|
91
|
+
return dataUrlFromMediaValue(mediaValue(media, k), k)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const request = createMemo(() => {
|
|
95
|
+
const media = cfg()
|
|
96
|
+
const k = kind()
|
|
97
|
+
|
|
98
|
+
if (!media || (k !== "image" && k !== "audio")) return
|
|
99
|
+
|
|
100
|
+
if (media.current !== undefined) return
|
|
101
|
+
|
|
102
|
+
if (deleted()) return
|
|
103
|
+
|
|
104
|
+
if (direct()) return
|
|
105
|
+
|
|
106
|
+
if (!media.path || !media.readFile) return
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
key: `${k}:${media.path}`,
|
|
110
|
+
kind: k,
|
|
111
|
+
path: media.path,
|
|
112
|
+
readFile: media.readFile,
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const dispatch = (event: FileMediaEvent) => {
|
|
117
|
+
const next = transitionFileMedia(remote, event)
|
|
118
|
+
|
|
119
|
+
if (next.state === remote) return
|
|
120
|
+
remote = next.state
|
|
121
|
+
setRemoteState(remote)
|
|
122
|
+
next.effects.forEach(run)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const run = (effect: FileMediaEffect) => {
|
|
126
|
+
if (effect.type === "clear-timeout") {
|
|
127
|
+
clearTimeout(timer)
|
|
128
|
+
timer = undefined
|
|
129
|
+
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (effect.type === "arm-timeout") {
|
|
134
|
+
timer = setTimeout(() => dispatch({ type: "read.timed-out", attempt: effect.attempt }), effect.delayMs)
|
|
135
|
+
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (effect.type === "notify-error") return untrack(cfg)?.onError?.({ kind: effect.kind })
|
|
140
|
+
|
|
141
|
+
const readFile = untrack(request)?.readFile
|
|
142
|
+
|
|
143
|
+
// A read that throws synchronously, rejects or returns no data URL all settle as a failed read.
|
|
144
|
+
void Promise.resolve()
|
|
145
|
+
.then(() => readFile?.(effect.path))
|
|
146
|
+
.then(
|
|
147
|
+
(result) => {
|
|
148
|
+
const src = dataUrlFromMediaValue(result, effect.kind)
|
|
149
|
+
|
|
150
|
+
if (!src) return dispatch({ type: "read.failed", attempt: effect.attempt })
|
|
151
|
+
|
|
152
|
+
const mime = effect.kind === "audio" ? normalizeMimeType(result?.mimeType) : undefined
|
|
153
|
+
dispatch({ type: "read.succeeded", attempt: effect.attempt, media: { src, mime } })
|
|
154
|
+
},
|
|
155
|
+
() => dispatch({ type: "read.failed", attempt: effect.attempt }),
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
createEffect(() => {
|
|
160
|
+
const input = request()
|
|
161
|
+
dispatch({ type: "request.changed", target: input && { key: input.key, kind: input.kind, path: input.path } })
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
onCleanup(() => dispatch(DISPOSED_FILE_MEDIA_EVENT))
|
|
165
|
+
|
|
166
|
+
const view = createMemo(() => viewFileMedia(remoteState(), direct(), request()?.key))
|
|
167
|
+
|
|
168
|
+
const svgSource = createMemo(() => {
|
|
169
|
+
const media = cfg()
|
|
170
|
+
|
|
171
|
+
if (!media || kind() !== "svg") return
|
|
172
|
+
|
|
173
|
+
return svgTextFromValue(media.current)
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
const svgSrc = createMemo(() => {
|
|
177
|
+
const media = cfg()
|
|
178
|
+
|
|
179
|
+
if (!media || kind() !== "svg") return
|
|
180
|
+
|
|
181
|
+
return dataUrlFromMediaValue(media.current, "svg")
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
const svgInvalid = createMemo(() => {
|
|
185
|
+
const media = cfg()
|
|
186
|
+
|
|
187
|
+
if (!media || kind() !== "svg") return
|
|
188
|
+
|
|
189
|
+
if (svgSource() !== undefined) return
|
|
190
|
+
|
|
191
|
+
if (!hasMediaValue(media.current)) return
|
|
192
|
+
|
|
193
|
+
return [media.path, media.current] as const
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
createEffect(
|
|
197
|
+
on(
|
|
198
|
+
svgInvalid,
|
|
199
|
+
(value) => {
|
|
200
|
+
if (!value) return
|
|
201
|
+
cfg()?.onError?.({ kind: "svg" })
|
|
202
|
+
},
|
|
203
|
+
{ defer: true },
|
|
204
|
+
),
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
const kindLabel = (value: "image" | "audio") =>
|
|
208
|
+
i18n.t(value === "image" ? "ui.fileMedia.kind.image" : "ui.fileMedia.kind.audio")
|
|
209
|
+
|
|
210
|
+
return (
|
|
211
|
+
<Switch>
|
|
212
|
+
<Match when={kind() === "image" || kind() === "audio"}>
|
|
213
|
+
<Show
|
|
214
|
+
when={view().src}
|
|
215
|
+
fallback={(() => {
|
|
216
|
+
const media = cfg()
|
|
217
|
+
const k = kind()
|
|
218
|
+
|
|
219
|
+
if (!media || (k !== "image" && k !== "audio")) return props.fallback()
|
|
220
|
+
const label = kindLabel(k)
|
|
221
|
+
|
|
222
|
+
if (deleted()) {
|
|
223
|
+
return (
|
|
224
|
+
<div class="flex min-h-40 items-center justify-center px-6 py-4 text-center text-v2-text-text-faint">
|
|
225
|
+
{i18n.t("ui.fileMedia.state.removed", { kind: label })}
|
|
226
|
+
</div>
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (view().status === "loading") {
|
|
231
|
+
return (
|
|
232
|
+
<div class="flex min-h-40 items-center justify-center px-6 py-4 text-center text-v2-text-text-faint">
|
|
233
|
+
{i18n.t("ui.fileMedia.state.loading", { kind: label })}
|
|
234
|
+
</div>
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (view().status === "error") {
|
|
239
|
+
return (
|
|
240
|
+
<div class="flex min-h-40 items-center justify-center px-6 py-4 text-center text-v2-text-text-faint">
|
|
241
|
+
{i18n.t("ui.fileMedia.state.error", { kind: label })}
|
|
242
|
+
</div>
|
|
243
|
+
)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return (
|
|
247
|
+
<div class="flex min-h-40 items-center justify-center px-6 py-4 text-center text-v2-text-text-faint">
|
|
248
|
+
{i18n.t("ui.fileMedia.state.unavailable", { kind: label })}
|
|
249
|
+
</div>
|
|
250
|
+
)
|
|
251
|
+
})()}
|
|
252
|
+
>
|
|
253
|
+
{(value) => {
|
|
254
|
+
const k = kind()
|
|
255
|
+
|
|
256
|
+
if (k !== "image" && k !== "audio") return props.fallback()
|
|
257
|
+
|
|
258
|
+
if (k === "image") {
|
|
259
|
+
return (
|
|
260
|
+
<div class="flex justify-center bg-background-stronger px-6 py-4">
|
|
261
|
+
<img
|
|
262
|
+
src={value()}
|
|
263
|
+
alt={cfg()?.path}
|
|
264
|
+
class="max-h-[60vh] max-w-full rounded border border-v2-border-border-base bg-background-base object-contain"
|
|
265
|
+
onLoad={onLoad}
|
|
266
|
+
/>
|
|
267
|
+
</div>
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return (
|
|
272
|
+
<div class="flex justify-center bg-background-stronger px-6 py-4">
|
|
273
|
+
<audio class="w-full max-w-xl" controls preload="metadata" onLoadedMetadata={onLoad}>
|
|
274
|
+
<source src={value()} type={view().mime} />
|
|
275
|
+
</audio>
|
|
276
|
+
</div>
|
|
277
|
+
)
|
|
278
|
+
}}
|
|
279
|
+
</Show>
|
|
280
|
+
</Match>
|
|
281
|
+
<Match when={kind() === "svg"}>
|
|
282
|
+
{(() => {
|
|
283
|
+
if (svgSource() === undefined && svgSrc() == null) return props.fallback()
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<div class="flex flex-col gap-4 px-6 py-4">
|
|
287
|
+
<Show when={svgSource() !== undefined}>{props.fallback()}</Show>
|
|
288
|
+
<Show when={svgSrc()}>
|
|
289
|
+
{(value) => (
|
|
290
|
+
<div class="flex justify-center">
|
|
291
|
+
<img
|
|
292
|
+
src={value()}
|
|
293
|
+
alt={cfg()?.path}
|
|
294
|
+
class="max-h-[60vh] max-w-full rounded border border-v2-border-border-base bg-background-base object-contain"
|
|
295
|
+
onLoad={onLoad}
|
|
296
|
+
/>
|
|
297
|
+
</div>
|
|
298
|
+
)}
|
|
299
|
+
</Show>
|
|
300
|
+
</div>
|
|
301
|
+
)
|
|
302
|
+
})()}
|
|
303
|
+
</Match>
|
|
304
|
+
<Match when={isBinary()}>
|
|
305
|
+
<div class="flex min-h-56 flex-col items-center justify-center gap-2 px-6 py-10 text-center">
|
|
306
|
+
<div class="text-14-semibold text-v2-text-text-base">
|
|
307
|
+
{cfg()?.path?.split("/").pop() ?? i18n.t("ui.fileMedia.binary.title")}
|
|
308
|
+
</div>
|
|
309
|
+
<div class="text-14-regular text-v2-text-text-faint">
|
|
310
|
+
{(() => {
|
|
311
|
+
const path = cfg()?.path
|
|
312
|
+
|
|
313
|
+
if (!path) return i18n.t("ui.fileMedia.binary.description.default")
|
|
314
|
+
|
|
315
|
+
return i18n.t("ui.fileMedia.binary.description.path", { path })
|
|
316
|
+
})()}
|
|
317
|
+
</div>
|
|
318
|
+
</div>
|
|
319
|
+
</Match>
|
|
320
|
+
<Match when={true}>{props.fallback()}</Match>
|
|
321
|
+
</Switch>
|
|
322
|
+
)
|
|
323
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Portal } from "solid-js/web"
|
|
2
|
+
import { useI18n } from "@zyro-sec/ui/context/i18n"
|
|
3
|
+
import { Icon } from "@zyro-sec/ui/icon"
|
|
4
|
+
|
|
5
|
+
export function FileSearchBar(props: {
|
|
6
|
+
pos: { top: number; right: number }
|
|
7
|
+
query: string
|
|
8
|
+
index: number
|
|
9
|
+
count: number
|
|
10
|
+
setInput: (el: HTMLInputElement) => void
|
|
11
|
+
onInput: (value: string) => void
|
|
12
|
+
onKeyDown: (event: KeyboardEvent) => void
|
|
13
|
+
onClose: () => void
|
|
14
|
+
onPrev: () => void
|
|
15
|
+
onNext: () => void
|
|
16
|
+
}) {
|
|
17
|
+
const i18n = useI18n()
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Portal>
|
|
21
|
+
<div
|
|
22
|
+
class="fixed z-50 flex h-8 items-center gap-2 rounded-md border border-v2-border-border-base bg-background-base px-3 shadow-md"
|
|
23
|
+
style={{
|
|
24
|
+
top: `${props.pos.top}px`,
|
|
25
|
+
right: `${props.pos.right}px`,
|
|
26
|
+
}}
|
|
27
|
+
onPointerDown={(e) => e.stopPropagation()}
|
|
28
|
+
data-floating-overlay
|
|
29
|
+
>
|
|
30
|
+
<Icon name="magnifying-glass" class="text-v2-icon-icon-muted shrink-0" />
|
|
31
|
+
<input
|
|
32
|
+
ref={props.setInput}
|
|
33
|
+
placeholder={i18n.t("ui.fileSearch.placeholder")}
|
|
34
|
+
value={props.query}
|
|
35
|
+
class="w-40 bg-transparent outline-none text-14-regular text-v2-text-text-base placeholder:text-v2-text-text-faint"
|
|
36
|
+
onInput={(e) => props.onInput(e.currentTarget.value)}
|
|
37
|
+
onKeyDown={props.onKeyDown}
|
|
38
|
+
/>
|
|
39
|
+
<div class="shrink-0 text-12-regular text-v2-text-text-faint tabular-nums text-right" style={{ width: "10ch" }}>
|
|
40
|
+
{props.count ? `${props.index + 1}/${props.count}` : "0/0"}
|
|
41
|
+
</div>
|
|
42
|
+
<div class="flex items-center">
|
|
43
|
+
<button
|
|
44
|
+
type="button"
|
|
45
|
+
class="size-6 grid place-items-center rounded text-v2-icon-icon-muted hover:bg-surface-base-hover hover:text-v2-icon-icon-base disabled:opacity-40 disabled:pointer-events-none"
|
|
46
|
+
disabled={props.count === 0}
|
|
47
|
+
aria-label={i18n.t("ui.fileSearch.previousMatch")}
|
|
48
|
+
onClick={props.onPrev}
|
|
49
|
+
>
|
|
50
|
+
<Icon name="chevron-down" class="rotate-180" />
|
|
51
|
+
</button>
|
|
52
|
+
<button
|
|
53
|
+
type="button"
|
|
54
|
+
class="size-6 grid place-items-center rounded text-v2-icon-icon-muted hover:bg-surface-base-hover hover:text-v2-icon-icon-base disabled:opacity-40 disabled:pointer-events-none"
|
|
55
|
+
disabled={props.count === 0}
|
|
56
|
+
aria-label={i18n.t("ui.fileSearch.nextMatch")}
|
|
57
|
+
onClick={props.onNext}
|
|
58
|
+
>
|
|
59
|
+
<Icon name="chevron-down" />
|
|
60
|
+
</button>
|
|
61
|
+
</div>
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
class="size-6 grid place-items-center rounded text-v2-icon-icon-muted hover:bg-surface-base-hover hover:text-v2-icon-icon-base"
|
|
65
|
+
aria-label={i18n.t("ui.fileSearch.close")}
|
|
66
|
+
onClick={props.onClose}
|
|
67
|
+
>
|
|
68
|
+
<Icon name="close" />
|
|
69
|
+
</button>
|
|
70
|
+
</div>
|
|
71
|
+
</Portal>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[data-component="file"] {
|
|
2
|
+
content-visibility: auto;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/* The viewer takes focus so the keyboard can scroll and search it, and draws no ring. */
|
|
6
|
+
[data-component="file"]:focus-visible {
|
|
7
|
+
outline: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
[data-timeline-row] [data-component="file"] {
|
|
11
|
+
content-visibility: visible;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
[data-component="file"][data-mode="text"] {
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
[data-component="file"][data-mode="diff"] {
|
|
19
|
+
[data-slot="diff-hunk-separator-line-number"] {
|
|
20
|
+
position: sticky;
|
|
21
|
+
left: 0;
|
|
22
|
+
background-color: var(--surface-diff-hidden-strong);
|
|
23
|
+
z-index: 2;
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
|
|
28
|
+
[data-slot="diff-hunk-separator-line-number-icon"] {
|
|
29
|
+
aspect-ratio: 1;
|
|
30
|
+
width: 24px;
|
|
31
|
+
height: 24px;
|
|
32
|
+
color: var(--icon-strong-base);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[data-slot="diff-hunk-separator-content"] {
|
|
37
|
+
position: sticky;
|
|
38
|
+
background-color: var(--surface-diff-hidden-base);
|
|
39
|
+
color: var(--v2-text-text-muted);
|
|
40
|
+
width: var(--diffs-column-content-width);
|
|
41
|
+
left: var(--diffs-column-number-width);
|
|
42
|
+
padding-left: 8px;
|
|
43
|
+
user-select: none;
|
|
44
|
+
cursor: default;
|
|
45
|
+
text-align: left;
|
|
46
|
+
|
|
47
|
+
[data-slot="diff-hunk-separator-content-span"] {
|
|
48
|
+
mix-blend-mode: var(--text-mix-blend-mode);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
[data-component="file-comment-selection"] {
|
|
54
|
+
background-color: var(--v2-background-bg-base);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[data-color-scheme="dark"] [data-component="file-comment-selection"] {
|
|
58
|
+
background-color: var(--v2-background-bg-layer-02);
|
|
59
|
+
}
|