@cueloop/client 0.1.0-alpha.5 → 0.1.0-alpha.51
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/native/build-pty.sh +51 -0
- package/native/build.sh +82 -0
- package/native/darwin-arm64/libcuelooppty.dylib +0 -0
- package/native/darwin-arm64/libcueloopvt.dylib +0 -0
- package/native/src/pty.zig +193 -0
- package/native/src/shim.zig +114 -0
- package/package.json +36 -31
- package/src/App.autoclose.test.tsx +137 -0
- package/src/App.diff.test.tsx +158 -22
- package/src/App.export.test.tsx +44 -37
- package/src/App.plan-review.test.tsx +672 -0
- package/src/App.prototype.test.tsx +155 -0
- package/src/App.readonly.test.tsx +60 -36
- package/src/App.rendering.test.tsx +132 -0
- package/src/App.review-panel.test.tsx +136 -0
- package/src/App.submit-confirm.test.tsx +218 -0
- package/src/App.test.tsx +128 -69
- package/src/App.toast.test.tsx +75 -0
- package/src/App.tsx +0 -0
- package/src/App.walk.test.tsx +289 -0
- package/src/__snapshots__/view-plan.regression.test.ts.snap +100 -0
- package/src/attribution.test.ts +31 -0
- package/src/attribution.ts +38 -0
- package/src/clipboard.test.ts +23 -0
- package/src/clipboard.ts +30 -0
- package/src/components/AnnotationCard.compose-rows.test.ts +49 -0
- package/src/components/AnnotationCard.stories.tsx +94 -0
- package/src/components/AnnotationCard.tsx +241 -0
- package/src/components/Breadcrumb.stories.tsx +19 -0
- package/src/components/Breadcrumb.tsx +44 -0
- package/src/components/CodeBlock.stories.tsx +42 -0
- package/src/components/CodeBlock.tsx +83 -0
- package/src/components/CompletionOverlay.stories.tsx +23 -0
- package/src/components/CompletionOverlay.tsx +59 -0
- package/src/components/ConfirmCard.stories.tsx +35 -0
- package/src/components/ConfirmCard.tsx +127 -0
- package/src/components/ConfirmDialog.stories.tsx +21 -0
- package/src/components/ConfirmDialog.tsx +64 -0
- package/src/components/DiffSheet.scroll.test.tsx +123 -0
- package/src/components/DiffSheet.stories.tsx +78 -0
- package/src/components/DiffSheet.syntax.test.tsx +62 -0
- package/src/components/DiffSheet.tsx +355 -0
- package/src/components/InboxList.stories.tsx +31 -0
- package/src/components/InboxList.tsx +62 -0
- package/src/components/KeybindsDialog.stories.tsx +31 -0
- package/src/components/KeybindsDialog.tsx +58 -0
- package/src/components/MarkerPopover.stories.tsx +58 -0
- package/src/components/MarkerPopover.tsx +108 -0
- package/src/components/MenuBar.stories.tsx +37 -0
- package/src/components/MenuBar.tsx +74 -0
- package/src/components/PlanSheet.stories.tsx +113 -0
- package/src/components/PlanSheet.tsx +456 -0
- package/src/components/PromptDialog.stories.tsx +36 -0
- package/src/components/PromptDialog.tsx +78 -0
- package/src/components/PrototypeSheet.stories.tsx +20 -0
- package/src/components/PrototypeSheet.tsx +358 -0
- package/src/components/ReviewPanel.stories.tsx +86 -0
- package/src/components/ReviewPanel.tsx +101 -0
- package/src/components/ReviewRail.stories.tsx +218 -0
- package/src/components/ReviewRail.tsx +317 -0
- package/src/components/SettingsDialog.stories.tsx +111 -0
- package/src/components/SettingsDialog.tsx +141 -0
- package/src/components/SettingsRows.stories.tsx +18 -0
- package/src/components/SettingsRows.tsx +108 -0
- package/src/components/Toast.stories.tsx +12 -0
- package/src/components/Toast.tsx +44 -0
- package/src/components/WalkWizard.stories.tsx +100 -0
- package/src/components/WalkWizard.tsx +152 -0
- package/src/components/__snapshots__/stories.test.tsx.snap +1857 -0
- package/src/components/agent-launcher.stories.tsx +26 -0
- package/src/components/agent-launcher.test.tsx +49 -0
- package/src/components/agent-launcher.tsx +147 -0
- package/src/components/diff-sheet-layout.test.ts +127 -0
- package/src/components/diff-sheet-layout.ts +167 -0
- package/src/components/primitives/Button.stories.tsx +32 -0
- package/src/components/primitives/Button.tsx +51 -0
- package/src/components/primitives/Card.stories.tsx +25 -0
- package/src/components/primitives/Card.tsx +59 -0
- package/src/components/primitives/Dialog.stories.tsx +24 -0
- package/src/components/primitives/Dialog.tsx +64 -0
- package/src/components/primitives/StatusBar.stories.tsx +11 -0
- package/src/components/primitives/StatusBar.tsx +22 -0
- package/src/components/primitives/Tabs.stories.tsx +29 -0
- package/src/components/primitives/Tabs.tsx +98 -0
- package/src/components/primitives/Toolbar.stories.tsx +17 -0
- package/src/components/primitives/Toolbar.tsx +14 -0
- package/src/components/primitives/frame.test.ts +12 -0
- package/src/components/primitives/frame.ts +14 -0
- package/src/components/quick-actions-editor.stories.tsx +54 -0
- package/src/components/quick-actions-editor.tsx +136 -0
- package/src/components/stories-app.tsx +123 -0
- package/src/components/stories.test.tsx +62 -0
- package/src/components/story-fixtures.ts +98 -0
- package/src/components/story.ts +69 -0
- package/src/components/syntax-highlight.ts +92 -0
- package/src/components/terminal-pane.test.tsx +40 -0
- package/src/components/terminal-pane.ts +181 -0
- package/src/components/theme-context.stories.tsx +46 -0
- package/src/components/theme-context.tsx +36 -0
- package/src/components/truncate-text.ts +6 -0
- package/src/config.test.ts +430 -31
- package/src/config.ts +304 -26
- package/src/diff-hunk-curate.test.ts +315 -0
- package/src/diff-hunk-curate.ts +233 -0
- package/src/diff-intraline.test.ts +164 -0
- package/src/diff-intraline.ts +132 -0
- package/src/diff-syntax.test.ts +96 -0
- package/src/diff-syntax.ts +154 -0
- package/src/editor.test.ts +143 -0
- package/src/editor.ts +123 -9
- package/src/ghostty-terminal.test.ts +82 -0
- package/src/ghostty-terminal.ts +168 -0
- package/src/herdr.test.ts +41 -0
- package/src/herdr.ts +27 -0
- package/src/index.ts +10 -0
- package/src/integrations.test.ts +41 -0
- package/src/integrations.ts +30 -0
- package/src/intent-dispatch.test.ts +493 -0
- package/src/intent-dispatch.ts +428 -0
- package/src/key-bindings.test.ts +152 -0
- package/src/key-bindings.ts +430 -0
- package/src/keymap.test.ts +622 -0
- package/src/keymap.ts +339 -0
- package/src/kitty-image.test.ts +20 -0
- package/src/kitty-image.ts +75 -0
- package/src/prototype-browser.test.ts +55 -0
- package/src/prototype-browser.ts +243 -0
- package/src/pty.test.ts +78 -0
- package/src/pty.ts +222 -0
- package/src/review-panel.test.ts +113 -0
- package/src/review-panel.ts +83 -0
- package/src/run.ts +9 -5
- package/src/serve.test.ts +24 -9
- package/src/serve.ts +7 -7
- package/src/session-controller.curate.test.ts +253 -0
- package/src/session-controller.share.test.ts +309 -0
- package/src/session-controller.ts +914 -0
- package/src/share.ts +113 -0
- package/src/test-support.test.ts +55 -0
- package/src/test-support.ts +187 -0
- package/src/theme-presets.ts +168 -0
- package/src/theme.ts +38 -17
- package/src/version.ts +5 -0
- package/src/view-diff.test.ts +19 -8
- package/src/view-diff.ts +34 -23
- package/src/view-plan.regression.test.ts +60 -0
- package/src/view-plan.test.ts +399 -0
- package/src/view-plan.ts +495 -0
- package/src/walk.test.ts +121 -0
- package/src/walk.ts +70 -0
- package/src/view.test.ts +0 -157
- package/src/view.ts +0 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DARK } from "../theme";
|
|
3
|
+
import type { Story, StoryMeta } from "./story";
|
|
4
|
+
import { ReviewRail } from "./ReviewRail";
|
|
5
|
+
import { FIXTURE_ANNOTATIONS, fixtureDiffSession, fixturePlanSession } from "./story-fixtures";
|
|
6
|
+
|
|
7
|
+
export const meta: StoryMeta = { title: "ReviewRail" };
|
|
8
|
+
|
|
9
|
+
const callbacks = {
|
|
10
|
+
curationItems: [],
|
|
11
|
+
onTabChange: () => {},
|
|
12
|
+
onSelectCard: () => {},
|
|
13
|
+
onActivateCard: () => {},
|
|
14
|
+
onSelectCuration: () => {},
|
|
15
|
+
onUndoCuration: () => {},
|
|
16
|
+
onSubmitRequest: () => {},
|
|
17
|
+
onLaunchHarness: () => {},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** The rail expects a height-constrained parent, like the app's main row. */
|
|
21
|
+
function RailFrame({ children }: { children: React.ReactNode }): React.ReactNode {
|
|
22
|
+
return <box style={{ flexDirection: "row", width: "100%", height: "100%" }}>{children}</box>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const AnnotationStack: Story = {
|
|
26
|
+
render: () => (
|
|
27
|
+
<RailFrame>
|
|
28
|
+
<ReviewRail
|
|
29
|
+
session={fixturePlanSession()}
|
|
30
|
+
authorNames={{}}
|
|
31
|
+
selectedId={FIXTURE_ANNOTATIONS[0]!.id}
|
|
32
|
+
resolvedIds={new Set(FIXTURE_ANNOTATIONS.map((annotation) => annotation.id))}
|
|
33
|
+
railTab="review"
|
|
34
|
+
pendingCount={2}
|
|
35
|
+
cardEdit={null}
|
|
36
|
+
submitConfirm={null}
|
|
37
|
+
{...callbacks}
|
|
38
|
+
/>
|
|
39
|
+
</RailFrame>
|
|
40
|
+
),
|
|
41
|
+
expectedColors: [DARK.accent],
|
|
42
|
+
size: { width: 40, height: 24 },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const MixedOwnershipStack: Story = {
|
|
46
|
+
render: () => (
|
|
47
|
+
<RailFrame>
|
|
48
|
+
<ReviewRail
|
|
49
|
+
session={fixturePlanSession({
|
|
50
|
+
participants: [{ id: "SHA256:collab1", provider: "ssh", name: "Priya" }],
|
|
51
|
+
annotations: [
|
|
52
|
+
{
|
|
53
|
+
id: "own_note",
|
|
54
|
+
kind: "comment",
|
|
55
|
+
anchor: { quote: "persists sessions", prefix: "The daemon ", suffix: " to disk" },
|
|
56
|
+
body: "Which daemon owns this?",
|
|
57
|
+
createdAt: "2026-01-01T00:00:00Z",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "collab_note",
|
|
61
|
+
kind: "comment",
|
|
62
|
+
anchor: { quote: "move the store", prefix: "", suffix: "" },
|
|
63
|
+
body: "move it behind one interface",
|
|
64
|
+
author: "SHA256:collab1",
|
|
65
|
+
createdAt: "2026-01-01T00:00:01Z",
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
})}
|
|
69
|
+
authorNames={{}}
|
|
70
|
+
selectedId="own_note"
|
|
71
|
+
resolvedIds={new Set(["own_note", "collab_note"])}
|
|
72
|
+
railTab="review"
|
|
73
|
+
pendingCount={2}
|
|
74
|
+
cardEdit={null}
|
|
75
|
+
submitConfirm={null}
|
|
76
|
+
{...callbacks}
|
|
77
|
+
/>
|
|
78
|
+
</RailFrame>
|
|
79
|
+
),
|
|
80
|
+
// every annotation border is accent now
|
|
81
|
+
expectedColors: [DARK.accent],
|
|
82
|
+
size: { width: 40, height: 24 },
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const Removals: Story = {
|
|
86
|
+
render: () => (
|
|
87
|
+
<RailFrame>
|
|
88
|
+
<ReviewRail
|
|
89
|
+
session={fixtureDiffSession()}
|
|
90
|
+
authorNames={{}}
|
|
91
|
+
resolvedIds={null}
|
|
92
|
+
railTab="review"
|
|
93
|
+
pendingCount={0}
|
|
94
|
+
cardEdit={null}
|
|
95
|
+
submitConfirm={null}
|
|
96
|
+
{...callbacks}
|
|
97
|
+
curationItems={[
|
|
98
|
+
{
|
|
99
|
+
id: "diff:src/store.ts#0#1",
|
|
100
|
+
source: "diff",
|
|
101
|
+
preview: ["- private items = [];", "+ private items = new Map();"],
|
|
102
|
+
revealIndex: 3,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: "diff:src/store.ts#1#hunk",
|
|
106
|
+
source: "diff",
|
|
107
|
+
preview: ["- return null;", "+ return fallback();", "+ log(fallback);"],
|
|
108
|
+
revealIndex: 9,
|
|
109
|
+
},
|
|
110
|
+
]}
|
|
111
|
+
selectedCurationId="diff:src/store.ts#0#1"
|
|
112
|
+
/>
|
|
113
|
+
</RailFrame>
|
|
114
|
+
),
|
|
115
|
+
expectedColors: [DARK.red],
|
|
116
|
+
size: { width: 40, height: 24 },
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/** A plan cut and an annotation interleave in one line-ordered stack. */
|
|
120
|
+
export const InterleavedStack: Story = {
|
|
121
|
+
render: () => (
|
|
122
|
+
<RailFrame>
|
|
123
|
+
<ReviewRail
|
|
124
|
+
session={fixturePlanSession()}
|
|
125
|
+
authorNames={{}}
|
|
126
|
+
selectedId={FIXTURE_ANNOTATIONS[0]!.id}
|
|
127
|
+
resolvedIds={new Set(FIXTURE_ANNOTATIONS.map((annotation) => annotation.id))}
|
|
128
|
+
railTab="review"
|
|
129
|
+
pendingCount={2}
|
|
130
|
+
cardEdit={null}
|
|
131
|
+
submitConfirm={null}
|
|
132
|
+
{...callbacks}
|
|
133
|
+
curationItems={[
|
|
134
|
+
{
|
|
135
|
+
id: "plan:6-6",
|
|
136
|
+
source: "plan",
|
|
137
|
+
preview: ["- add recovery"],
|
|
138
|
+
revealIndex: 1,
|
|
139
|
+
},
|
|
140
|
+
]}
|
|
141
|
+
annotationPositions={new Map([[FIXTURE_ANNOTATIONS[0]!.id, 5]])}
|
|
142
|
+
/>
|
|
143
|
+
</RailFrame>
|
|
144
|
+
),
|
|
145
|
+
expectedColors: [DARK.accent],
|
|
146
|
+
size: { width: 40, height: 24 },
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const AgentTab: Story = {
|
|
150
|
+
render: () => (
|
|
151
|
+
<RailFrame>
|
|
152
|
+
<ReviewRail
|
|
153
|
+
session={fixturePlanSession()}
|
|
154
|
+
authorNames={{}}
|
|
155
|
+
resolvedIds={new Set()}
|
|
156
|
+
railTab="agent"
|
|
157
|
+
pendingCount={2}
|
|
158
|
+
cardEdit={null}
|
|
159
|
+
submitConfirm={null}
|
|
160
|
+
{...callbacks}
|
|
161
|
+
/>
|
|
162
|
+
</RailFrame>
|
|
163
|
+
),
|
|
164
|
+
size: { width: 40, height: 24 },
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const SubmitConfirmOpen: Story = {
|
|
168
|
+
render: () => (
|
|
169
|
+
<RailFrame>
|
|
170
|
+
<ReviewRail
|
|
171
|
+
session={fixturePlanSession()}
|
|
172
|
+
authorNames={{}}
|
|
173
|
+
resolvedIds={new Set()}
|
|
174
|
+
railTab="review"
|
|
175
|
+
pendingCount={2}
|
|
176
|
+
cardEdit={null}
|
|
177
|
+
submitConfirm={{
|
|
178
|
+
verdict: "request_changes",
|
|
179
|
+
summary: "",
|
|
180
|
+
onInput: () => {},
|
|
181
|
+
onSelectVerdict: () => {},
|
|
182
|
+
onSubmit: () => {},
|
|
183
|
+
onCancel: () => {},
|
|
184
|
+
}}
|
|
185
|
+
{...callbacks}
|
|
186
|
+
/>
|
|
187
|
+
</RailFrame>
|
|
188
|
+
),
|
|
189
|
+
expectedColors: [DARK.red],
|
|
190
|
+
size: { width: 40, height: 30 },
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export const Resolved: Story = {
|
|
194
|
+
render: () => (
|
|
195
|
+
<RailFrame>
|
|
196
|
+
<ReviewRail
|
|
197
|
+
session={fixturePlanSession({
|
|
198
|
+
status: "resolved",
|
|
199
|
+
verdict: {
|
|
200
|
+
kind: "approve",
|
|
201
|
+
summary: "",
|
|
202
|
+
feedback: "",
|
|
203
|
+
resolvedAt: "2026-01-01T00:00:00Z",
|
|
204
|
+
},
|
|
205
|
+
})}
|
|
206
|
+
authorNames={{}}
|
|
207
|
+
resolvedIds={new Set()}
|
|
208
|
+
railTab="review"
|
|
209
|
+
pendingCount={0}
|
|
210
|
+
cardEdit={null}
|
|
211
|
+
submitConfirm={null}
|
|
212
|
+
{...callbacks}
|
|
213
|
+
/>
|
|
214
|
+
</RailFrame>
|
|
215
|
+
),
|
|
216
|
+
expectedColors: [DARK.green],
|
|
217
|
+
size: { width: 40, height: 24 },
|
|
218
|
+
};
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The right review rail: tab strip (Review/Agent), the scrollable annotation
|
|
3
|
+
* stack, and the pinned submit affordance. The confirm card sits OUTSIDE the
|
|
4
|
+
* scrollbox so the stack scrolls while the card stays at the rail bottom.
|
|
5
|
+
* Card reveal goes through the scrollbox's own scrollChildIntoView - no
|
|
6
|
+
* hardcoded card-height arithmetic.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React, { forwardRef, useImperativeHandle, useRef } from "react";
|
|
10
|
+
import { createTextAttributes, type ScrollBoxRenderable } from "@opentui/core";
|
|
11
|
+
import { isAddressed, isAgentNote, type Annotation, type ReviewSession } from "@cueloop/schema";
|
|
12
|
+
import type { CurationItem } from "../session-controller";
|
|
13
|
+
import type { Theme } from "../theme";
|
|
14
|
+
import { useComponentTheme } from "./theme-context";
|
|
15
|
+
import { Tabs, Tab, TabList } from "./primitives/Tabs";
|
|
16
|
+
import { Button } from "./primitives/Button";
|
|
17
|
+
import { Toolbar } from "./primitives/Toolbar";
|
|
18
|
+
import { AnnotationCard, type AnnotationDraft } from "./AnnotationCard";
|
|
19
|
+
import { ConfirmCard, type ConfirmCardProps } from "./ConfirmCard";
|
|
20
|
+
import { AgentLauncher, type AgentTerminalHandle } from "./agent-launcher";
|
|
21
|
+
import { Card } from "./primitives/Card";
|
|
22
|
+
import { truncateToSingleLine } from "./truncate-text";
|
|
23
|
+
import { resolveDisplayName } from "../attribution";
|
|
24
|
+
|
|
25
|
+
export type RailTab = "review" | "agent";
|
|
26
|
+
|
|
27
|
+
export interface RailCardEdit extends AnnotationDraft {
|
|
28
|
+
id: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ReviewRailHandle {
|
|
32
|
+
/** Scroll the card for an annotation into view (selection symmetry). */
|
|
33
|
+
revealCard(annotationId: string): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ReviewRailProps {
|
|
37
|
+
session: ReviewSession;
|
|
38
|
+
/** Planner-local author renames (config [authors]); override the registry name. */
|
|
39
|
+
authorNames: Record<string, string>;
|
|
40
|
+
selectedId?: string;
|
|
41
|
+
/** Ids whose anchor resolved; null = orphan display off (diff view). */
|
|
42
|
+
resolvedIds: Set<string> | null;
|
|
43
|
+
/** Removed pieces (diff rejections / plan cuts) interleaved into the card stack. */
|
|
44
|
+
curationItems: CurationItem[];
|
|
45
|
+
/** The selected curation item, highlighted and the undo target. */
|
|
46
|
+
selectedCurationId?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Sort position per annotation id (diff row index / plan display index), so
|
|
49
|
+
* annotation and removal cards interleave in one position-ordered stack.
|
|
50
|
+
*/
|
|
51
|
+
annotationPositions?: Map<string, number>;
|
|
52
|
+
railTab: RailTab;
|
|
53
|
+
pendingCount: number;
|
|
54
|
+
cardEdit: RailCardEdit | null;
|
|
55
|
+
submitConfirm: Omit<ConfirmCardProps, "theme"> | null;
|
|
56
|
+
onTabChange: (tab: RailTab) => void;
|
|
57
|
+
onSelectCard: (id: string) => void;
|
|
58
|
+
onActivateCard: (id: string) => void;
|
|
59
|
+
/** Select a curation item (reveals its diff row); pressing undo restores it. */
|
|
60
|
+
onSelectCuration: (id: string) => void;
|
|
61
|
+
/** Restore a curation item (the selected card's undo button, same as the u key). */
|
|
62
|
+
onUndoCuration: (id: string) => void;
|
|
63
|
+
onSubmitRequest: () => void;
|
|
64
|
+
/** Launch a bring-your-own harness in the rail (Agent tab); seedText is the plan-context briefing. */
|
|
65
|
+
onLaunchHarness: (command: string, seedText?: string) => void;
|
|
66
|
+
/** In-tab agent terminal handle (embedded path); null when detached. Lets the app route keys to it. */
|
|
67
|
+
onAgentTerminal?: (handle: AgentTerminalHandle | null) => void;
|
|
68
|
+
/** Rail column width; the app derives it from the persisted review layout. */
|
|
69
|
+
width?: number;
|
|
70
|
+
/**
|
|
71
|
+
* When set, renders the muted `>` chevron pinned at the rail's bottom-left,
|
|
72
|
+
* one column from the divider. Clicking it collapses the panel to compact.
|
|
73
|
+
*/
|
|
74
|
+
onCollapse?: () => void;
|
|
75
|
+
theme?: Theme;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const ReviewRail = forwardRef<ReviewRailHandle, ReviewRailProps>(function ReviewRail(
|
|
79
|
+
{
|
|
80
|
+
session,
|
|
81
|
+
authorNames,
|
|
82
|
+
selectedId,
|
|
83
|
+
resolvedIds,
|
|
84
|
+
curationItems,
|
|
85
|
+
selectedCurationId,
|
|
86
|
+
annotationPositions,
|
|
87
|
+
railTab,
|
|
88
|
+
cardEdit,
|
|
89
|
+
submitConfirm,
|
|
90
|
+
onTabChange,
|
|
91
|
+
onSelectCard,
|
|
92
|
+
onActivateCard,
|
|
93
|
+
onSelectCuration,
|
|
94
|
+
onUndoCuration,
|
|
95
|
+
onSubmitRequest,
|
|
96
|
+
onLaunchHarness,
|
|
97
|
+
onAgentTerminal,
|
|
98
|
+
width = 34,
|
|
99
|
+
onCollapse,
|
|
100
|
+
theme,
|
|
101
|
+
}: ReviewRailProps,
|
|
102
|
+
handleRef,
|
|
103
|
+
): React.ReactNode {
|
|
104
|
+
const tokens = useComponentTheme(theme);
|
|
105
|
+
const scrollRef = useRef<ScrollBoxRenderable | null>(null);
|
|
106
|
+
// addressed annotations leave the card list; a dim count keeps them honest
|
|
107
|
+
const openAnnotations = session.annotations.filter((annotation) => !isAddressed(annotation));
|
|
108
|
+
const addressedCount = session.annotations.length - openAnnotations.length;
|
|
109
|
+
|
|
110
|
+
useImperativeHandle(handleRef, () => ({
|
|
111
|
+
revealCard: (annotationId: string): void => {
|
|
112
|
+
try {
|
|
113
|
+
scrollRef.current?.scrollChildIntoView(`annotation-card-${annotationId}`);
|
|
114
|
+
} catch {
|
|
115
|
+
// reveal is best-effort; selection state is already correct
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
}));
|
|
119
|
+
|
|
120
|
+
const renderAnnotationCard = (annotation: Annotation): React.ReactNode => (
|
|
121
|
+
<AnnotationCard
|
|
122
|
+
key={annotation.id}
|
|
123
|
+
id={`annotation-card-${annotation.id}`}
|
|
124
|
+
kind={annotation.kind}
|
|
125
|
+
quote={annotation.anchor.quote}
|
|
126
|
+
theme={theme}
|
|
127
|
+
saved={{
|
|
128
|
+
body: annotation.body,
|
|
129
|
+
isSelected: annotation.id === selectedId,
|
|
130
|
+
isOrphan: resolvedIds !== null && !resolvedIds.has(annotation.id),
|
|
131
|
+
// border-title author: a collaborator's name, "agent" for agent notes, else "me"
|
|
132
|
+
author: annotation.author
|
|
133
|
+
? resolveDisplayName(annotation.author, session.participants, authorNames)
|
|
134
|
+
: isAgentNote(annotation)
|
|
135
|
+
? "agent"
|
|
136
|
+
: "me",
|
|
137
|
+
tone: tokens.blue,
|
|
138
|
+
editing:
|
|
139
|
+
cardEdit && cardEdit.id === annotation.id
|
|
140
|
+
? {
|
|
141
|
+
text: cardEdit.text,
|
|
142
|
+
onInput: cardEdit.onInput,
|
|
143
|
+
onSave: cardEdit.onSave,
|
|
144
|
+
onCancel: cardEdit.onCancel,
|
|
145
|
+
}
|
|
146
|
+
: null,
|
|
147
|
+
onPress: () =>
|
|
148
|
+
annotation.id === selectedId
|
|
149
|
+
? onActivateCard(annotation.id)
|
|
150
|
+
: onSelectCard(annotation.id),
|
|
151
|
+
}}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// one position-ordered stack: annotation and removal cards interleaved by their
|
|
156
|
+
// source line (diff row / plan block), original order breaking ties
|
|
157
|
+
const railEntries: { sort: number; order: number; node: React.ReactNode }[] = [
|
|
158
|
+
...openAnnotations.map((annotation, order) => ({
|
|
159
|
+
sort: annotationPositions?.get(annotation.id) ?? Number.MAX_SAFE_INTEGER,
|
|
160
|
+
order,
|
|
161
|
+
node: renderAnnotationCard(annotation),
|
|
162
|
+
})),
|
|
163
|
+
...curationItems.map((item, index) => ({
|
|
164
|
+
sort: item.revealIndex,
|
|
165
|
+
order: openAnnotations.length + index,
|
|
166
|
+
node: (
|
|
167
|
+
<RemovalCard
|
|
168
|
+
key={item.id}
|
|
169
|
+
item={item}
|
|
170
|
+
isSelected={item.id === selectedCurationId}
|
|
171
|
+
onSelect={onSelectCuration}
|
|
172
|
+
onUndo={onUndoCuration}
|
|
173
|
+
theme={theme}
|
|
174
|
+
/>
|
|
175
|
+
),
|
|
176
|
+
})),
|
|
177
|
+
].sort((left, right) => left.sort - right.sort || left.order - right.order);
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<box
|
|
181
|
+
style={{
|
|
182
|
+
width,
|
|
183
|
+
backgroundColor: tokens.panel,
|
|
184
|
+
flexDirection: "column",
|
|
185
|
+
paddingBottom: 1,
|
|
186
|
+
}}
|
|
187
|
+
>
|
|
188
|
+
<Tabs
|
|
189
|
+
selectedKey={railTab}
|
|
190
|
+
onSelectionChange={(key) => onTabChange(key as RailTab)}
|
|
191
|
+
theme={theme}
|
|
192
|
+
>
|
|
193
|
+
<TabList>
|
|
194
|
+
<Tab id="review">Review</Tab>
|
|
195
|
+
<Tab id="agent">Agent</Tab>
|
|
196
|
+
</TabList>
|
|
197
|
+
</Tabs>
|
|
198
|
+
{railTab === "agent" ? (
|
|
199
|
+
<box style={{ flexGrow: 1, flexDirection: "column" }}>
|
|
200
|
+
<AgentLauncher
|
|
201
|
+
session={session}
|
|
202
|
+
onLaunchHarness={onLaunchHarness}
|
|
203
|
+
onAgentTerminal={onAgentTerminal}
|
|
204
|
+
theme={theme}
|
|
205
|
+
/>
|
|
206
|
+
</box>
|
|
207
|
+
) : openAnnotations.length === 0 && curationItems.length === 0 ? (
|
|
208
|
+
<box style={{ flexGrow: 1, alignItems: "center", justifyContent: "center" }}>
|
|
209
|
+
<text fg={tokens.textDim}>
|
|
210
|
+
{session.annotations.length === 0 ? "no annotations yet" : "all annotations addressed"}
|
|
211
|
+
</text>
|
|
212
|
+
</box>
|
|
213
|
+
) : (
|
|
214
|
+
<box style={{ flexGrow: 1, flexDirection: "column" }}>
|
|
215
|
+
{addressedCount > 0 ? (
|
|
216
|
+
<text fg={tokens.textDim}>✓ {addressedCount} addressed by revision</text>
|
|
217
|
+
) : null}
|
|
218
|
+
<scrollbox ref={scrollRef} style={{ flexGrow: 1 }} focused={false}>
|
|
219
|
+
{railEntries.map((entry) => entry.node)}
|
|
220
|
+
</scrollbox>
|
|
221
|
+
</box>
|
|
222
|
+
)}
|
|
223
|
+
{/* the confirm card keeps full width, above the footer row */}
|
|
224
|
+
{railTab !== "agent" && submitConfirm ? (
|
|
225
|
+
<ConfirmCard {...submitConfirm} theme={theme} />
|
|
226
|
+
) : null}
|
|
227
|
+
{/* footer row: collapse chevron left-bound, the submit affordance inline
|
|
228
|
+
beside it, both on the rail's last row (the plan's bottom-border height) */}
|
|
229
|
+
<box style={{ flexDirection: "row", alignItems: "center", justifyContent: "space-between" }}>
|
|
230
|
+
{onCollapse ? (
|
|
231
|
+
<box onMouseUp={onCollapse}>
|
|
232
|
+
<text fg={tokens.textDim}>{">"}</text>
|
|
233
|
+
</box>
|
|
234
|
+
) : null}
|
|
235
|
+
{railTab !== "agent" && !submitConfirm ? (
|
|
236
|
+
session.status === "resolved" ? (
|
|
237
|
+
<text fg={tokens.green}>resolved: {session.verdict!.kind.replace("_", " ")}</text>
|
|
238
|
+
) : (
|
|
239
|
+
<Button variant="accent-text" onPress={onSubmitRequest} theme={theme}>
|
|
240
|
+
Submit review
|
|
241
|
+
</Button>
|
|
242
|
+
)
|
|
243
|
+
) : null}
|
|
244
|
+
</box>
|
|
245
|
+
</box>
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
/** A removal preview reads as removed content: struck through and dimmed. */
|
|
250
|
+
const REMOVAL_ATTRIBUTES = createTextAttributes({ strikethrough: true, dim: true });
|
|
251
|
+
|
|
252
|
+
/** Preview lines a removal card shows before it collapses to a "+N more" row. */
|
|
253
|
+
const REMOVAL_PREVIEW_LINES = 4;
|
|
254
|
+
|
|
255
|
+
/** Rough content width inside a removal card's border + padding, for truncation. */
|
|
256
|
+
const REMOVAL_PREVIEW_WIDTH = 24;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* A removed piece as a full display card - the same border/padding/selection
|
|
260
|
+
* chrome as a saved annotation card - previewing the removed content struck
|
|
261
|
+
* through. Unified across diff (a curated-out hunk/change) and plan (a cut
|
|
262
|
+
* block). Clicking selects (App reveals its source line); the undo key restores.
|
|
263
|
+
*/
|
|
264
|
+
function RemovalCard({
|
|
265
|
+
item,
|
|
266
|
+
isSelected,
|
|
267
|
+
onSelect,
|
|
268
|
+
onUndo,
|
|
269
|
+
theme,
|
|
270
|
+
}: {
|
|
271
|
+
item: CurationItem;
|
|
272
|
+
isSelected: boolean;
|
|
273
|
+
onSelect: (id: string) => void;
|
|
274
|
+
onUndo: (id: string) => void;
|
|
275
|
+
theme?: Theme;
|
|
276
|
+
}): React.ReactNode {
|
|
277
|
+
const tokens = useComponentTheme(theme);
|
|
278
|
+
const previewLines = item.preview.slice(0, REMOVAL_PREVIEW_LINES);
|
|
279
|
+
const overflow = item.preview.length - previewLines.length;
|
|
280
|
+
// body = the struck-through preview (at least one row) + an overflow row, plus
|
|
281
|
+
// the undo button's own row when selected (mirrors the draft card's Save/Cancel)
|
|
282
|
+
const contentRows =
|
|
283
|
+
Math.max(1, previewLines.length) + (overflow > 0 ? 1 : 0) + (isSelected ? 1 : 0);
|
|
284
|
+
// border = "what + who": a diff reject or a plan cut, always the reviewer's own
|
|
285
|
+
const title = ` ${item.source === "diff" ? "REJECT" : "CUT"} · me `;
|
|
286
|
+
return (
|
|
287
|
+
<box id={`removal-card-${item.id}`} onMouseUp={() => onSelect(item.id)}>
|
|
288
|
+
<Card
|
|
289
|
+
title={title}
|
|
290
|
+
contentRows={contentRows}
|
|
291
|
+
borderColor={tokens.red}
|
|
292
|
+
backgroundColor="transparent"
|
|
293
|
+
theme={theme}
|
|
294
|
+
>
|
|
295
|
+
{previewLines.length === 0 ? (
|
|
296
|
+
<text fg={tokens.textDim}> </text>
|
|
297
|
+
) : (
|
|
298
|
+
previewLines.map((line, lineIndex) => (
|
|
299
|
+
<text key={lineIndex} fg={tokens.textDim}>
|
|
300
|
+
<span attributes={REMOVAL_ATTRIBUTES}>
|
|
301
|
+
{truncateToSingleLine(line, REMOVAL_PREVIEW_WIDTH)}
|
|
302
|
+
</span>
|
|
303
|
+
</text>
|
|
304
|
+
))
|
|
305
|
+
)}
|
|
306
|
+
{overflow > 0 ? <text fg={tokens.textDim}>{` …+${overflow} more`}</text> : null}
|
|
307
|
+
{isSelected ? (
|
|
308
|
+
<Toolbar>
|
|
309
|
+
<Button variant="solid" onPress={() => onUndo(item.id)} theme={theme}>
|
|
310
|
+
{" undo "}
|
|
311
|
+
</Button>
|
|
312
|
+
</Toolbar>
|
|
313
|
+
) : null}
|
|
314
|
+
</Card>
|
|
315
|
+
</box>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DARK } from "../theme";
|
|
3
|
+
import { THEME_PRESETS } from "../theme-presets";
|
|
4
|
+
import type { Story, StoryMeta } from "./story";
|
|
5
|
+
import { SettingsDialog, type SettingsCategory } from "./SettingsDialog";
|
|
6
|
+
|
|
7
|
+
export const meta: StoryMeta = { title: "SettingsDialog" };
|
|
8
|
+
|
|
9
|
+
const CATEGORIES: SettingsCategory[] = [
|
|
10
|
+
{
|
|
11
|
+
id: "general",
|
|
12
|
+
name: "General",
|
|
13
|
+
description: "identity and submission",
|
|
14
|
+
rows: [
|
|
15
|
+
{ key: "displayName", label: "Display name", kind: "text" },
|
|
16
|
+
{
|
|
17
|
+
key: "autoClose",
|
|
18
|
+
label: "Auto-close on submit",
|
|
19
|
+
kind: "cycle",
|
|
20
|
+
options: ["off", "3s", "on"],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "display",
|
|
26
|
+
name: "Display",
|
|
27
|
+
description: "plan width and chrome",
|
|
28
|
+
rows: [
|
|
29
|
+
{
|
|
30
|
+
key: "planWidth",
|
|
31
|
+
label: "Plan width",
|
|
32
|
+
kind: "cycle",
|
|
33
|
+
options: ["default", "wide", "full"],
|
|
34
|
+
},
|
|
35
|
+
{ key: "showLineNumbers", label: "Line numbers", kind: "toggle" },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "appearance",
|
|
40
|
+
name: "Appearance",
|
|
41
|
+
description: "the color theme",
|
|
42
|
+
rows: [
|
|
43
|
+
{
|
|
44
|
+
key: "theme",
|
|
45
|
+
label: "Theme",
|
|
46
|
+
kind: "cycle",
|
|
47
|
+
options: ["cueloop", "Rosé Pine Moon", "Nord"],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
const VALUES = {
|
|
54
|
+
displayName: "amber-heron",
|
|
55
|
+
autoClose: "3s",
|
|
56
|
+
planWidth: "default",
|
|
57
|
+
showLineNumbers: true,
|
|
58
|
+
theme: "Rosé Pine Moon",
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const NavZone: Story = {
|
|
62
|
+
render: () => (
|
|
63
|
+
<SettingsDialog
|
|
64
|
+
isOpen
|
|
65
|
+
categories={CATEGORIES}
|
|
66
|
+
values={VALUES}
|
|
67
|
+
activeCategoryId="general"
|
|
68
|
+
activeRowIndex={0}
|
|
69
|
+
activeZone="nav"
|
|
70
|
+
onCategorySelect={() => {}}
|
|
71
|
+
onRowActivate={() => {}}
|
|
72
|
+
/>
|
|
73
|
+
),
|
|
74
|
+
expectedColors: [DARK.accent],
|
|
75
|
+
size: { width: 100, height: 30 },
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const BodyZone: Story = {
|
|
79
|
+
render: () => (
|
|
80
|
+
<SettingsDialog
|
|
81
|
+
isOpen
|
|
82
|
+
categories={CATEGORIES}
|
|
83
|
+
values={VALUES}
|
|
84
|
+
activeCategoryId="display"
|
|
85
|
+
activeRowIndex={1}
|
|
86
|
+
activeZone="body"
|
|
87
|
+
onCategorySelect={() => {}}
|
|
88
|
+
onRowActivate={() => {}}
|
|
89
|
+
/>
|
|
90
|
+
),
|
|
91
|
+
expectedColors: [DARK.green],
|
|
92
|
+
size: { width: 100, height: 30 },
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const AppearanceThemed: Story = {
|
|
96
|
+
render: () => (
|
|
97
|
+
<SettingsDialog
|
|
98
|
+
isOpen
|
|
99
|
+
categories={CATEGORIES}
|
|
100
|
+
values={VALUES}
|
|
101
|
+
activeCategoryId="appearance"
|
|
102
|
+
activeRowIndex={0}
|
|
103
|
+
activeZone="body"
|
|
104
|
+
onCategorySelect={() => {}}
|
|
105
|
+
onRowActivate={() => {}}
|
|
106
|
+
theme={THEME_PRESETS["rose-pine-moon"]}
|
|
107
|
+
/>
|
|
108
|
+
),
|
|
109
|
+
expectedColors: [THEME_PRESETS["rose-pine-moon"].accent],
|
|
110
|
+
size: { width: 100, height: 30 },
|
|
111
|
+
};
|