@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,733 @@
|
|
|
1
|
+
import { Accordion } from "@zyro-sec/ui/accordion"
|
|
2
|
+
import { Button } from "@zyro-sec/ui/button"
|
|
3
|
+
import { Menu } from "@zyro-sec/ui/menu"
|
|
4
|
+
import { SegmentedControl, SegmentedControlItem } from "@zyro-sec/ui/segmented-control"
|
|
5
|
+
import { DiffChanges } from "@zyro-sec/ui/diff-changes"
|
|
6
|
+
import { FileIcon } from "@zyro-sec/ui/file-icon"
|
|
7
|
+
import { Icon } from "@zyro-sec/ui/icon"
|
|
8
|
+
import { IconButton } from "@zyro-sec/ui/icon-button"
|
|
9
|
+
import { StickyAccordionHeader } from "@zyro-sec/ui/sticky-accordion-header"
|
|
10
|
+
import { Tooltip } from "@zyro-sec/ui/tooltip"
|
|
11
|
+
import { useFileComponent } from "@zyro-sec/ui/context/file"
|
|
12
|
+
import { useI18n } from "@zyro-sec/ui/context/i18n"
|
|
13
|
+
import { getDirectory, getFilename } from "@zyro-sec/util/path"
|
|
14
|
+
import { checksum } from "@zyro-sec/util/encode"
|
|
15
|
+
import {
|
|
16
|
+
createEffect,
|
|
17
|
+
createMemo,
|
|
18
|
+
createSignal,
|
|
19
|
+
For,
|
|
20
|
+
Match,
|
|
21
|
+
onCleanup,
|
|
22
|
+
Show,
|
|
23
|
+
Switch,
|
|
24
|
+
untrack,
|
|
25
|
+
type JSX,
|
|
26
|
+
} from "solid-js"
|
|
27
|
+
import { Predicate } from "effect"
|
|
28
|
+
import type { FileDiffInfo } from "@zyro-sec/client/promise"
|
|
29
|
+
import type { PresentationFileContent, PresentationFileDiff } from "../file-presentation"
|
|
30
|
+
import { PreloadMultiFileDiffResult } from "@pierre/diffs/ssr"
|
|
31
|
+
import { type SelectedLineRange } from "@pierre/diffs"
|
|
32
|
+
import { Dynamic } from "solid-js/web"
|
|
33
|
+
import { mediaKindFromPath } from "../pierre/media"
|
|
34
|
+
import { previewSelectedLines } from "../pierre/selection-bridge"
|
|
35
|
+
import { createLineCommentController } from "./line-comment-annotations"
|
|
36
|
+
import {
|
|
37
|
+
EMPTY_REVIEW_COMMENT_MODES,
|
|
38
|
+
reviewFileCommentMode,
|
|
39
|
+
transitionReviewCommentModes,
|
|
40
|
+
type LineCommentEvent,
|
|
41
|
+
} from "./line-comment-machine"
|
|
42
|
+
import { createReviewFocusDriver } from "./review-focus-driver"
|
|
43
|
+
import { reviewFocusPinnedFile } from "./review-focus-machine"
|
|
44
|
+
import type { LineCommentEditorProps } from "./line-comment"
|
|
45
|
+
import { normalize, text, type ViewDiff } from "./session-diff"
|
|
46
|
+
import {
|
|
47
|
+
createSessionReviewState,
|
|
48
|
+
DISPOSED_SESSION_REVIEW_EVENT,
|
|
49
|
+
MAX_DIFF_CHANGED_LINES,
|
|
50
|
+
MEASURE_REQUESTED_EVENT,
|
|
51
|
+
REVIEW_MOUNT_MARGIN,
|
|
52
|
+
selectSessionReviewExpanded,
|
|
53
|
+
selectSessionReviewFileBody,
|
|
54
|
+
selectSessionReviewOpen,
|
|
55
|
+
transitionSessionReview,
|
|
56
|
+
type SessionReviewEvent,
|
|
57
|
+
type SessionReviewState,
|
|
58
|
+
} from "./session-review-machine"
|
|
59
|
+
|
|
60
|
+
export type SessionReviewDiffStyle = "unified" | "split"
|
|
61
|
+
|
|
62
|
+
export type SessionReviewComment = {
|
|
63
|
+
id: string
|
|
64
|
+
file: string
|
|
65
|
+
selection: SelectedLineRange
|
|
66
|
+
comment: string
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type SessionReviewLineComment = {
|
|
70
|
+
file: string
|
|
71
|
+
selection: SelectedLineRange
|
|
72
|
+
comment: string
|
|
73
|
+
preview?: string
|
|
74
|
+
send?: boolean
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type SessionReviewCommentUpdate = SessionReviewLineComment & {
|
|
78
|
+
id: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type SessionReviewCommentDelete = {
|
|
82
|
+
id: string
|
|
83
|
+
file: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export type SessionReviewCommentActions = {
|
|
87
|
+
moreLabel: string
|
|
88
|
+
editLabel: string
|
|
89
|
+
deleteLabel: string
|
|
90
|
+
saveLabel: string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type SessionReviewFocus = { file: string; id: string }
|
|
94
|
+
|
|
95
|
+
type RawReviewDiff = (PresentationFileDiff | FileDiffInfo) & {
|
|
96
|
+
preloaded?: PreloadMultiFileDiffResult<unknown, undefined>
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type ReviewDiff = ((PresentationFileDiff & { file: string }) | FileDiffInfo) & {
|
|
100
|
+
preloaded?: PreloadMultiFileDiffResult<unknown, undefined>
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface SessionReviewProps {
|
|
104
|
+
title?: JSX.Element
|
|
105
|
+
empty?: JSX.Element
|
|
106
|
+
split?: boolean
|
|
107
|
+
diffStyle?: SessionReviewDiffStyle
|
|
108
|
+
changeSummary?: boolean
|
|
109
|
+
overflow?: "wrap" | "scroll"
|
|
110
|
+
disableLineNumbers?: boolean
|
|
111
|
+
onDiffStyleChange?: (diffStyle: SessionReviewDiffStyle) => void
|
|
112
|
+
onDiffRendered?: VoidFunction
|
|
113
|
+
onLineComment?: (comment: SessionReviewLineComment) => void
|
|
114
|
+
onLineCommentUpdate?: (comment: SessionReviewCommentUpdate) => void
|
|
115
|
+
onLineCommentDelete?: (comment: SessionReviewCommentDelete) => void
|
|
116
|
+
lineCommentActions?: SessionReviewCommentActions
|
|
117
|
+
comments?: SessionReviewComment[]
|
|
118
|
+
focusedComment?: SessionReviewFocus | null
|
|
119
|
+
onFocusedCommentChange?: (focus: SessionReviewFocus | null) => void
|
|
120
|
+
focusedFile?: string
|
|
121
|
+
open?: readonly string[]
|
|
122
|
+
onOpenChange?: (open: string[]) => void
|
|
123
|
+
scrollRef?: (el: HTMLDivElement) => void
|
|
124
|
+
onScroll?: JSX.EventHandlerUnion<HTMLDivElement, Event>
|
|
125
|
+
class?: string
|
|
126
|
+
classList?: Record<string, boolean | undefined>
|
|
127
|
+
classes?: { root?: string; header?: string; container?: string }
|
|
128
|
+
actions?: JSX.Element
|
|
129
|
+
diffs: RawReviewDiff[]
|
|
130
|
+
onViewFile?: (file: string) => void
|
|
131
|
+
readFile?: (path: string) => Promise<PresentationFileContent | undefined>
|
|
132
|
+
lineCommentMention?: LineCommentEditorProps["mention"]
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function ReviewCommentMenu(props: {
|
|
136
|
+
labels: SessionReviewCommentActions
|
|
137
|
+
onEdit: VoidFunction
|
|
138
|
+
onDelete: VoidFunction
|
|
139
|
+
}) {
|
|
140
|
+
return (
|
|
141
|
+
<div onMouseDown={(event) => event.stopPropagation()} onClick={(event) => event.stopPropagation()}>
|
|
142
|
+
<Menu appearance="standard" gutter={4} placement="bottom-end">
|
|
143
|
+
<Menu.Trigger
|
|
144
|
+
as={IconButton}
|
|
145
|
+
icon={<Icon name="dot-grid" />}
|
|
146
|
+
variant="ghost"
|
|
147
|
+
size="small"
|
|
148
|
+
class="size-6 rounded-md"
|
|
149
|
+
aria-label={props.labels.moreLabel}
|
|
150
|
+
/>
|
|
151
|
+
<Menu.Portal>
|
|
152
|
+
<Menu.Content>
|
|
153
|
+
<Menu.Item onSelect={props.onEdit}>{props.labels.editLabel}</Menu.Item>
|
|
154
|
+
<Menu.Item onSelect={props.onDelete}>{props.labels.deleteLabel}</Menu.Item>
|
|
155
|
+
</Menu.Content>
|
|
156
|
+
</Menu.Portal>
|
|
157
|
+
</Menu>
|
|
158
|
+
</div>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function observableChange(previous: SessionReviewState, next: SessionReviewState) {
|
|
163
|
+
if (previous === next) return false
|
|
164
|
+
|
|
165
|
+
if (previous.status !== "active" || next.status !== "active") return previous.status !== next.status
|
|
166
|
+
|
|
167
|
+
return previous.open !== next.open || previous.mounted !== next.mounted || previous.forced !== next.forced
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** The open files near the scroll viewport, or null while it has no size, so a hidden review mounts nothing. */
|
|
171
|
+
function measureVisibleReviewFiles(
|
|
172
|
+
scroll: HTMLDivElement | undefined,
|
|
173
|
+
nodes: ReadonlyMap<string, HTMLDivElement>,
|
|
174
|
+
state: SessionReviewState,
|
|
175
|
+
) {
|
|
176
|
+
if (!scroll || state.status !== "active") return null
|
|
177
|
+
|
|
178
|
+
const root = scroll.getBoundingClientRect()
|
|
179
|
+
|
|
180
|
+
if (root.width <= 0 || root.height <= 0) return null
|
|
181
|
+
|
|
182
|
+
const top = root.top - REVIEW_MOUNT_MARGIN
|
|
183
|
+
const bottom = root.bottom + REVIEW_MOUNT_MARGIN
|
|
184
|
+
const visible = new Set<string>()
|
|
185
|
+
|
|
186
|
+
for (const [file, el] of nodes) {
|
|
187
|
+
if (!state.openSet.has(file)) continue
|
|
188
|
+
const rect = el.getBoundingClientRect()
|
|
189
|
+
|
|
190
|
+
if (rect.bottom < top || rect.top > bottom) continue
|
|
191
|
+
visible.add(file)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return visible
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function diffId(file: string): string | undefined {
|
|
198
|
+
const sum = checksum(file)
|
|
199
|
+
|
|
200
|
+
if (!sum) return
|
|
201
|
+
|
|
202
|
+
return `session-review-diff-${sum}`
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export const SessionReview = (props: SessionReviewProps) => {
|
|
206
|
+
let scroll: HTMLDivElement | undefined
|
|
207
|
+
let frameId: number | undefined
|
|
208
|
+
const i18n = useI18n()
|
|
209
|
+
const fileComponent = useFileComponent()
|
|
210
|
+
const anchors = new Map<string, HTMLElement>()
|
|
211
|
+
const nodes = new Map<string, HTMLDivElement>()
|
|
212
|
+
|
|
213
|
+
const files = createMemo(() => props.diffs.map((diff) => diff.file!))
|
|
214
|
+
|
|
215
|
+
let reviewCurrent = createSessionReviewState(
|
|
216
|
+
untrack(files),
|
|
217
|
+
untrack(() => props.open),
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
const [reviewState, setReviewState] = createSignal(reviewCurrent)
|
|
221
|
+
|
|
222
|
+
const dispatchReview = (event: SessionReviewEvent) => {
|
|
223
|
+
const previous = reviewCurrent
|
|
224
|
+
const step = transitionSessionReview(previous, event)
|
|
225
|
+
reviewCurrent = step.state
|
|
226
|
+
|
|
227
|
+
// A queued measurement alone changes nothing on screen, so a scrolled frame writes no signal.
|
|
228
|
+
if (observableChange(previous, step.state)) setReviewState(step.state)
|
|
229
|
+
step.effects.forEach((effect) => {
|
|
230
|
+
if (effect.type === "notify-open") return props.onOpenChange?.([...effect.files])
|
|
231
|
+
|
|
232
|
+
if (effect.type === "schedule-measure") {
|
|
233
|
+
if (frameId === undefined) frameId = requestAnimationFrame(measureViewport)
|
|
234
|
+
|
|
235
|
+
return
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (frameId === undefined) return
|
|
239
|
+
cancelAnimationFrame(frameId)
|
|
240
|
+
frameId = undefined
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const measureViewport = () => {
|
|
245
|
+
frameId = undefined
|
|
246
|
+
dispatchReview({
|
|
247
|
+
type: "viewport.measured",
|
|
248
|
+
visible: measureVisibleReviewFiles(scroll, nodes, reviewCurrent),
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const resizeObserver =
|
|
253
|
+
typeof ResizeObserver === "undefined"
|
|
254
|
+
? undefined
|
|
255
|
+
: new ResizeObserver(() => dispatchReview(MEASURE_REQUESTED_EVENT))
|
|
256
|
+
|
|
257
|
+
const [commentModes, setCommentModes] = createSignal(EMPTY_REVIEW_COMMENT_MODES)
|
|
258
|
+
|
|
259
|
+
const dispatchComment = (file: string, event: LineCommentEvent) => {
|
|
260
|
+
const step = transitionReviewCommentModes(untrack(commentModes), file, event)
|
|
261
|
+
setCommentModes(step.modes)
|
|
262
|
+
|
|
263
|
+
return step.effects
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const open = () => selectSessionReviewOpen(reviewState())
|
|
267
|
+
|
|
268
|
+
const itemsMap = createMemo(() =>
|
|
269
|
+
Object.fromEntries(
|
|
270
|
+
props.diffs
|
|
271
|
+
.filter((diff): diff is ReviewDiff => diff.file !== undefined)
|
|
272
|
+
.map((diff) => [diff.file, { ...normalize(diff), preloaded: diff.preloaded }]),
|
|
273
|
+
),
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
const grouped = createMemo(() => {
|
|
277
|
+
const next = new Map<string, SessionReviewComment[]>()
|
|
278
|
+
|
|
279
|
+
for (const comment of props.comments ?? []) {
|
|
280
|
+
const list = next.get(comment.file)
|
|
281
|
+
|
|
282
|
+
if (list) {
|
|
283
|
+
list.push(comment)
|
|
284
|
+
continue
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
next.set(comment.file, [comment])
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
return next
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
const diffStyle = () => props.diffStyle ?? (props.split ? "split" : "unified")
|
|
294
|
+
const hasDiffs = () => files().length > 0
|
|
295
|
+
|
|
296
|
+
const pinned = (file: string) =>
|
|
297
|
+
reviewFocusPinnedFile(focus.state()) === file ||
|
|
298
|
+
props.focusedFile === file ||
|
|
299
|
+
reviewFileCommentMode(commentModes(), file).status !== "idle"
|
|
300
|
+
|
|
301
|
+
const handleScroll: JSX.EventHandler<HTMLDivElement, Event> = (event) => {
|
|
302
|
+
dispatchReview(MEASURE_REQUESTED_EVENT)
|
|
303
|
+
const next = props.onScroll
|
|
304
|
+
|
|
305
|
+
if (!next) return
|
|
306
|
+
|
|
307
|
+
if (Predicate.isFunction(next)) return next(event)
|
|
308
|
+
|
|
309
|
+
next[0](next[1], event)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
createEffect(() => dispatchReview({ type: "props.synced", files: files(), open: props.open }))
|
|
313
|
+
|
|
314
|
+
onCleanup(() => {
|
|
315
|
+
resizeObserver?.disconnect()
|
|
316
|
+
dispatchReview(DISPOSED_SESSION_REVIEW_EVENT)
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
const handleChange = (next: string[]) => dispatchReview({ type: "open.changed", files: next })
|
|
320
|
+
|
|
321
|
+
const handleExpandOrCollapseAll = () => {
|
|
322
|
+
if (open().length > 0) return handleChange([])
|
|
323
|
+
handleChange(
|
|
324
|
+
files().filter((file) => {
|
|
325
|
+
const diff = itemsMap()[file]
|
|
326
|
+
|
|
327
|
+
return diff !== undefined && (diff.additions !== 0 || diff.deletions !== 0)
|
|
328
|
+
}),
|
|
329
|
+
)
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const openFileLabel = () => i18n.t("ui.sessionReview.openFile")
|
|
333
|
+
|
|
334
|
+
const selectionSide = (range: SelectedLineRange) => range.endSide ?? range.side ?? "additions"
|
|
335
|
+
|
|
336
|
+
const selectionPreview = (diff: ViewDiff, range: SelectedLineRange) => {
|
|
337
|
+
const side = selectionSide(range)
|
|
338
|
+
const contents = text(diff, side)
|
|
339
|
+
|
|
340
|
+
if (contents.length === 0) return undefined
|
|
341
|
+
|
|
342
|
+
return previewSelectedLines(contents, range)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const focus = createReviewFocusDriver({
|
|
346
|
+
focusedComment: () => props.focusedComment,
|
|
347
|
+
// Before the diffs load, wait for them instead of failing the request.
|
|
348
|
+
isAvailable: (target) => {
|
|
349
|
+
if (!hasDiffs()) return true
|
|
350
|
+
const diff = itemsMap()[target.file]
|
|
351
|
+
|
|
352
|
+
return diff !== undefined && (diff.additions !== 0 || diff.deletions !== 0)
|
|
353
|
+
},
|
|
354
|
+
root: () => scroll,
|
|
355
|
+
findComment: (file, commentId) => {
|
|
356
|
+
const anchor = anchors.get(file)?.querySelector(`[data-comment-id="${CSS.escape(commentId)}"]`)
|
|
357
|
+
|
|
358
|
+
if (!(anchor instanceof HTMLElement)) return
|
|
359
|
+
|
|
360
|
+
if (anchor.style.pointerEvents === "none" || anchor.style.opacity === "0") return
|
|
361
|
+
|
|
362
|
+
return anchor
|
|
363
|
+
},
|
|
364
|
+
findFallback: (file) => anchors.get(file),
|
|
365
|
+
scrollTo: (target) => {
|
|
366
|
+
if (!scroll) return
|
|
367
|
+
const rootRect = scroll.getBoundingClientRect()
|
|
368
|
+
const targetRect = target.getBoundingClientRect()
|
|
369
|
+
const next = scroll.scrollTop + targetRect.top - rootRect.top - rootRect.height / 2 + targetRect.height / 2
|
|
370
|
+
scroll.scrollTop = Math.max(0, next)
|
|
371
|
+
},
|
|
372
|
+
onOpenComment: (file, commentId) => {
|
|
373
|
+
const comment = (props.comments ?? []).find((item) => item.file === file && item.id === commentId)
|
|
374
|
+
|
|
375
|
+
if (comment) dispatchComment(file, { type: "comment.focused", id: comment.id, range: comment.selection })
|
|
376
|
+
},
|
|
377
|
+
onExpandFile: (file) => {
|
|
378
|
+
const current = open()
|
|
379
|
+
|
|
380
|
+
if (!current.includes(file)) handleChange([...current, file])
|
|
381
|
+
},
|
|
382
|
+
onAcknowledge: () => props.onFocusedCommentChange?.(null),
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
return (
|
|
386
|
+
<div data-component="session-review" class={props.class} classList={props.classList}>
|
|
387
|
+
<div data-slot="session-review-header" class={props.classes?.header}>
|
|
388
|
+
<div data-slot="session-review-title">
|
|
389
|
+
{props.title === undefined ? i18n.t("ui.sessionReview.title") : props.title}
|
|
390
|
+
</div>
|
|
391
|
+
<Show when={hasDiffs()}>
|
|
392
|
+
<DiffChanges appearance="standard" changes={props.diffs} />
|
|
393
|
+
</Show>
|
|
394
|
+
<div data-slot="session-review-actions">
|
|
395
|
+
<Show when={hasDiffs() && props.onDiffStyleChange}>
|
|
396
|
+
<SegmentedControl
|
|
397
|
+
class="session-review-diff-style"
|
|
398
|
+
value={diffStyle()}
|
|
399
|
+
onChange={(style) => {
|
|
400
|
+
if (style !== "unified" && style !== "split") return
|
|
401
|
+
props.onDiffStyleChange?.(style)
|
|
402
|
+
}}
|
|
403
|
+
>
|
|
404
|
+
<For each={["unified", "split"] as const}>
|
|
405
|
+
{(style) => (
|
|
406
|
+
<SegmentedControlItem value={style}>
|
|
407
|
+
{i18n.t(
|
|
408
|
+
style === "unified" ? "ui.sessionReview.diffStyle.unified" : "ui.sessionReview.diffStyle.split",
|
|
409
|
+
)}
|
|
410
|
+
</SegmentedControlItem>
|
|
411
|
+
)}
|
|
412
|
+
</For>
|
|
413
|
+
</SegmentedControl>
|
|
414
|
+
</Show>
|
|
415
|
+
<Show when={hasDiffs()}>
|
|
416
|
+
<Button
|
|
417
|
+
size="small"
|
|
418
|
+
icon="chevron-grabber-vertical"
|
|
419
|
+
class="shrink-0 whitespace-nowrap justify-start"
|
|
420
|
+
onClick={handleExpandOrCollapseAll}
|
|
421
|
+
>
|
|
422
|
+
<Switch>
|
|
423
|
+
<Match when={open().length > 0}>{i18n.t("ui.sessionReview.collapseAll")}</Match>
|
|
424
|
+
<Match when={true}>{i18n.t("ui.sessionReview.expandAll")}</Match>
|
|
425
|
+
</Switch>
|
|
426
|
+
</Button>
|
|
427
|
+
</Show>
|
|
428
|
+
{props.actions}
|
|
429
|
+
</div>
|
|
430
|
+
</div>
|
|
431
|
+
|
|
432
|
+
<div
|
|
433
|
+
data-slot="session-review-scroll"
|
|
434
|
+
data-scrollable
|
|
435
|
+
ref={(el) => {
|
|
436
|
+
scroll = el
|
|
437
|
+
props.scrollRef?.(el)
|
|
438
|
+
resizeObserver?.observe(el)
|
|
439
|
+
dispatchReview(MEASURE_REQUESTED_EVENT)
|
|
440
|
+
}}
|
|
441
|
+
onScroll={handleScroll}
|
|
442
|
+
classList={{
|
|
443
|
+
[props.classes?.root ?? ""]: !!props.classes?.root,
|
|
444
|
+
}}
|
|
445
|
+
>
|
|
446
|
+
<div
|
|
447
|
+
data-slot="session-review-container"
|
|
448
|
+
class={props.classes?.container}
|
|
449
|
+
ref={(el) => {
|
|
450
|
+
resizeObserver?.observe(el)
|
|
451
|
+
dispatchReview(MEASURE_REQUESTED_EVENT)
|
|
452
|
+
}}
|
|
453
|
+
>
|
|
454
|
+
<Show when={hasDiffs()} fallback={props.empty}>
|
|
455
|
+
<div data-slot="session-review-list" class="pb-6">
|
|
456
|
+
<Accordion multiple value={open()} onChange={handleChange}>
|
|
457
|
+
<For each={files()}>
|
|
458
|
+
{(file) => {
|
|
459
|
+
const diff = () => itemsMap()[file]
|
|
460
|
+
|
|
461
|
+
// binary files have empty diffs that we can't render
|
|
462
|
+
const diffCanRender = () => diff().additions !== 0 || diff().deletions !== 0
|
|
463
|
+
|
|
464
|
+
const expanded = createMemo(() => selectSessionReviewExpanded(reviewState(), file, diffCanRender()))
|
|
465
|
+
|
|
466
|
+
const comments = createMemo(() => grouped().get(file) ?? [])
|
|
467
|
+
const commentedLines = createMemo(() => comments().map((c) => c.selection))
|
|
468
|
+
|
|
469
|
+
const beforeText = () => text(diff(), "deletions")
|
|
470
|
+
const afterText = () => text(diff(), "additions")
|
|
471
|
+
const changedLines = () => diff().additions + diff().deletions
|
|
472
|
+
const mediaKind = createMemo(() => mediaKindFromPath(file))
|
|
473
|
+
|
|
474
|
+
const body = createMemo(() =>
|
|
475
|
+
selectSessionReviewFileBody(reviewState(), {
|
|
476
|
+
file,
|
|
477
|
+
canRender: diffCanRender(),
|
|
478
|
+
changedLines: changedLines(),
|
|
479
|
+
isMedia: !!mediaKind(),
|
|
480
|
+
pinned: pinned(file),
|
|
481
|
+
}),
|
|
482
|
+
)
|
|
483
|
+
|
|
484
|
+
const isAdded = () =>
|
|
485
|
+
diff().status === "added" || (beforeText().length === 0 && afterText().length > 0)
|
|
486
|
+
|
|
487
|
+
const isDeleted = () =>
|
|
488
|
+
diff().status === "deleted" || (afterText().length === 0 && beforeText().length > 0)
|
|
489
|
+
|
|
490
|
+
const commentsUi = createLineCommentController<SessionReviewComment>({
|
|
491
|
+
comments,
|
|
492
|
+
label: i18n.t("ui.lineComment.submit"),
|
|
493
|
+
draftKey: () => file,
|
|
494
|
+
mention: props.lineCommentMention,
|
|
495
|
+
machine: {
|
|
496
|
+
mode: createMemo(() => reviewFileCommentMode(commentModes(), file)),
|
|
497
|
+
dispatch: (event) => dispatchComment(file, event),
|
|
498
|
+
},
|
|
499
|
+
getSide: selectionSide,
|
|
500
|
+
onSubmit: ({ comment, selection }) => {
|
|
501
|
+
props.onLineComment?.({
|
|
502
|
+
file,
|
|
503
|
+
selection,
|
|
504
|
+
comment,
|
|
505
|
+
preview: selectionPreview(diff(), selection),
|
|
506
|
+
})
|
|
507
|
+
},
|
|
508
|
+
onUpdate: ({ id, comment, selection }) => {
|
|
509
|
+
props.onLineCommentUpdate?.({
|
|
510
|
+
id,
|
|
511
|
+
file,
|
|
512
|
+
selection,
|
|
513
|
+
comment,
|
|
514
|
+
preview: selectionPreview(diff(), selection),
|
|
515
|
+
})
|
|
516
|
+
},
|
|
517
|
+
onDelete: (comment) => {
|
|
518
|
+
props.onLineCommentDelete?.({
|
|
519
|
+
id: comment.id,
|
|
520
|
+
file,
|
|
521
|
+
})
|
|
522
|
+
},
|
|
523
|
+
editSubmitLabel: props.lineCommentActions?.saveLabel,
|
|
524
|
+
renderCommentActions: props.lineCommentActions
|
|
525
|
+
? (comment, controls) => (
|
|
526
|
+
<ReviewCommentMenu
|
|
527
|
+
labels={props.lineCommentActions!}
|
|
528
|
+
onEdit={controls.edit}
|
|
529
|
+
onDelete={controls.remove}
|
|
530
|
+
/>
|
|
531
|
+
)
|
|
532
|
+
: undefined,
|
|
533
|
+
})
|
|
534
|
+
|
|
535
|
+
onCleanup(() => {
|
|
536
|
+
anchors.delete(file)
|
|
537
|
+
nodes.delete(file)
|
|
538
|
+
dispatchReview(MEASURE_REQUESTED_EVENT)
|
|
539
|
+
})
|
|
540
|
+
|
|
541
|
+
const handleLineSelected = (range: SelectedLineRange | null) => {
|
|
542
|
+
if (!props.onLineComment) return
|
|
543
|
+
commentsUi.onLineSelected(range)
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
const handleLineSelectionEnd = (range: SelectedLineRange | null) => {
|
|
547
|
+
if (!props.onLineComment) return
|
|
548
|
+
commentsUi.onLineSelectionEnd(range)
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
const changes = (summary = false) => (
|
|
552
|
+
<>
|
|
553
|
+
<Switch>
|
|
554
|
+
<Match when={isAdded()}>
|
|
555
|
+
<div data-slot="session-review-change-group" data-type="added">
|
|
556
|
+
<span data-slot="session-review-change" data-type="added">
|
|
557
|
+
{i18n.t("ui.sessionReview.change.added")}
|
|
558
|
+
</span>
|
|
559
|
+
<DiffChanges appearance="standard" changes={diff()} />
|
|
560
|
+
</div>
|
|
561
|
+
</Match>
|
|
562
|
+
<Match when={isDeleted()}>
|
|
563
|
+
<span data-slot="session-review-change" data-type="removed">
|
|
564
|
+
{i18n.t("ui.sessionReview.change.removed")}
|
|
565
|
+
</span>
|
|
566
|
+
<Show when={summary}>
|
|
567
|
+
<DiffChanges appearance="standard" changes={diff()} />
|
|
568
|
+
</Show>
|
|
569
|
+
</Match>
|
|
570
|
+
<Match when={!!mediaKind()}>
|
|
571
|
+
<span data-slot="session-review-change" data-type="modified">
|
|
572
|
+
{i18n.t("ui.sessionReview.change.modified")}
|
|
573
|
+
</span>
|
|
574
|
+
</Match>
|
|
575
|
+
<Match when={true}>
|
|
576
|
+
<DiffChanges appearance="standard" changes={diff()} />
|
|
577
|
+
</Match>
|
|
578
|
+
</Switch>
|
|
579
|
+
</>
|
|
580
|
+
)
|
|
581
|
+
|
|
582
|
+
return (
|
|
583
|
+
<Accordion.Item
|
|
584
|
+
value={diffCanRender() ? file : null!}
|
|
585
|
+
id={diffId(file)}
|
|
586
|
+
data-file={file}
|
|
587
|
+
data-slot="session-review-accordion-item"
|
|
588
|
+
data-selected={props.focusedFile === file ? "" : undefined}
|
|
589
|
+
>
|
|
590
|
+
<StickyAccordionHeader>
|
|
591
|
+
<Accordion.Trigger disabled={!diffCanRender()} class="cursor-default">
|
|
592
|
+
<div data-slot="session-review-trigger-content">
|
|
593
|
+
<div data-slot="session-review-file-info">
|
|
594
|
+
<FileIcon node={{ path: file, type: "file" }} />
|
|
595
|
+
<div data-slot="session-review-file-name-container">
|
|
596
|
+
<Show when={file.includes("/")}>
|
|
597
|
+
<span data-slot="session-review-directory">{`\u202A${getDirectory(file)}\u202C`}</span>
|
|
598
|
+
</Show>
|
|
599
|
+
<span data-slot="session-review-filename">{getFilename(file)}</span>
|
|
600
|
+
<Show when={props.onViewFile && diffCanRender() && !props.changeSummary}>
|
|
601
|
+
<Tooltip appearance="standard" value={openFileLabel()} placement="top" gutter={4}>
|
|
602
|
+
<button
|
|
603
|
+
data-slot="session-review-view-button"
|
|
604
|
+
type="button"
|
|
605
|
+
aria-label={openFileLabel()}
|
|
606
|
+
onClick={(e) => {
|
|
607
|
+
e.stopPropagation()
|
|
608
|
+
props.onViewFile?.(file)
|
|
609
|
+
}}
|
|
610
|
+
>
|
|
611
|
+
<Icon name="open-file" size="small" />
|
|
612
|
+
</button>
|
|
613
|
+
</Tooltip>
|
|
614
|
+
</Show>
|
|
615
|
+
</div>
|
|
616
|
+
</div>
|
|
617
|
+
<div data-slot="session-review-trigger-actions">
|
|
618
|
+
<Show when={!props.changeSummary || !diffCanRender()}>{changes()}</Show>
|
|
619
|
+
<Show when={diffCanRender()}>
|
|
620
|
+
<span data-slot="session-review-diff-chevron">
|
|
621
|
+
<Icon name="chevron-down" />
|
|
622
|
+
</span>
|
|
623
|
+
</Show>
|
|
624
|
+
</div>
|
|
625
|
+
</div>
|
|
626
|
+
</Accordion.Trigger>
|
|
627
|
+
</StickyAccordionHeader>
|
|
628
|
+
<Show when={props.changeSummary && expanded()}>
|
|
629
|
+
<div data-slot="session-review-change-summary">
|
|
630
|
+
{changes(true)}
|
|
631
|
+
<Show when={props.onViewFile}>
|
|
632
|
+
<Button
|
|
633
|
+
data-slot="session-review-summary-open-file"
|
|
634
|
+
size="small"
|
|
635
|
+
variant="ghost"
|
|
636
|
+
icon="open-file"
|
|
637
|
+
onClick={() => props.onViewFile?.(file)}
|
|
638
|
+
>
|
|
639
|
+
{openFileLabel()}
|
|
640
|
+
</Button>
|
|
641
|
+
</Show>
|
|
642
|
+
</div>
|
|
643
|
+
</Show>
|
|
644
|
+
<Accordion.Content data-slot="session-review-accordion-content">
|
|
645
|
+
<div
|
|
646
|
+
data-slot="session-review-diff-wrapper"
|
|
647
|
+
ref={(el) => {
|
|
648
|
+
anchors.set(file, el)
|
|
649
|
+
nodes.set(file, el)
|
|
650
|
+
dispatchReview(MEASURE_REQUESTED_EVENT)
|
|
651
|
+
focus.poke()
|
|
652
|
+
}}
|
|
653
|
+
>
|
|
654
|
+
<Show when={expanded()}>
|
|
655
|
+
<Switch>
|
|
656
|
+
<Match when={body() === "placeholder"}>
|
|
657
|
+
<div
|
|
658
|
+
data-slot="session-review-diff-placeholder"
|
|
659
|
+
class="rounded-lg border border-v2-border-border-muted bg-background-stronger/40"
|
|
660
|
+
style={{ height: "160px" }}
|
|
661
|
+
/>
|
|
662
|
+
</Match>
|
|
663
|
+
<Match when={body() === "too-large"}>
|
|
664
|
+
<div data-slot="session-review-large-diff">
|
|
665
|
+
<div data-slot="session-review-large-diff-title">
|
|
666
|
+
{i18n.t("ui.sessionReview.largeDiff.title")}
|
|
667
|
+
</div>
|
|
668
|
+
<div data-slot="session-review-large-diff-meta">
|
|
669
|
+
{i18n.t("ui.sessionReview.largeDiff.meta", {
|
|
670
|
+
limit: MAX_DIFF_CHANGED_LINES.toLocaleString(),
|
|
671
|
+
current: changedLines().toLocaleString(),
|
|
672
|
+
})}
|
|
673
|
+
</div>
|
|
674
|
+
<div data-slot="session-review-large-diff-actions">
|
|
675
|
+
<Button
|
|
676
|
+
size="normal"
|
|
677
|
+
variant="neutral"
|
|
678
|
+
onClick={() => dispatchReview({ type: "force.requested", file })}
|
|
679
|
+
>
|
|
680
|
+
{i18n.t("ui.sessionReview.largeDiff.renderAnyway")}
|
|
681
|
+
</Button>
|
|
682
|
+
</div>
|
|
683
|
+
</div>
|
|
684
|
+
</Match>
|
|
685
|
+
<Match when={body() === "mounted"}>
|
|
686
|
+
<Dynamic
|
|
687
|
+
component={fileComponent}
|
|
688
|
+
mode="diff"
|
|
689
|
+
fileDiff={diff().fileDiff}
|
|
690
|
+
preloadedDiff={diff().preloaded}
|
|
691
|
+
diffStyle={diffStyle()}
|
|
692
|
+
overflow={props.overflow ?? "wrap"}
|
|
693
|
+
disableLineNumbers={props.disableLineNumbers}
|
|
694
|
+
onRendered={() => {
|
|
695
|
+
props.onDiffRendered?.()
|
|
696
|
+
focus.poke()
|
|
697
|
+
}}
|
|
698
|
+
enableLineSelection={props.onLineComment != null}
|
|
699
|
+
enableGutterUtility={props.onLineComment != null}
|
|
700
|
+
onLineSelected={handleLineSelected}
|
|
701
|
+
onLineSelectionEnd={handleLineSelectionEnd}
|
|
702
|
+
annotations={commentsUi.annotations()}
|
|
703
|
+
renderAnnotation={commentsUi.renderAnnotation}
|
|
704
|
+
renderGutterUtility={
|
|
705
|
+
props.onLineComment ? commentsUi.renderGutterUtility : undefined
|
|
706
|
+
}
|
|
707
|
+
onCommentSelection={props.onLineComment ? commentsUi.commentSelection() : undefined}
|
|
708
|
+
selectedLines={commentsUi.selected()}
|
|
709
|
+
commentedLines={commentedLines()}
|
|
710
|
+
media={{
|
|
711
|
+
mode: "auto",
|
|
712
|
+
path: file,
|
|
713
|
+
deleted: diff().status === "deleted",
|
|
714
|
+
readFile: diff().status === "deleted" ? undefined : props.readFile,
|
|
715
|
+
}}
|
|
716
|
+
/>
|
|
717
|
+
</Match>
|
|
718
|
+
</Switch>
|
|
719
|
+
</Show>
|
|
720
|
+
</div>
|
|
721
|
+
</Accordion.Content>
|
|
722
|
+
</Accordion.Item>
|
|
723
|
+
)
|
|
724
|
+
}}
|
|
725
|
+
</For>
|
|
726
|
+
</Accordion>
|
|
727
|
+
</div>
|
|
728
|
+
</Show>
|
|
729
|
+
</div>
|
|
730
|
+
</div>
|
|
731
|
+
</div>
|
|
732
|
+
)
|
|
733
|
+
}
|