@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,422 @@
|
|
|
1
|
+
import { useI18n } from "@zyro-sec/ui/context/i18n"
|
|
2
|
+
import { SegmentedControlItem, SegmentedControl } from "@zyro-sec/ui/segmented-control"
|
|
3
|
+
import { TextInput } from "@zyro-sec/ui/text-input"
|
|
4
|
+
import { Keybind } from "@zyro-sec/ui/keybind"
|
|
5
|
+
import { Icon } from "@zyro-sec/ui/icon"
|
|
6
|
+
import { IconButton } from "@zyro-sec/ui/icon-button"
|
|
7
|
+
import { Tooltip } from "@zyro-sec/ui/tooltip"
|
|
8
|
+
import type { SessionReviewDiffStyle } from "../../components/session-review"
|
|
9
|
+
import { ResizeHandle } from "@zyro-sec/ui/resize-handle"
|
|
10
|
+
import { useLocale } from "@kobalte/core/i18n"
|
|
11
|
+
import { makeEventListener } from "@solid-primitives/event-listener"
|
|
12
|
+
import { prefersReducedMotion } from "@zyro-sec/ui/motion"
|
|
13
|
+
import { Show, createEffect, createMemo, createSignal, on, onCleanup, untrack, type JSX } from "solid-js"
|
|
14
|
+
import { getWorkerPool } from "../../pierre/worker"
|
|
15
|
+
import {
|
|
16
|
+
SIDEBAR_EXIT_TIMEOUT_MS,
|
|
17
|
+
createSidebarPresenceState,
|
|
18
|
+
selectSidebarMounted,
|
|
19
|
+
transitionSidebarPresence,
|
|
20
|
+
type SidebarPresenceEvent,
|
|
21
|
+
} from "./sidebar-presence-machine"
|
|
22
|
+
import {
|
|
23
|
+
SessionFilePanelV2,
|
|
24
|
+
SessionFilePanelV2Empty,
|
|
25
|
+
type SessionFilePanelV2SidebarSide,
|
|
26
|
+
} from "./session-file-panel-v2"
|
|
27
|
+
|
|
28
|
+
export const SESSION_REVIEW_V2_SIDEBAR_WIDTH_DEFAULT = 240
|
|
29
|
+
|
|
30
|
+
export const SESSION_REVIEW_V2_SIDEBAR_WIDTH_MIN = 200
|
|
31
|
+
|
|
32
|
+
export const SESSION_REVIEW_V2_SIDEBAR_WIDTH_MAX = 480
|
|
33
|
+
|
|
34
|
+
export type SessionReviewExpandMode = "expand" | "collapse"
|
|
35
|
+
|
|
36
|
+
export type SessionReviewV2Props = {
|
|
37
|
+
title?: JSX.Element
|
|
38
|
+
stats?: JSX.Element
|
|
39
|
+
empty?: JSX.Element
|
|
40
|
+
sidebarOpen?: boolean
|
|
41
|
+
sidebar?: JSX.Element
|
|
42
|
+
sidebarToggle?: JSX.Element
|
|
43
|
+
/** Defaults to `start`. */
|
|
44
|
+
sidebarSide?: SessionFilePanelV2SidebarSide
|
|
45
|
+
onSidebarSideChange?: (side: SessionFilePanelV2SidebarSide) => void
|
|
46
|
+
activeFile?: string
|
|
47
|
+
files: string[]
|
|
48
|
+
onSelectFile: (file: string) => void
|
|
49
|
+
diffStyle: SessionReviewDiffStyle
|
|
50
|
+
toolbarAction?: JSX.Element
|
|
51
|
+
onDiffStyleChange?: (style: SessionReviewDiffStyle) => void
|
|
52
|
+
expandMode: SessionReviewExpandMode
|
|
53
|
+
onExpandModeChange: (mode: SessionReviewExpandMode) => void
|
|
54
|
+
preview?: JSX.Element
|
|
55
|
+
hasDiffs: boolean
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type SessionReviewV2SidebarProps = {
|
|
59
|
+
open: boolean
|
|
60
|
+
transition: boolean
|
|
61
|
+
/** The edge of the panel the sidebar sits on, which its resize handle faces away from. Defaults to `start`. */
|
|
62
|
+
side?: SessionFilePanelV2SidebarSide
|
|
63
|
+
title?: JSX.Element
|
|
64
|
+
stats?: JSX.Element
|
|
65
|
+
/** Controls at the header's end, after the stats. */
|
|
66
|
+
actions?: JSX.Element
|
|
67
|
+
filter: string
|
|
68
|
+
onFilterChange: (value: string) => void
|
|
69
|
+
onFilterKeyDown?: JSX.EventHandlerUnion<HTMLInputElement, KeyboardEvent>
|
|
70
|
+
filterAutofocus?: boolean
|
|
71
|
+
filterRef?: (element: HTMLInputElement) => void
|
|
72
|
+
filterControls?: string
|
|
73
|
+
filterActiveDescendant?: string
|
|
74
|
+
filterExpanded?: boolean
|
|
75
|
+
width?: number
|
|
76
|
+
onWidthChange?: (width: number) => void
|
|
77
|
+
minWidth?: number
|
|
78
|
+
maxWidth?: number
|
|
79
|
+
viewportRef?: (element: HTMLDivElement) => void
|
|
80
|
+
children?: JSX.Element
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function SessionReviewV2Sidebar(props: SessionReviewV2SidebarProps) {
|
|
84
|
+
const i18n = useI18n()
|
|
85
|
+
const [resizing, setResizing] = createSignal(false)
|
|
86
|
+
const width = () => props.width ?? SESSION_REVIEW_V2_SIDEBAR_WIDTH_DEFAULT
|
|
87
|
+
const minWidth = () => props.minWidth ?? SESSION_REVIEW_V2_SIDEBAR_WIDTH_MIN
|
|
88
|
+
const maxWidth = () => props.maxWidth ?? SESSION_REVIEW_V2_SIDEBAR_WIDTH_MAX
|
|
89
|
+
const [presence, setPresence] = createSignal(createSidebarPresenceState(untrack(() => props.open)))
|
|
90
|
+
let exitTimer: ReturnType<typeof setTimeout> | undefined
|
|
91
|
+
|
|
92
|
+
const dispatch = (event: SidebarPresenceEvent) => {
|
|
93
|
+
const next = transitionSidebarPresence(untrack(presence), event)
|
|
94
|
+
|
|
95
|
+
setPresence(next.state)
|
|
96
|
+
next.effects.forEach((effect) => {
|
|
97
|
+
clearTimeout(exitTimer)
|
|
98
|
+
exitTimer = setTimeout(
|
|
99
|
+
() => dispatch({ type: "exit.timed-out", attempt: effect.attempt }),
|
|
100
|
+
SIDEBAR_EXIT_TIMEOUT_MS,
|
|
101
|
+
)
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
createEffect(
|
|
106
|
+
on(
|
|
107
|
+
() => props.open,
|
|
108
|
+
(open) =>
|
|
109
|
+
dispatch({ type: "open.changed", open, animate: untrack(() => props.transition) && !prefersReducedMotion() }),
|
|
110
|
+
{ defer: true },
|
|
111
|
+
),
|
|
112
|
+
)
|
|
113
|
+
onCleanup(() => clearTimeout(exitTimer))
|
|
114
|
+
|
|
115
|
+
const closing = () => presence().status === "closing"
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<div data-component="session-review-v2-sidebar-root">
|
|
119
|
+
<Show when={selectSidebarMounted(presence())}>
|
|
120
|
+
<aside
|
|
121
|
+
data-slot="session-review-v2-sidebar"
|
|
122
|
+
data-presence={presence().status}
|
|
123
|
+
data-transition={props.transition ? "" : undefined}
|
|
124
|
+
data-resizing={resizing() ? "" : undefined}
|
|
125
|
+
aria-hidden={closing() || undefined}
|
|
126
|
+
inert={closing() || undefined}
|
|
127
|
+
style={{ "--session-review-v2-sidebar-width": `${width()}px` }}
|
|
128
|
+
onTransitionEnd={(event) => {
|
|
129
|
+
if (event.target === event.currentTarget && event.propertyName === "width") dispatch({ type: "exit.ended" })
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
<div data-slot="session-review-v2-sidebar-header">
|
|
133
|
+
<div data-slot="session-review-v2-sidebar-title">{props.title}</div>
|
|
134
|
+
{props.stats}
|
|
135
|
+
{props.actions}
|
|
136
|
+
</div>
|
|
137
|
+
<div data-slot="session-review-v2-sidebar-filter">
|
|
138
|
+
<TextInput
|
|
139
|
+
type="search"
|
|
140
|
+
value={props.filter}
|
|
141
|
+
onInput={(event) => props.onFilterChange(event.currentTarget.value)}
|
|
142
|
+
onKeyDown={props.onFilterKeyDown}
|
|
143
|
+
autofocus={props.filterAutofocus}
|
|
144
|
+
ref={props.filterRef}
|
|
145
|
+
role={props.filterControls ? "combobox" : undefined}
|
|
146
|
+
aria-autocomplete={props.filterControls ? "list" : undefined}
|
|
147
|
+
aria-controls={props.filterControls}
|
|
148
|
+
aria-activedescendant={props.filterActiveDescendant}
|
|
149
|
+
aria-expanded={props.filterControls ? props.filterExpanded : undefined}
|
|
150
|
+
showClearButton={props.filter.length > 0}
|
|
151
|
+
clearLabel={i18n.t("ui.list.clearFilter")}
|
|
152
|
+
onClearClick={() => props.onFilterChange("")}
|
|
153
|
+
placeholder={i18n.t("ui.sessionReviewV2.filterFiles")}
|
|
154
|
+
aria-label={i18n.t("ui.sessionReviewV2.filterFiles")}
|
|
155
|
+
leadingIcon={
|
|
156
|
+
<svg
|
|
157
|
+
width="14"
|
|
158
|
+
height="14"
|
|
159
|
+
viewBox="0 0 14 14"
|
|
160
|
+
fill="none"
|
|
161
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
162
|
+
aria-hidden="true"
|
|
163
|
+
>
|
|
164
|
+
<path
|
|
165
|
+
d="M12.25 12.25L10.0625 10.0625M11.0833 6.41667C11.0833 8.994 8.994 11.0833 6.41667 11.0833C3.83934 11.0833 1.75 8.994 1.75 6.41667C1.75 3.83934 3.83934 1.75 6.41667 1.75C8.994 1.75 11.0833 3.83934 11.0833 6.41667Z"
|
|
166
|
+
stroke="currentColor"
|
|
167
|
+
stroke-linecap="square"
|
|
168
|
+
/>
|
|
169
|
+
</svg>
|
|
170
|
+
}
|
|
171
|
+
/>
|
|
172
|
+
</div>
|
|
173
|
+
<div data-slot="session-review-v2-sidebar-tree" class="group/file-tree-v2">
|
|
174
|
+
<div
|
|
175
|
+
data-slot="session-review-v2-sidebar-viewport"
|
|
176
|
+
data-scrollable
|
|
177
|
+
ref={(element) => props.viewportRef?.(element)}
|
|
178
|
+
>
|
|
179
|
+
{props.children}
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
</aside>
|
|
183
|
+
</Show>
|
|
184
|
+
<Show when={props.open && props.onWidthChange}>
|
|
185
|
+
<div data-slot="session-review-v2-sidebar-resize">
|
|
186
|
+
<ResizeHandle
|
|
187
|
+
direction="horizontal"
|
|
188
|
+
edge={props.side === "end" ? "start" : "end"}
|
|
189
|
+
size={width()}
|
|
190
|
+
min={minWidth()}
|
|
191
|
+
max={maxWidth()}
|
|
192
|
+
onResize={(next) => props.onWidthChange?.(next)}
|
|
193
|
+
onDraggingChange={setResizing}
|
|
194
|
+
onDblClick={() => props.onWidthChange?.(SESSION_REVIEW_V2_SIDEBAR_WIDTH_DEFAULT)}
|
|
195
|
+
/>
|
|
196
|
+
</div>
|
|
197
|
+
</Show>
|
|
198
|
+
</div>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export function SessionReviewV2(props: SessionReviewV2Props) {
|
|
203
|
+
const i18n = useI18n()
|
|
204
|
+
const locale = useLocale()
|
|
205
|
+
let previousButton: HTMLButtonElement | undefined
|
|
206
|
+
let nextButton: HTMLButtonElement | undefined
|
|
207
|
+
|
|
208
|
+
createEffect(() => {
|
|
209
|
+
getWorkerPool()
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
const fileIndex = () => {
|
|
213
|
+
const files = props.files
|
|
214
|
+
|
|
215
|
+
if (files.length === 0) return -1
|
|
216
|
+
|
|
217
|
+
const active = props.activeFile
|
|
218
|
+
const i = active ? files.indexOf(active) : -1
|
|
219
|
+
|
|
220
|
+
if (i >= 0) return i
|
|
221
|
+
|
|
222
|
+
return 0
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const prev = () => {
|
|
226
|
+
if (!canCycle()) return
|
|
227
|
+
|
|
228
|
+
return props.files[(fileIndex() - 1 + props.files.length) % props.files.length]
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const next = () => {
|
|
232
|
+
if (!canCycle()) return
|
|
233
|
+
|
|
234
|
+
return props.files[(fileIndex() + 1) % props.files.length]
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const canCycle = () => props.files.length > 0
|
|
238
|
+
const previousKey = () => (locale.direction() === "rtl" ? "ArrowRight" : "ArrowLeft")
|
|
239
|
+
const nextKey = () => (locale.direction() === "rtl" ? "ArrowLeft" : "ArrowRight")
|
|
240
|
+
const showCollapsedMeta = () => props.sidebarOpen === false
|
|
241
|
+
// Memoize slot getters so Show conditions do not instantiate throwaway elements.
|
|
242
|
+
const title = createMemo(() => props.title)
|
|
243
|
+
const stats = createMemo(() => props.stats)
|
|
244
|
+
|
|
245
|
+
const cycle = (file: string | undefined) => {
|
|
246
|
+
if (!file) return
|
|
247
|
+
props.onSelectFile(file)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Keep the advertised arrow keys working while the
|
|
251
|
+
// pane is mounted, but never while typing in an input or comment editor.
|
|
252
|
+
makeEventListener(document, "keydown", (event) => {
|
|
253
|
+
if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.altKey) return
|
|
254
|
+
|
|
255
|
+
if (event.key !== previousKey() && event.key !== nextKey()) return
|
|
256
|
+
const target = event.target
|
|
257
|
+
|
|
258
|
+
if (target instanceof HTMLElement && (target.isContentEditable || target.closest("input, textarea, select"))) return
|
|
259
|
+
|
|
260
|
+
if (!props.hasDiffs || !canCycle()) return
|
|
261
|
+
const previous = event.key === previousKey()
|
|
262
|
+
const file = previous ? prev() : next()
|
|
263
|
+
|
|
264
|
+
if (!file) return
|
|
265
|
+
const active = document.activeElement
|
|
266
|
+
|
|
267
|
+
event.preventDefault()
|
|
268
|
+
cycle(file)
|
|
269
|
+
|
|
270
|
+
if (active !== previousButton && active !== nextButton) return
|
|
271
|
+
;(previous ? previousButton : nextButton)?.focus({ preventScroll: true })
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
const toolbarStart = () => (
|
|
275
|
+
<>
|
|
276
|
+
<Show when={showCollapsedMeta()}>
|
|
277
|
+
<div data-slot="session-review-v2-toolbar-collapsed-meta">
|
|
278
|
+
<Show when={title()}>
|
|
279
|
+
<div data-slot="session-review-v2-toolbar-title">{title()}</div>
|
|
280
|
+
</Show>
|
|
281
|
+
{stats()}
|
|
282
|
+
<Show when={canCycle()}>
|
|
283
|
+
<span data-slot="session-review-v2-file-position">
|
|
284
|
+
{fileIndex() + 1}/{props.files.length}
|
|
285
|
+
</span>
|
|
286
|
+
</Show>
|
|
287
|
+
</div>
|
|
288
|
+
</Show>
|
|
289
|
+
<div class="flex items-center">
|
|
290
|
+
<Tooltip
|
|
291
|
+
openDelay={2000}
|
|
292
|
+
inactive={!prev()}
|
|
293
|
+
value={
|
|
294
|
+
<>
|
|
295
|
+
{i18n.t("ui.sessionReviewV2.previousFile")}
|
|
296
|
+
<Keybind keys={[locale.direction() === "rtl" ? "→" : "←"]} variant="neutral" />
|
|
297
|
+
</>
|
|
298
|
+
}
|
|
299
|
+
>
|
|
300
|
+
<IconButton
|
|
301
|
+
ref={previousButton}
|
|
302
|
+
icon={<Icon name="arrow-left" />}
|
|
303
|
+
variant="ghost"
|
|
304
|
+
size="small"
|
|
305
|
+
class="session-review-v2-file-nav-button"
|
|
306
|
+
disabled={!prev()}
|
|
307
|
+
onClick={() => cycle(prev())}
|
|
308
|
+
aria-label={i18n.t("ui.sessionReviewV2.previousFile")}
|
|
309
|
+
/>
|
|
310
|
+
</Tooltip>
|
|
311
|
+
<Tooltip
|
|
312
|
+
openDelay={2000}
|
|
313
|
+
inactive={!next()}
|
|
314
|
+
value={
|
|
315
|
+
<>
|
|
316
|
+
{i18n.t("ui.sessionReviewV2.nextFile")}
|
|
317
|
+
<Keybind keys={[locale.direction() === "rtl" ? "←" : "→"]} variant="neutral" />
|
|
318
|
+
</>
|
|
319
|
+
}
|
|
320
|
+
>
|
|
321
|
+
<IconButton
|
|
322
|
+
ref={nextButton}
|
|
323
|
+
icon={<Icon name="arrow-right" />}
|
|
324
|
+
variant="ghost"
|
|
325
|
+
size="small"
|
|
326
|
+
class="session-review-v2-file-nav-button"
|
|
327
|
+
disabled={!next()}
|
|
328
|
+
onClick={() => cycle(next())}
|
|
329
|
+
aria-label={i18n.t("ui.sessionReviewV2.nextFile")}
|
|
330
|
+
/>
|
|
331
|
+
</Tooltip>
|
|
332
|
+
</div>
|
|
333
|
+
</>
|
|
334
|
+
)
|
|
335
|
+
|
|
336
|
+
const toolbarEnd = () => (
|
|
337
|
+
<>
|
|
338
|
+
{props.toolbarAction}
|
|
339
|
+
<SegmentedControl
|
|
340
|
+
value={props.expandMode}
|
|
341
|
+
onChange={(value) => {
|
|
342
|
+
if (value !== "expand" && value !== "collapse") return
|
|
343
|
+
props.onExpandModeChange(value)
|
|
344
|
+
}}
|
|
345
|
+
class="session-review-v2-segmented-control session-review-v2-segmented-control--icon"
|
|
346
|
+
aria-label={i18n.t("ui.sessionReviewV2.expandMode")}
|
|
347
|
+
>
|
|
348
|
+
<Tooltip openDelay={2000} value={i18n.t("ui.sessionReviewV2.showAllLines")}>
|
|
349
|
+
<SegmentedControlItem value="expand" aria-label={i18n.t("ui.sessionReviewV2.showAllLines")}>
|
|
350
|
+
<Icon name="expand" />
|
|
351
|
+
</SegmentedControlItem>
|
|
352
|
+
</Tooltip>
|
|
353
|
+
<Tooltip openDelay={2000} value={i18n.t("ui.sessionReviewV2.hideNonDiffLines")}>
|
|
354
|
+
<SegmentedControlItem value="collapse" aria-label={i18n.t("ui.sessionReviewV2.hideNonDiffLines")}>
|
|
355
|
+
<Icon name="collapse" />
|
|
356
|
+
</SegmentedControlItem>
|
|
357
|
+
</Tooltip>
|
|
358
|
+
</SegmentedControl>
|
|
359
|
+
<Show when={props.onDiffStyleChange}>
|
|
360
|
+
<SegmentedControl
|
|
361
|
+
value={props.diffStyle}
|
|
362
|
+
onChange={(value) => {
|
|
363
|
+
if (value !== "unified" && value !== "split") return
|
|
364
|
+
props.onDiffStyleChange?.(value)
|
|
365
|
+
}}
|
|
366
|
+
class="session-review-v2-segmented-control session-review-v2-segmented-control--icon"
|
|
367
|
+
aria-label={i18n.t("ui.sessionReviewV2.diffView")}
|
|
368
|
+
>
|
|
369
|
+
<Tooltip openDelay={2000} value={i18n.t("ui.sessionReviewV2.unifiedDiff")}>
|
|
370
|
+
<SegmentedControlItem value="unified" aria-label={i18n.t("ui.sessionReviewV2.unifiedDiff")}>
|
|
371
|
+
<Icon name="unified" />
|
|
372
|
+
</SegmentedControlItem>
|
|
373
|
+
</Tooltip>
|
|
374
|
+
<Tooltip openDelay={2000} value={i18n.t("ui.sessionReviewV2.splitDiff")}>
|
|
375
|
+
<SegmentedControlItem value="split" aria-label={i18n.t("ui.sessionReviewV2.splitDiff")}>
|
|
376
|
+
<Icon name="split" />
|
|
377
|
+
</SegmentedControlItem>
|
|
378
|
+
</Tooltip>
|
|
379
|
+
</SegmentedControl>
|
|
380
|
+
</Show>
|
|
381
|
+
</>
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
return (
|
|
385
|
+
<SessionFilePanelV2
|
|
386
|
+
sidebar={props.sidebar}
|
|
387
|
+
sidebarToggle={props.sidebarToggle}
|
|
388
|
+
sidebarCollapsed={props.sidebarOpen === false}
|
|
389
|
+
sidebarSide={props.sidebarSide}
|
|
390
|
+
onSidebarSideChange={props.onSidebarSideChange}
|
|
391
|
+
toolbar={props.hasDiffs || props.sidebarOpen === false}
|
|
392
|
+
toolbarStart={toolbarStart()}
|
|
393
|
+
toolbarEnd={toolbarEnd()}
|
|
394
|
+
>
|
|
395
|
+
<Show when={props.hasDiffs} fallback={props.empty}>
|
|
396
|
+
<Show when={props.activeFile} fallback={<SessionFilePanelV2Empty>{props.empty}</SessionFilePanelV2Empty>}>
|
|
397
|
+
{props.preview}
|
|
398
|
+
</Show>
|
|
399
|
+
</Show>
|
|
400
|
+
</SessionFilePanelV2>
|
|
401
|
+
)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
export function SessionReviewV2SidebarToggle(props: { opened: boolean; disabled?: boolean; onToggle: () => void }) {
|
|
405
|
+
const i18n = useI18n()
|
|
406
|
+
|
|
407
|
+
return (
|
|
408
|
+
<Tooltip value={i18n.t("ui.sessionReviewV2.toggleSidebar")}>
|
|
409
|
+
<IconButton
|
|
410
|
+
variant="ghost"
|
|
411
|
+
size="small"
|
|
412
|
+
class="session-review-v2-sidebar-toggle"
|
|
413
|
+
aria-label={i18n.t("ui.sessionReviewV2.toggleSidebar")}
|
|
414
|
+
aria-expanded={props.opened}
|
|
415
|
+
data-expanded={props.opened ? "" : undefined}
|
|
416
|
+
disabled={props.disabled}
|
|
417
|
+
onClick={props.onToggle}
|
|
418
|
+
icon={<Icon name="filetree" />}
|
|
419
|
+
/>
|
|
420
|
+
</Tooltip>
|
|
421
|
+
)
|
|
422
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** The CSS slide's 200ms, plus slack, after which a close lands even when no `transitionend` arrives. */
|
|
2
|
+
export const SIDEBAR_EXIT_TIMEOUT_MS = 300
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The review and file tree sidebar. It mounts while open and slides its width on the user's toggles; a close keeps it
|
|
6
|
+
* mounted until the slide ends, then unmounts it, so no hidden tree is left behind.
|
|
7
|
+
*/
|
|
8
|
+
export type SidebarPresenceState =
|
|
9
|
+
| { readonly status: "open"; readonly attempt: number }
|
|
10
|
+
/** Opened by a toggle, so it slides in from zero width when it mounts. */
|
|
11
|
+
| { readonly status: "opening"; readonly attempt: number }
|
|
12
|
+
| { readonly status: "closing"; readonly attempt: number }
|
|
13
|
+
| { readonly status: "closed"; readonly attempt: number }
|
|
14
|
+
|
|
15
|
+
export type SidebarPresenceEvent =
|
|
16
|
+
/** `animate` is false while the preference hydrates and under reduced motion. */
|
|
17
|
+
| { readonly type: "open.changed"; readonly open: boolean; readonly animate: boolean }
|
|
18
|
+
| { readonly type: "exit.ended" }
|
|
19
|
+
| { readonly type: "exit.timed-out"; readonly attempt: number }
|
|
20
|
+
|
|
21
|
+
export type SidebarPresenceEffect = { readonly type: "exit.timer"; readonly attempt: number }
|
|
22
|
+
|
|
23
|
+
export type SidebarPresenceTransition = {
|
|
24
|
+
readonly state: SidebarPresenceState
|
|
25
|
+
readonly effects: readonly SidebarPresenceEffect[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const NO_EFFECTS: readonly SidebarPresenceEffect[] = []
|
|
29
|
+
|
|
30
|
+
export function createSidebarPresenceState(open: boolean): SidebarPresenceState {
|
|
31
|
+
return { status: open ? "open" : "closed", attempt: 0 }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function transitionSidebarPresence(
|
|
35
|
+
state: SidebarPresenceState,
|
|
36
|
+
event: SidebarPresenceEvent,
|
|
37
|
+
): SidebarPresenceTransition {
|
|
38
|
+
if (event.type === "exit.ended") {
|
|
39
|
+
if (state.status !== "closing") return { state, effects: NO_EFFECTS }
|
|
40
|
+
|
|
41
|
+
return { state: { status: "closed", attempt: state.attempt }, effects: NO_EFFECTS }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (event.type === "exit.timed-out") {
|
|
45
|
+
if (state.status !== "closing" || state.attempt !== event.attempt) return { state, effects: NO_EFFECTS }
|
|
46
|
+
|
|
47
|
+
return { state: { status: "closed", attempt: state.attempt }, effects: NO_EFFECTS }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (event.open) {
|
|
51
|
+
if (state.status === "open" || state.status === "opening") return { state, effects: NO_EFFECTS }
|
|
52
|
+
|
|
53
|
+
// Reopening mid-close keeps the mounted sidebar, so its width turns around from where it is.
|
|
54
|
+
if (state.status === "closing") return { state: { status: "open", attempt: state.attempt }, effects: NO_EFFECTS }
|
|
55
|
+
|
|
56
|
+
return { state: { status: event.animate ? "opening" : "open", attempt: state.attempt }, effects: NO_EFFECTS }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (state.status === "closed" || state.status === "closing") return { state, effects: NO_EFFECTS }
|
|
60
|
+
|
|
61
|
+
if (!event.animate) return { state: { status: "closed", attempt: state.attempt }, effects: NO_EFFECTS }
|
|
62
|
+
|
|
63
|
+
const attempt = state.attempt + 1
|
|
64
|
+
|
|
65
|
+
return { state: { status: "closing", attempt }, effects: [{ type: "exit.timer", attempt }] }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The sidebar is in the page: open, sliding in, or sliding out. */
|
|
69
|
+
export const selectSidebarMounted = (state: SidebarPresenceState) => state.status !== "closed"
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"extends": "@tsconfig/node22/tsconfig.json",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"noUnusedLocals": true,
|
|
6
|
+
"jsx": "preserve",
|
|
7
|
+
"jsxImportSource": "solid-js",
|
|
8
|
+
"target": "ESNext",
|
|
9
|
+
"allowSyntheticDefaultImports": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"module": "ESNext",
|
|
13
|
+
"moduleResolution": "bundler",
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"lib": ["es2023", "dom", "dom.iterable"],
|
|
16
|
+
"strict": true,
|
|
17
|
+
"types": ["vite/client", "bun"]
|
|
18
|
+
},
|
|
19
|
+
"exclude": ["**/*.stories.*", "**/*.mdx"]
|
|
20
|
+
}
|
package/README.md
DELETED