@cueloop/client 0.1.0-alpha.4 → 0.1.0-alpha.41
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.sh +56 -0
- package/native/darwin-arm64/libcueloopvt.dylib +0 -0
- package/native/src/shim.c +107 -0
- package/package.json +34 -24
- 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 +632 -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 +220 -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 +288 -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 +228 -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 +56 -0
- package/src/components/ConfirmCard.tsx +135 -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 +102 -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 +389 -0
- package/src/components/PromptDialog.stories.tsx +36 -0
- package/src/components/PromptDialog.tsx +78 -0
- package/src/components/ReviewPanel.stories.tsx +86 -0
- package/src/components/ReviewPanel.tsx +101 -0
- package/src/components/ReviewRail.stories.tsx +220 -0
- package/src/components/ReviewRail.tsx +324 -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 +1829 -0
- package/src/components/agent-launcher.stories.tsx +26 -0
- package/src/components/agent-launcher.test.tsx +21 -0
- package/src/components/agent-launcher.tsx +180 -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 +48 -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 +174 -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 +45 -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 +492 -0
- package/src/intent-dispatch.ts +428 -0
- package/src/key-bindings.test.ts +152 -0
- package/src/key-bindings.ts +424 -0
- package/src/keymap.test.ts +622 -0
- package/src/keymap.ts +339 -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 +900 -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 +36 -15
- 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.test.ts +294 -0
- package/src/view-plan.ts +408 -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,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One annotation component in three modes: a draft composer (bordered card
|
|
3
|
+
* inline in the document flow), a saved rail card, and the rail card editing
|
|
4
|
+
* its body in place. Compose, saved, and re-edit share this rendering path,
|
|
5
|
+
* so the kind-color and quote treatment can never drift between them.
|
|
6
|
+
*
|
|
7
|
+
* Bodies are multiline: the composer is a textarea (wrap, undo/redo). Plain ⏎
|
|
8
|
+
* stays the save key while ⌥/Alt+⏎ and shift+⏎ insert a new line (the Slack
|
|
9
|
+
* convention). The box auto-grows with the wrapped text up to a cap, then
|
|
10
|
+
* scrolls internally.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
14
|
+
import type { KeyBinding, TextareaRenderable } from "@opentui/core";
|
|
15
|
+
import type { Theme } from "../theme";
|
|
16
|
+
import { useComponentTheme } from "./theme-context";
|
|
17
|
+
import { Card, cardHeight } from "./primitives/Card";
|
|
18
|
+
import { FRAME_BORDER_STYLE } from "./primitives/frame";
|
|
19
|
+
import { Button } from "./primitives/Button";
|
|
20
|
+
import { Toolbar } from "./primitives/Toolbar";
|
|
21
|
+
import { truncateToSingleLine } from "./truncate-text";
|
|
22
|
+
|
|
23
|
+
export interface AnnotationDraft {
|
|
24
|
+
text: string;
|
|
25
|
+
onInput: (text: string) => void;
|
|
26
|
+
onSave: () => void;
|
|
27
|
+
onCancel: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface AnnotationSaved {
|
|
31
|
+
body: string;
|
|
32
|
+
isSelected: boolean;
|
|
33
|
+
isOrphan: boolean;
|
|
34
|
+
isBlocking: boolean;
|
|
35
|
+
/** Border-title author: a collaborator's display name, or "me" for the reviewer's own note. */
|
|
36
|
+
author: string;
|
|
37
|
+
/** Non-null while the card body is being rewritten in place. */
|
|
38
|
+
editing: AnnotationDraft | null;
|
|
39
|
+
onPress: () => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface AnnotationCardProps {
|
|
43
|
+
id?: string;
|
|
44
|
+
kind: string;
|
|
45
|
+
quote: string;
|
|
46
|
+
draft?: AnnotationDraft;
|
|
47
|
+
saved?: AnnotationSaved;
|
|
48
|
+
theme?: Theme;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* ⏎ submits (which keeps the textarea from inserting its default newline; the
|
|
53
|
+
* grammar owns the actual save). ⌥/Alt+⏎ and shift+⏎ insert a newline so the
|
|
54
|
+
* body can grow multiline without leaving the composer.
|
|
55
|
+
*
|
|
56
|
+
* Option/Alt reaches a binding as `meta`, not `option`: a binding key here is
|
|
57
|
+
* built from name+ctrl+shift+meta+super only, so the newline binding matches on
|
|
58
|
+
* `meta`. This also overrides the textarea default that maps meta+⏎ to submit.
|
|
59
|
+
*/
|
|
60
|
+
const COMPOSE_KEY_BINDINGS: KeyBinding[] = [
|
|
61
|
+
{ name: "return", action: "submit" },
|
|
62
|
+
{ name: "return", meta: true, action: "newline" },
|
|
63
|
+
{ name: "return", shift: true, action: "newline" },
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/** The composer never grows past this many rows; beyond it the textarea scrolls. */
|
|
67
|
+
export const COMPOSE_MAX_ROWS = 4;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Visible row count for the composer, so a soft-wrapped long line grows the box
|
|
71
|
+
* just like a hard newline does. Each logical line takes `ceil(length /
|
|
72
|
+
* contentWidth)` visual rows (at least one), summed over the hard-newline lines
|
|
73
|
+
* and capped. A non-positive width (before layout is known) counts hard
|
|
74
|
+
* newlines only. Beyond the cap the textarea scrolls internally and keeps the
|
|
75
|
+
* caret line in view.
|
|
76
|
+
*/
|
|
77
|
+
export function composeRowCount(
|
|
78
|
+
text: string,
|
|
79
|
+
contentWidth: number,
|
|
80
|
+
cap: number = COMPOSE_MAX_ROWS,
|
|
81
|
+
): number {
|
|
82
|
+
const usableWidth = contentWidth > 0 ? contentWidth : Number.MAX_SAFE_INTEGER;
|
|
83
|
+
let visualRowCount = 0;
|
|
84
|
+
for (const line of text.split("\n")) {
|
|
85
|
+
visualRowCount += Math.max(1, Math.ceil(line.length / usableWidth));
|
|
86
|
+
}
|
|
87
|
+
return Math.min(cap, Math.max(1, visualRowCount));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function DraftEditor({
|
|
91
|
+
draft,
|
|
92
|
+
rows,
|
|
93
|
+
onRowsChange,
|
|
94
|
+
theme,
|
|
95
|
+
}: {
|
|
96
|
+
draft: AnnotationDraft;
|
|
97
|
+
/** Current visible height in rows; owned by the parent so the card frame agrees. */
|
|
98
|
+
rows: number;
|
|
99
|
+
onRowsChange: (rows: number) => void;
|
|
100
|
+
theme?: Theme;
|
|
101
|
+
}): React.ReactNode {
|
|
102
|
+
const tokens = useComponentTheme(theme);
|
|
103
|
+
const editorRef = useRef<TextareaRenderable | null>(null);
|
|
104
|
+
// re-edit opens with the caret after the existing body, like a text field
|
|
105
|
+
const initialTextLength = useRef(draft.text.length);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const editor = editorRef.current;
|
|
108
|
+
if (!editor) return;
|
|
109
|
+
editor.cursorOffset = initialTextLength.current;
|
|
110
|
+
// the box is laid out now, so its width is known: size to the wrapped body
|
|
111
|
+
onRowsChange(composeRowCount(editor.plainText, editor.width));
|
|
112
|
+
}, [onRowsChange]);
|
|
113
|
+
return (
|
|
114
|
+
<>
|
|
115
|
+
<textarea
|
|
116
|
+
ref={editorRef}
|
|
117
|
+
focused
|
|
118
|
+
initialValue={draft.text}
|
|
119
|
+
placeholder="write a note..."
|
|
120
|
+
keyBindings={COMPOSE_KEY_BINDINGS}
|
|
121
|
+
onContentChange={() => {
|
|
122
|
+
const editor = editorRef.current;
|
|
123
|
+
if (!editor) return;
|
|
124
|
+
draft.onInput(editor.plainText);
|
|
125
|
+
onRowsChange(composeRowCount(editor.plainText, editor.width));
|
|
126
|
+
}}
|
|
127
|
+
style={{
|
|
128
|
+
height: rows,
|
|
129
|
+
backgroundColor: "transparent",
|
|
130
|
+
focusedBackgroundColor: "transparent",
|
|
131
|
+
textColor: tokens.text,
|
|
132
|
+
focusedTextColor: tokens.text,
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
<Toolbar>
|
|
136
|
+
<Button variant="solid" marginRight={2} onPress={draft.onSave} theme={theme}>
|
|
137
|
+
{" Save "}
|
|
138
|
+
</Button>
|
|
139
|
+
<Button onPress={draft.onCancel} theme={theme}>
|
|
140
|
+
{" Cancel "}
|
|
141
|
+
</Button>
|
|
142
|
+
</Toolbar>
|
|
143
|
+
</>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function AnnotationCard({
|
|
148
|
+
id,
|
|
149
|
+
kind,
|
|
150
|
+
quote,
|
|
151
|
+
draft,
|
|
152
|
+
saved,
|
|
153
|
+
theme,
|
|
154
|
+
}: AnnotationCardProps): React.ReactNode {
|
|
155
|
+
const tokens = useComponentTheme(theme);
|
|
156
|
+
const kindColor = tokens.accent;
|
|
157
|
+
const activeDraft = draft ?? saved?.editing ?? null;
|
|
158
|
+
// The composer's visible height, grown from the wrapped text. It is shared
|
|
159
|
+
// with the card frame (contentRows) so the border never clips the textarea
|
|
160
|
+
// or the toolbar. Seeded from hard newlines, then corrected once the mounted
|
|
161
|
+
// textarea reports its measured width.
|
|
162
|
+
const [editorRowCount, setEditorRowCount] = useState(() =>
|
|
163
|
+
// Width 0 is the "layout not known yet" contract: count hard newlines only,
|
|
164
|
+
// until the mounted textarea reports its measured width below.
|
|
165
|
+
composeRowCount(activeDraft?.text ?? "", 0),
|
|
166
|
+
);
|
|
167
|
+
if (draft) {
|
|
168
|
+
const verb = "comment on";
|
|
169
|
+
return (
|
|
170
|
+
<Card
|
|
171
|
+
title={` ${verb} "${truncateToSingleLine(quote, 40)}" `}
|
|
172
|
+
contentRows={editorRowCount + 1}
|
|
173
|
+
borderColor={kindColor}
|
|
174
|
+
backgroundColor="transparent"
|
|
175
|
+
theme={theme}
|
|
176
|
+
>
|
|
177
|
+
<DraftEditor
|
|
178
|
+
draft={draft}
|
|
179
|
+
rows={editorRowCount}
|
|
180
|
+
onRowsChange={setEditorRowCount}
|
|
181
|
+
theme={theme}
|
|
182
|
+
/>
|
|
183
|
+
</Card>
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
const card = saved!;
|
|
187
|
+
// border = "what + who" (+ any exceptional flag); body = the content only
|
|
188
|
+
const flags = [card.isBlocking ? "BLOCKING" : null, card.isOrphan ? "ORPHANED" : null].filter(
|
|
189
|
+
(flag): flag is string => flag !== null,
|
|
190
|
+
);
|
|
191
|
+
const title = ` ${[kind.toUpperCase(), card.author, ...flags].join(" · ")} `;
|
|
192
|
+
// every saved card is bordered, so the border + side padding always eat this width
|
|
193
|
+
const borderInset = 4;
|
|
194
|
+
// a bordered box must declare a height or it collapses: quote + body, or the editor
|
|
195
|
+
const contentRows = card.editing ? editorRowCount + 2 : 2;
|
|
196
|
+
return (
|
|
197
|
+
<box
|
|
198
|
+
id={id}
|
|
199
|
+
title={title}
|
|
200
|
+
style={{
|
|
201
|
+
flexDirection: "column",
|
|
202
|
+
height: cardHeight(contentRows),
|
|
203
|
+
border: true,
|
|
204
|
+
borderStyle: FRAME_BORDER_STYLE,
|
|
205
|
+
// cards stay transparent in every theme; selection is the bright
|
|
206
|
+
// kind-colored border, while unselected cards recede to a dim border
|
|
207
|
+
borderColor: card.isSelected || card.editing ? kindColor : tokens.border,
|
|
208
|
+
paddingLeft: 1,
|
|
209
|
+
paddingRight: 1,
|
|
210
|
+
}}
|
|
211
|
+
onMouseUp={card.onPress}
|
|
212
|
+
>
|
|
213
|
+
<text fg={tokens.textDim}>"{truncateToSingleLine(quote, 26 - borderInset)}"</text>
|
|
214
|
+
{card.editing ? (
|
|
215
|
+
<DraftEditor
|
|
216
|
+
draft={card.editing}
|
|
217
|
+
rows={editorRowCount}
|
|
218
|
+
onRowsChange={setEditorRowCount}
|
|
219
|
+
theme={theme}
|
|
220
|
+
/>
|
|
221
|
+
) : (
|
|
222
|
+
<text fg={card.isOrphan ? tokens.textDim : tokens.textMuted}>
|
|
223
|
+
{truncateToSingleLine(card.body, 28 - borderInset)}
|
|
224
|
+
</text>
|
|
225
|
+
)}
|
|
226
|
+
</box>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DARK } from "../theme";
|
|
3
|
+
import type { Story, StoryMeta } from "./story";
|
|
4
|
+
import { Breadcrumb } from "./Breadcrumb";
|
|
5
|
+
|
|
6
|
+
export const meta: StoryMeta = { title: "Breadcrumb" };
|
|
7
|
+
|
|
8
|
+
export const SessionHeader: Story = {
|
|
9
|
+
render: () => (
|
|
10
|
+
<Breadcrumb
|
|
11
|
+
items={[
|
|
12
|
+
{ label: "cueloop", tone: "accent" },
|
|
13
|
+
{ label: "Migration Plan · rev 2", tone: "dim" },
|
|
14
|
+
{ label: "resolved: approve", tone: "green" },
|
|
15
|
+
]}
|
|
16
|
+
/>
|
|
17
|
+
),
|
|
18
|
+
expectedColors: [DARK.accent, DARK.green],
|
|
19
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One-row breadcrumb trail: toned segments joined by " · " on the panel
|
|
3
|
+
* surface. The app header is a breadcrumb (product · artifact · revision)
|
|
4
|
+
* followed by state badges; each item picks a semantic tone.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from "react";
|
|
8
|
+
import type { Theme } from "../theme";
|
|
9
|
+
import { useComponentTheme } from "./theme-context";
|
|
10
|
+
|
|
11
|
+
export type BreadcrumbTone = "accent" | "dim" | "text" | "green";
|
|
12
|
+
|
|
13
|
+
export interface BreadcrumbItem {
|
|
14
|
+
label: string;
|
|
15
|
+
tone?: BreadcrumbTone;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface BreadcrumbProps {
|
|
19
|
+
items: BreadcrumbItem[];
|
|
20
|
+
theme?: Theme;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function Breadcrumb({ items, theme }: BreadcrumbProps): React.ReactNode {
|
|
24
|
+
const tokens = useComponentTheme(theme);
|
|
25
|
+
const toneColor = (tone?: BreadcrumbTone): string =>
|
|
26
|
+
tone === "accent"
|
|
27
|
+
? tokens.accent
|
|
28
|
+
: tone === "green"
|
|
29
|
+
? tokens.green
|
|
30
|
+
: tone === "text"
|
|
31
|
+
? tokens.text
|
|
32
|
+
: tokens.textDim;
|
|
33
|
+
return (
|
|
34
|
+
<box style={{ height: 1, backgroundColor: tokens.panel, paddingLeft: 1, flexDirection: "row" }}>
|
|
35
|
+
<text fg={tokens.text}>
|
|
36
|
+
{items.map((item, index) => (
|
|
37
|
+
<span key={index} fg={toneColor(item.tone)}>
|
|
38
|
+
{index === 0 ? item.label : ` · ${item.label}`}
|
|
39
|
+
</span>
|
|
40
|
+
))}
|
|
41
|
+
</text>
|
|
42
|
+
</box>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DARK } from "../theme";
|
|
3
|
+
import type { Story, StoryMeta } from "./story";
|
|
4
|
+
import { CodeBlock } from "./CodeBlock";
|
|
5
|
+
|
|
6
|
+
export const meta: StoryMeta = { title: "CodeBlock" };
|
|
7
|
+
|
|
8
|
+
const SNIPPET = `export function gate(full: number) {
|
|
9
|
+
// threshold
|
|
10
|
+
return full < 0.6 ? "blocked" : "clear";
|
|
11
|
+
}`;
|
|
12
|
+
|
|
13
|
+
export const Typescript: Story = {
|
|
14
|
+
render: () => <CodeBlock language="ts" content={SNIPPET} />,
|
|
15
|
+
expectedColors: [DARK.elevated],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const CursorAnnotatedEdited: Story = {
|
|
19
|
+
render: () => (
|
|
20
|
+
<CodeBlock
|
|
21
|
+
language="ts"
|
|
22
|
+
content={SNIPPET}
|
|
23
|
+
isCursor
|
|
24
|
+
isAnnotated
|
|
25
|
+
changeTag="edited"
|
|
26
|
+
marginTop={1}
|
|
27
|
+
/>
|
|
28
|
+
),
|
|
29
|
+
expectedColors: [DARK.accent],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const UnknownLanguage: Story = {
|
|
33
|
+
render: () => (
|
|
34
|
+
<CodeBlock language="brainfog" content={"plain verbatim lines\n with indentation"} />
|
|
35
|
+
),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** A cut code block: struck-through gray content, no [cut] tag. */
|
|
39
|
+
export const Cut: Story = {
|
|
40
|
+
render: () => <CodeBlock language="ts" content={SNIPPET} cut />,
|
|
41
|
+
expectedColors: [DARK.elevated],
|
|
42
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fenced code block: verbatim lines in a contained elevated box, highlighted
|
|
3
|
+
* by the native code renderable (tree-sitter). Unstyled text draws first, so
|
|
4
|
+
* the content never flashes empty while highlights resolve; unknown languages
|
|
5
|
+
* stay unstyled.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { createTextAttributes } from "@opentui/core";
|
|
10
|
+
import type { Theme } from "../theme";
|
|
11
|
+
import { useComponentTheme } from "./theme-context";
|
|
12
|
+
import { filetypeFor, syntaxStyleFor } from "./syntax-highlight";
|
|
13
|
+
|
|
14
|
+
/** A cut code block reads as removed: struck through and grayed, never red. */
|
|
15
|
+
const CUT_ATTRIBUTES = createTextAttributes({ strikethrough: true, dim: true });
|
|
16
|
+
|
|
17
|
+
export interface CodeBlockProps {
|
|
18
|
+
id?: string;
|
|
19
|
+
/** Markdown fence info string ("tsx", "python", ...). */
|
|
20
|
+
language?: string;
|
|
21
|
+
content: string;
|
|
22
|
+
isCursor?: boolean;
|
|
23
|
+
/** Vertical rhythm above the block. */
|
|
24
|
+
marginTop?: number;
|
|
25
|
+
isAnnotated?: boolean;
|
|
26
|
+
/** Working-copy change tag rendered after the language label. */
|
|
27
|
+
changeTag?: "new" | "edited";
|
|
28
|
+
/** A cut (removed) block: struck-through gray content, no tag. */
|
|
29
|
+
cut?: boolean;
|
|
30
|
+
theme?: Theme;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function CodeBlock({
|
|
34
|
+
id,
|
|
35
|
+
language,
|
|
36
|
+
content,
|
|
37
|
+
isCursor = false,
|
|
38
|
+
marginTop = 0,
|
|
39
|
+
isAnnotated = false,
|
|
40
|
+
changeTag,
|
|
41
|
+
cut = false,
|
|
42
|
+
theme,
|
|
43
|
+
}: CodeBlockProps): React.ReactNode {
|
|
44
|
+
const tokens = useComponentTheme(theme);
|
|
45
|
+
const tagColor = changeTag === "new" ? tokens.green : tokens.accent;
|
|
46
|
+
return (
|
|
47
|
+
<box id={id} style={{ flexDirection: "column", marginTop }}>
|
|
48
|
+
<text>
|
|
49
|
+
<span fg={isCursor ? tokens.accent : tokens.textDim}>{isCursor ? "▎ " : " "}</span>
|
|
50
|
+
<span fg={tokens.textDim}>{language ?? "code"}</span>
|
|
51
|
+
{isAnnotated ? <span fg={tokens.accent}> ◆</span> : null}
|
|
52
|
+
{changeTag ? <span fg={tagColor}> [{changeTag}]</span> : null}
|
|
53
|
+
</text>
|
|
54
|
+
<box
|
|
55
|
+
style={{
|
|
56
|
+
flexDirection: "column",
|
|
57
|
+
backgroundColor: tokens.elevated,
|
|
58
|
+
paddingLeft: 2,
|
|
59
|
+
paddingRight: 2,
|
|
60
|
+
paddingTop: 1,
|
|
61
|
+
paddingBottom: 1,
|
|
62
|
+
marginLeft: 2,
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
{cut ? (
|
|
66
|
+
<text style={{ wrapMode: "none" }} selectable={false}>
|
|
67
|
+
<span fg={tokens.textDim} attributes={CUT_ATTRIBUTES}>
|
|
68
|
+
{content}
|
|
69
|
+
</span>
|
|
70
|
+
</text>
|
|
71
|
+
) : (
|
|
72
|
+
<code
|
|
73
|
+
content={content}
|
|
74
|
+
filetype={filetypeFor(language)}
|
|
75
|
+
syntaxStyle={syntaxStyleFor(tokens)}
|
|
76
|
+
selectable={false}
|
|
77
|
+
style={{ wrapMode: "none", fg: tokens.textMuted, bg: tokens.elevated }}
|
|
78
|
+
/>
|
|
79
|
+
)}
|
|
80
|
+
</box>
|
|
81
|
+
</box>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DARK } from "../theme";
|
|
3
|
+
import type { Story, StoryMeta } from "./story";
|
|
4
|
+
import { CompletionOverlay } from "./CompletionOverlay";
|
|
5
|
+
|
|
6
|
+
export const meta: StoryMeta = { title: "CompletionOverlay" };
|
|
7
|
+
|
|
8
|
+
export const ApprovedPrompt: Story = {
|
|
9
|
+
render: () => <CompletionOverlay verdict="approve" completion={{ phase: "prompt" }} status="" />,
|
|
10
|
+
expectedColors: [DARK.green],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const FeedbackCounting: Story = {
|
|
14
|
+
render: () => (
|
|
15
|
+
<CompletionOverlay
|
|
16
|
+
verdict="request_changes"
|
|
17
|
+
completion={{ phase: "counting", remaining: 3 }}
|
|
18
|
+
status="exported to vault/cueloop/plan.md"
|
|
19
|
+
returnsTo="agent/worker-3"
|
|
20
|
+
/>
|
|
21
|
+
),
|
|
22
|
+
expectedColors: [DARK.accent],
|
|
23
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-submit hand-back overlay: the agent is unblocked, the reviewer either
|
|
3
|
+
* closes now, opts into auto-close, or dismisses back to the resolved view.
|
|
4
|
+
* The latest status line (e.g. the vault-export path) stays visible here.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from "react";
|
|
8
|
+
import type { VerdictKind } from "@cueloop/schema";
|
|
9
|
+
import type { Theme } from "../theme";
|
|
10
|
+
import { useComponentTheme } from "./theme-context";
|
|
11
|
+
|
|
12
|
+
export interface CompletionOverlayProps {
|
|
13
|
+
verdict: VerdictKind;
|
|
14
|
+
completion: { phase: "prompt" } | { phase: "counting"; remaining: number };
|
|
15
|
+
/** Latest status line (e.g. the vault-export path) stays visible here. */
|
|
16
|
+
status: string;
|
|
17
|
+
/** Where focus goes on close (the agent's pane), when known. */
|
|
18
|
+
returnsTo?: string;
|
|
19
|
+
theme?: Theme;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function CompletionOverlay({
|
|
23
|
+
verdict,
|
|
24
|
+
completion,
|
|
25
|
+
status,
|
|
26
|
+
returnsTo,
|
|
27
|
+
theme,
|
|
28
|
+
}: CompletionOverlayProps): React.ReactNode {
|
|
29
|
+
const tokens = useComponentTheme(theme);
|
|
30
|
+
const approved = verdict === "approve";
|
|
31
|
+
return (
|
|
32
|
+
<box
|
|
33
|
+
style={{
|
|
34
|
+
width: "100%",
|
|
35
|
+
height: "100%",
|
|
36
|
+
backgroundColor: tokens.background,
|
|
37
|
+
flexDirection: "column",
|
|
38
|
+
justifyContent: "center",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<text fg={approved ? tokens.green : tokens.accent}>
|
|
43
|
+
{approved ? "review approved" : "feedback sent"}
|
|
44
|
+
</text>
|
|
45
|
+
<text> </text>
|
|
46
|
+
<text fg={tokens.text}>
|
|
47
|
+
The agent has your {approved ? "approval" : "feedback"} and is unblocked.
|
|
48
|
+
</text>
|
|
49
|
+
{returnsTo ? <text fg={tokens.textDim}>returning to {returnsTo} on close</text> : null}
|
|
50
|
+
{status ? <text fg={tokens.textDim}>{status}</text> : null}
|
|
51
|
+
<text> </text>
|
|
52
|
+
<text fg={tokens.textDim}>
|
|
53
|
+
close [return]
|
|
54
|
+
{completion.phase === "counting" ? ` · closing in ${completion.remaining}s` : ""}
|
|
55
|
+
{" · return to plan [esc] · always [a]"}
|
|
56
|
+
</text>
|
|
57
|
+
</box>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DARK } from "../theme";
|
|
3
|
+
import type { Story, StoryMeta } from "./story";
|
|
4
|
+
import { ConfirmCard } from "./ConfirmCard";
|
|
5
|
+
|
|
6
|
+
export const meta: StoryMeta = { title: "ConfirmCard" };
|
|
7
|
+
|
|
8
|
+
const callbacks = {
|
|
9
|
+
onInput: () => {},
|
|
10
|
+
onSelectVerdict: () => {},
|
|
11
|
+
onSubmit: () => {},
|
|
12
|
+
onCancel: () => {},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const ApproveDefault: Story = {
|
|
16
|
+
render: () => (
|
|
17
|
+
<ConfirmCard
|
|
18
|
+
verdict="approve"
|
|
19
|
+
summary=""
|
|
20
|
+
annotationCount={0}
|
|
21
|
+
blockingCount={0}
|
|
22
|
+
{...callbacks}
|
|
23
|
+
/>
|
|
24
|
+
),
|
|
25
|
+
expectedColors: [DARK.green, DARK.accent],
|
|
26
|
+
size: { width: 40, height: 14 },
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const RequestChanges: Story = {
|
|
30
|
+
render: () => (
|
|
31
|
+
<ConfirmCard
|
|
32
|
+
verdict="request_changes"
|
|
33
|
+
summary="Tighten the steps."
|
|
34
|
+
annotationCount={3}
|
|
35
|
+
blockingCount={1}
|
|
36
|
+
{...callbacks}
|
|
37
|
+
/>
|
|
38
|
+
),
|
|
39
|
+
expectedColors: [DARK.red],
|
|
40
|
+
size: { width: 40, height: 14 },
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const WithViewedSummary: Story = {
|
|
44
|
+
render: () => (
|
|
45
|
+
<ConfirmCard
|
|
46
|
+
verdict="approve"
|
|
47
|
+
summary=""
|
|
48
|
+
annotationCount={1}
|
|
49
|
+
blockingCount={0}
|
|
50
|
+
viewedSummary="2/3 files viewed"
|
|
51
|
+
{...callbacks}
|
|
52
|
+
/>
|
|
53
|
+
),
|
|
54
|
+
expectedColors: [DARK.green, DARK.textDim],
|
|
55
|
+
size: { width: 40, height: 14 },
|
|
56
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Submit button expanded into a bordered confirm card at the rail bottom:
|
|
3
|
+
* honest counts, the verdict selector (arrow keys or click), the optional
|
|
4
|
+
* summary, and plain word-buttons - key hints live in the status line only.
|
|
5
|
+
* The bordered height derives from the content rows through Card, so layout
|
|
6
|
+
* and render never drift.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React from "react";
|
|
10
|
+
import type { VerdictKind } from "@cueloop/schema";
|
|
11
|
+
import type { Theme } from "../theme";
|
|
12
|
+
import { useComponentTheme } from "./theme-context";
|
|
13
|
+
import { Card } from "./primitives/Card";
|
|
14
|
+
import { Button } from "./primitives/Button";
|
|
15
|
+
import { Toolbar } from "./primitives/Toolbar";
|
|
16
|
+
|
|
17
|
+
export const VERDICTS: VerdictKind[] = ["comment", "approve", "request_changes"];
|
|
18
|
+
|
|
19
|
+
/** Selector words in the confirm card - one word per verdict. */
|
|
20
|
+
export const VERDICT_LABEL: Record<VerdictKind, string> = {
|
|
21
|
+
comment: "Comment",
|
|
22
|
+
approve: "Approve",
|
|
23
|
+
request_changes: "Changes",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export interface ConfirmCardProps {
|
|
27
|
+
verdict: VerdictKind;
|
|
28
|
+
summary: string;
|
|
29
|
+
annotationCount: number;
|
|
30
|
+
blockingCount: number;
|
|
31
|
+
/**
|
|
32
|
+
* The guided walk's honest coverage line for diff sessions, e.g.
|
|
33
|
+
* "2/3 files viewed". Undefined = no walk data, the row does not render.
|
|
34
|
+
*/
|
|
35
|
+
viewedSummary?: string;
|
|
36
|
+
onInput: (summary: string) => void;
|
|
37
|
+
onSelectVerdict: (verdict: VerdictKind) => void;
|
|
38
|
+
onSubmit: () => void;
|
|
39
|
+
onCancel: () => void;
|
|
40
|
+
theme?: Theme;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Counts, spacer, 1-row verdict selector, spacer, summary input, spacer, buttons. */
|
|
44
|
+
const CONFIRM_CONTENT_ROWS = 7;
|
|
45
|
+
|
|
46
|
+
export function verdictColor(verdict: VerdictKind, tokens: Theme): string {
|
|
47
|
+
return verdict === "approve"
|
|
48
|
+
? tokens.green
|
|
49
|
+
: verdict === "request_changes"
|
|
50
|
+
? tokens.red
|
|
51
|
+
: tokens.blue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The verdict selector: one row of pressable words, matching the reading
|
|
56
|
+
* direction of a choice between three peers. Selection stays controlled by
|
|
57
|
+
* the grammar (←/→ cycle the verdict); a click selects directly. The
|
|
58
|
+
* selected verdict wears brackets and its color.
|
|
59
|
+
*/
|
|
60
|
+
function VerdictSelector({
|
|
61
|
+
verdict,
|
|
62
|
+
onSelectVerdict,
|
|
63
|
+
theme,
|
|
64
|
+
}: {
|
|
65
|
+
verdict: VerdictKind;
|
|
66
|
+
onSelectVerdict: (verdict: VerdictKind) => void;
|
|
67
|
+
theme?: Theme;
|
|
68
|
+
}): React.ReactNode {
|
|
69
|
+
const tokens = useComponentTheme(theme);
|
|
70
|
+
return (
|
|
71
|
+
<box style={{ flexDirection: "row", height: 1 }}>
|
|
72
|
+
{VERDICTS.map((candidate) => (
|
|
73
|
+
<box
|
|
74
|
+
key={candidate}
|
|
75
|
+
style={{ paddingRight: 1 }}
|
|
76
|
+
onMouseUp={() => onSelectVerdict(candidate)}
|
|
77
|
+
>
|
|
78
|
+
<text fg={candidate === verdict ? verdictColor(candidate, tokens) : tokens.textDim}>
|
|
79
|
+
{candidate === verdict
|
|
80
|
+
? `[${VERDICT_LABEL[candidate]}]`
|
|
81
|
+
: ` ${VERDICT_LABEL[candidate]} `}
|
|
82
|
+
</text>
|
|
83
|
+
</box>
|
|
84
|
+
))}
|
|
85
|
+
</box>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function ConfirmCard({
|
|
90
|
+
verdict,
|
|
91
|
+
summary,
|
|
92
|
+
annotationCount,
|
|
93
|
+
blockingCount,
|
|
94
|
+
viewedSummary,
|
|
95
|
+
onInput,
|
|
96
|
+
onSelectVerdict,
|
|
97
|
+
onSubmit,
|
|
98
|
+
onCancel,
|
|
99
|
+
theme,
|
|
100
|
+
}: ConfirmCardProps): React.ReactNode {
|
|
101
|
+
const tokens = useComponentTheme(theme);
|
|
102
|
+
return (
|
|
103
|
+
<Card
|
|
104
|
+
title=" submit review "
|
|
105
|
+
contentRows={CONFIRM_CONTENT_ROWS + (viewedSummary !== undefined ? 1 : 0)}
|
|
106
|
+
borderColor={tokens.accent}
|
|
107
|
+
backgroundColor="transparent"
|
|
108
|
+
marginRight={1}
|
|
109
|
+
theme={theme}
|
|
110
|
+
>
|
|
111
|
+
<text
|
|
112
|
+
fg={tokens.textDim}
|
|
113
|
+
>{`${annotationCount} annotations · ${blockingCount} blocking`}</text>
|
|
114
|
+
{viewedSummary !== undefined ? <text fg={tokens.textDim}>{viewedSummary}</text> : null}
|
|
115
|
+
<box style={{ height: 1 }} />
|
|
116
|
+
<VerdictSelector verdict={verdict} onSelectVerdict={onSelectVerdict} theme={theme} />
|
|
117
|
+
<box style={{ height: 1 }} />
|
|
118
|
+
<input
|
|
119
|
+
focused
|
|
120
|
+
value={summary}
|
|
121
|
+
onInput={onInput}
|
|
122
|
+
placeholder="summary for the agent (optional)"
|
|
123
|
+
/>
|
|
124
|
+
<box style={{ height: 1 }} />
|
|
125
|
+
<Toolbar>
|
|
126
|
+
<Button variant="solid" marginRight={2} onPress={onSubmit} theme={theme}>
|
|
127
|
+
{" Submit "}
|
|
128
|
+
</Button>
|
|
129
|
+
<Button onPress={onCancel} theme={theme}>
|
|
130
|
+
{" Cancel "}
|
|
131
|
+
</Button>
|
|
132
|
+
</Toolbar>
|
|
133
|
+
</Card>
|
|
134
|
+
);
|
|
135
|
+
}
|