@cueloop/client 0.1.0-alpha.6 → 0.1.0-alpha.61
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 +37 -33
- package/src/App.appearance.test.tsx +51 -0
- package/src/App.autoclose.test.tsx +73 -47
- package/src/App.diff.test.tsx +169 -22
- package/src/App.export.test.tsx +49 -37
- package/src/App.plan-review.test.tsx +714 -0
- package/src/App.prototype.test.tsx +194 -0
- package/src/App.readonly.test.tsx +69 -35
- package/src/App.rendering.test.tsx +59 -31
- package/src/App.review-panel.test.tsx +143 -0
- package/src/App.submit-confirm.test.tsx +229 -0
- package/src/App.test.tsx +139 -68
- package/src/App.toast.test.tsx +77 -0
- package/src/App.tsx +0 -0
- package/src/App.walk.test.tsx +299 -0
- package/src/__snapshots__/view-plan.regression.test.ts.snap +100 -0
- package/src/app-key-state.ts +61 -0
- package/src/app-screens.tsx +270 -0
- package/src/app-view-model.ts +307 -0
- package/src/attribution.test.ts +31 -0
- package/src/attribution.ts +42 -0
- package/src/clipboard.test.ts +23 -0
- package/src/clipboard.ts +33 -0
- package/src/components/AnnotationCard.compose-rows.test.ts +49 -0
- package/src/components/AnnotationCard.stories.tsx +94 -0
- package/src/components/AnnotationCard.tsx +250 -0
- package/src/components/Breadcrumb.stories.tsx +19 -0
- package/src/components/Breadcrumb.tsx +45 -0
- package/src/components/CodeBlock.stories.tsx +42 -0
- package/src/components/CodeBlock.tsx +84 -0
- package/src/components/CompletionOverlay.stories.tsx +23 -0
- package/src/components/CompletionOverlay.tsx +60 -0
- package/src/components/ConfirmCard.stories.tsx +35 -0
- package/src/components/ConfirmCard.tsx +129 -0
- package/src/components/ConfirmDialog.stories.tsx +21 -0
- package/src/components/ConfirmDialog.tsx +66 -0
- package/src/components/DiffSheet.scroll.test.tsx +135 -0
- package/src/components/DiffSheet.stories.tsx +78 -0
- package/src/components/DiffSheet.syntax.test.tsx +65 -0
- package/src/components/DiffSheet.tsx +374 -0
- package/src/components/InboxList.stories.tsx +31 -0
- package/src/components/InboxList.tsx +64 -0
- package/src/components/KeybindsDialog.stories.tsx +31 -0
- package/src/components/KeybindsDialog.tsx +59 -0
- package/src/components/MarkerPopover.stories.tsx +58 -0
- package/src/components/MarkerPopover.tsx +109 -0
- package/src/components/MenuBar.stories.tsx +37 -0
- package/src/components/MenuBar.tsx +75 -0
- package/src/components/PlanSheet.stories.tsx +113 -0
- package/src/components/PlanSheet.tsx +422 -0
- package/src/components/PromptDialog.stories.tsx +36 -0
- package/src/components/PromptDialog.tsx +80 -0
- package/src/components/PrototypeSheet.stories.tsx +20 -0
- package/src/components/PrototypeSheet.tsx +450 -0
- package/src/components/ReviewPanel.stories.tsx +86 -0
- package/src/components/ReviewPanel.tsx +103 -0
- package/src/components/ReviewRail.stories.tsx +218 -0
- package/src/components/ReviewRail.tsx +318 -0
- package/src/components/SettingsDialog.stories.tsx +111 -0
- package/src/components/SettingsDialog.tsx +147 -0
- package/src/components/SettingsRows.stories.tsx +18 -0
- package/src/components/SettingsRows.tsx +112 -0
- package/src/components/Toast.stories.tsx +12 -0
- package/src/components/Toast.tsx +45 -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 +50 -0
- package/src/components/agent-launcher.tsx +149 -0
- package/src/components/diff-sheet-layout.test.ts +128 -0
- package/src/components/diff-sheet-layout.ts +184 -0
- package/src/components/plan-sheet-run-style.ts +90 -0
- package/src/components/primitives/Button.stories.tsx +32 -0
- package/src/components/primitives/Button.tsx +52 -0
- package/src/components/primitives/Card.stories.tsx +25 -0
- package/src/components/primitives/Card.tsx +60 -0
- package/src/components/primitives/Dialog.stories.tsx +24 -0
- package/src/components/primitives/Dialog.tsx +66 -0
- package/src/components/primitives/StatusBar.stories.tsx +11 -0
- package/src/components/primitives/StatusBar.tsx +23 -0
- package/src/components/primitives/Tabs.stories.tsx +29 -0
- package/src/components/primitives/Tabs.tsx +102 -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 +138 -0
- package/src/components/stories-app.tsx +124 -0
- package/src/components/stories.test.tsx +66 -0
- package/src/components/story-fixtures.ts +98 -0
- package/src/components/story.ts +75 -0
- package/src/components/syntax-highlight.ts +102 -0
- package/src/components/terminal-pane.test.tsx +40 -0
- package/src/components/terminal-pane.ts +193 -0
- package/src/components/theme-context.stories.tsx +46 -0
- package/src/components/theme-context.tsx +37 -0
- package/src/components/truncate-text.ts +7 -0
- package/src/config.test.ts +448 -31
- package/src/config.ts +339 -57
- package/src/diff-hunk-curate.test.ts +315 -0
- package/src/diff-hunk-curate.ts +253 -0
- package/src/diff-intraline.test.ts +165 -0
- package/src/diff-intraline.ts +146 -0
- package/src/diff-syntax.test.ts +96 -0
- package/src/diff-syntax.ts +176 -0
- package/src/editor.test.ts +149 -0
- package/src/editor.ts +135 -9
- package/src/ghostty-terminal.test.ts +84 -0
- package/src/ghostty-terminal.ts +176 -0
- package/src/herdr.test.ts +9 -34
- package/src/herdr.ts +17 -21
- package/src/index.ts +10 -0
- package/src/integrations.test.ts +41 -0
- package/src/integrations.ts +32 -0
- package/src/intent-dispatch.test.ts +499 -0
- package/src/intent-dispatch.ts +585 -0
- package/src/key-bindings.test.ts +156 -0
- package/src/key-bindings.ts +452 -0
- package/src/keymap.test.ts +635 -0
- package/src/keymap.ts +404 -0
- package/src/kitty-image.test.ts +66 -0
- package/src/kitty-image.ts +138 -0
- package/src/prototype-browser.test.ts +56 -0
- package/src/prototype-browser.ts +289 -0
- package/src/pty.test.ts +81 -0
- package/src/pty.ts +237 -0
- package/src/review-panel.test.ts +113 -0
- package/src/review-panel.ts +83 -0
- package/src/run.ts +16 -5
- package/src/serve.test.ts +25 -9
- package/src/serve.ts +19 -8
- package/src/session-controller.curate.test.ts +260 -0
- package/src/session-controller.share.test.ts +320 -0
- package/src/session-controller.ts +993 -0
- package/src/share.ts +120 -0
- package/src/test-support.test.ts +60 -0
- package/src/test-support.ts +197 -0
- package/src/theme-presets.test.ts +51 -0
- package/src/theme-presets.ts +187 -0
- package/src/theme.ts +64 -17
- package/src/use-settings-dialog.tsx +275 -0
- package/src/version.ts +5 -0
- package/src/view-diff.test.ts +22 -8
- package/src/view-diff.ts +39 -23
- package/src/view-plan.regression.test.ts +60 -0
- package/src/view-plan.test.ts +406 -0
- package/src/view-plan.ts +554 -0
- package/src/walk.test.ts +121 -0
- package/src/walk.ts +74 -0
- package/src/syntax.test.ts +0 -41
- package/src/syntax.ts +0 -88
- package/src/view.test.ts +0 -157
- package/src/view.ts +0 -0
package/src/clipboard.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort system clipboard. Each platform has its own tool; we try them in
|
|
3
|
+
* order and report whether one worked, so the caller can fall back to printing
|
|
4
|
+
* the line (the over-SSH case, where no clipboard tool exists). Mirrors how
|
|
5
|
+
* herdr confirms a copy.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** The clipboard-write commands to try, most-preferred first, for this platform. */
|
|
9
|
+
export function clipboardCommands(platform: NodeJS.Platform = process.platform): string[][] {
|
|
10
|
+
if (platform === "darwin") return [["pbcopy"]];
|
|
11
|
+
if (platform === "win32") return [["clip.exe"]];
|
|
12
|
+
|
|
13
|
+
return [["wl-copy"], ["xclip", "-selection", "clipboard"], ["xsel", "--clipboard", "--input"]];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Copy `text` to the clipboard; false when no tool is available or all fail. */
|
|
17
|
+
export async function copyToClipboard(text: string): Promise<boolean> {
|
|
18
|
+
for (const command of clipboardCommands()) {
|
|
19
|
+
try {
|
|
20
|
+
const proc = Bun.spawn(command, {
|
|
21
|
+
stdin: Buffer.from(text),
|
|
22
|
+
stdout: "ignore",
|
|
23
|
+
stderr: "ignore",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if ((await proc.exited) === 0) return true;
|
|
27
|
+
} catch {
|
|
28
|
+
// tool not installed - try the next one
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The composer's auto-grow row math as a pure function: hard newlines and soft
|
|
3
|
+
* wrapping both add rows, growth stops at the cap, and a non-positive width
|
|
4
|
+
* (before layout is known) degrades to a hard-newline count. The live textarea
|
|
5
|
+
* scrolls internally past the cap, so this only needs to get the growth curve
|
|
6
|
+
* and the ceiling right.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { describe, expect, test } from "bun:test";
|
|
10
|
+
import { COMPOSE_MAX_ROWS, composeRowCount } from "./AnnotationCard";
|
|
11
|
+
|
|
12
|
+
describe("composeRowCount", () => {
|
|
13
|
+
const width = 10;
|
|
14
|
+
|
|
15
|
+
test("empty and short text are one row", () => {
|
|
16
|
+
expect(composeRowCount("", width)).toBe(1);
|
|
17
|
+
expect(composeRowCount("hi", width)).toBe(1);
|
|
18
|
+
expect(composeRowCount("exactly-10", width)).toBe(1); // length 10 / width 10
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("hard newlines add rows", () => {
|
|
22
|
+
expect(composeRowCount("a\nb", width)).toBe(2);
|
|
23
|
+
expect(composeRowCount("a\nb\nc", width)).toBe(3);
|
|
24
|
+
// a blank trailing line still occupies a row
|
|
25
|
+
expect(composeRowCount("a\n", width)).toBe(2);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("a soft-wrapped long line grows the box", () => {
|
|
29
|
+
expect(composeRowCount("a".repeat(11), width)).toBe(2); // ceil(11/10)
|
|
30
|
+
expect(composeRowCount("a".repeat(25), width)).toBe(3); // ceil(25/10)
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("wrapping and hard newlines combine", () => {
|
|
34
|
+
// 1 row for "short" plus ceil(21/10)=3 rows for the long line
|
|
35
|
+
expect(composeRowCount("short\n" + "b".repeat(21), width)).toBe(4);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("growth is capped", () => {
|
|
39
|
+
expect(composeRowCount("a".repeat(100), width)).toBe(COMPOSE_MAX_ROWS);
|
|
40
|
+
expect(composeRowCount("l\ni\nn\ne\ns\nx", width)).toBe(COMPOSE_MAX_ROWS);
|
|
41
|
+
expect(composeRowCount("a\nb", width, 1)).toBe(1); // custom cap
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("a non-positive width counts hard newlines only, never divides by zero", () => {
|
|
45
|
+
expect(composeRowCount("a".repeat(100), 0)).toBe(1);
|
|
46
|
+
expect(composeRowCount("a\nb\nc", 0)).toBe(3);
|
|
47
|
+
expect(composeRowCount("a".repeat(100), -5)).toBe(1);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DARK } from "../theme";
|
|
3
|
+
import type { Story, StoryMeta } from "./story";
|
|
4
|
+
import { AnnotationCard } from "./AnnotationCard";
|
|
5
|
+
|
|
6
|
+
export const meta: StoryMeta = { title: "AnnotationCard" };
|
|
7
|
+
|
|
8
|
+
const draftCallbacks = { onInput: () => {}, onSave: () => {}, onCancel: () => {} };
|
|
9
|
+
|
|
10
|
+
export const CommentDraft: Story = {
|
|
11
|
+
render: () => (
|
|
12
|
+
<AnnotationCard
|
|
13
|
+
kind="comment"
|
|
14
|
+
quote="persists sessions"
|
|
15
|
+
draft={{ text: "Which daemon?", ...draftCallbacks }}
|
|
16
|
+
/>
|
|
17
|
+
),
|
|
18
|
+
expectedColors: [DARK.blue],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const SavedSelected: Story = {
|
|
22
|
+
render: () => (
|
|
23
|
+
<AnnotationCard
|
|
24
|
+
kind="comment"
|
|
25
|
+
quote="persists sessions"
|
|
26
|
+
saved={{
|
|
27
|
+
body: "Which daemon owns this?",
|
|
28
|
+
isSelected: true,
|
|
29
|
+
isOrphan: false,
|
|
30
|
+
author: "me",
|
|
31
|
+
tone: DARK.blue,
|
|
32
|
+
editing: null,
|
|
33
|
+
onPress: () => {},
|
|
34
|
+
}}
|
|
35
|
+
/>
|
|
36
|
+
),
|
|
37
|
+
expectedColors: [DARK.blue],
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const SavedCollaborator: Story = {
|
|
41
|
+
render: () => (
|
|
42
|
+
<AnnotationCard
|
|
43
|
+
kind="comment"
|
|
44
|
+
quote="persists sessions"
|
|
45
|
+
saved={{
|
|
46
|
+
body: "Which daemon owns this?",
|
|
47
|
+
isSelected: false,
|
|
48
|
+
isOrphan: false,
|
|
49
|
+
author: "Priya",
|
|
50
|
+
tone: DARK.blue,
|
|
51
|
+
editing: null,
|
|
52
|
+
onPress: () => {},
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
),
|
|
56
|
+
expectedColors: [DARK.blue],
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const SavedOrphan: Story = {
|
|
60
|
+
render: () => (
|
|
61
|
+
<AnnotationCard
|
|
62
|
+
kind="comment"
|
|
63
|
+
quote="a removed passage"
|
|
64
|
+
saved={{
|
|
65
|
+
body: "The passage is gone.",
|
|
66
|
+
isSelected: false,
|
|
67
|
+
isOrphan: true,
|
|
68
|
+
author: "me",
|
|
69
|
+
tone: DARK.blue,
|
|
70
|
+
editing: null,
|
|
71
|
+
onPress: () => {},
|
|
72
|
+
}}
|
|
73
|
+
/>
|
|
74
|
+
),
|
|
75
|
+
expectedColors: [DARK.blue],
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const SavedEditing: Story = {
|
|
79
|
+
render: () => (
|
|
80
|
+
<AnnotationCard
|
|
81
|
+
kind="comment"
|
|
82
|
+
quote="move the store"
|
|
83
|
+
saved={{
|
|
84
|
+
body: "old body",
|
|
85
|
+
isSelected: true,
|
|
86
|
+
isOrphan: false,
|
|
87
|
+
author: "me",
|
|
88
|
+
tone: DARK.blue,
|
|
89
|
+
editing: { text: "new body", ...draftCallbacks },
|
|
90
|
+
onPress: () => {},
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
),
|
|
94
|
+
};
|
|
@@ -0,0 +1,250 @@
|
|
|
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
|
+
* When set, ⏎ in the textarea saves through this handler. The plan and diff
|
|
30
|
+
* composers leave it unset because the app keymap owns ⏎ there; the prototype
|
|
31
|
+
* composer sets it because the app keymap is suppressed while it is open.
|
|
32
|
+
*/
|
|
33
|
+
onSubmit?: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AnnotationSaved {
|
|
37
|
+
body: string;
|
|
38
|
+
isSelected: boolean;
|
|
39
|
+
isOrphan: boolean;
|
|
40
|
+
/** Border-title author: a collaborator's display name, or "me" for the reviewer's own note. */
|
|
41
|
+
author: string;
|
|
42
|
+
/** Border + title color for this card (comment cards read blue). */
|
|
43
|
+
tone: string;
|
|
44
|
+
/** Non-null while the card body is being rewritten in place. */
|
|
45
|
+
editing: AnnotationDraft | null;
|
|
46
|
+
onPress: () => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface AnnotationCardProps {
|
|
50
|
+
id?: string;
|
|
51
|
+
kind: string;
|
|
52
|
+
quote: string;
|
|
53
|
+
draft?: AnnotationDraft;
|
|
54
|
+
saved?: AnnotationSaved;
|
|
55
|
+
theme?: Theme;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* ⏎ submits (which keeps the textarea from inserting its default newline; the
|
|
60
|
+
* grammar owns the actual save). ⌥/Alt+⏎ and shift+⏎ insert a newline so the
|
|
61
|
+
* body can grow multiline without leaving the composer.
|
|
62
|
+
*
|
|
63
|
+
* Option/Alt reaches a binding as `meta`, not `option`: a binding key here is
|
|
64
|
+
* built from name+ctrl+shift+meta+super only, so the newline binding matches on
|
|
65
|
+
* `meta`. This also overrides the textarea default that maps meta+⏎ to submit.
|
|
66
|
+
*/
|
|
67
|
+
const COMPOSE_KEY_BINDINGS: KeyBinding[] = [
|
|
68
|
+
{ name: "return", action: "submit" },
|
|
69
|
+
{ name: "return", meta: true, action: "newline" },
|
|
70
|
+
{ name: "return", shift: true, action: "newline" },
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
/** The composer never grows past this many rows; beyond it the textarea scrolls. */
|
|
74
|
+
export const COMPOSE_MAX_ROWS = 4;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Visible row count for the composer, so a soft-wrapped long line grows the box
|
|
78
|
+
* just like a hard newline does. Each logical line takes `ceil(length /
|
|
79
|
+
* contentWidth)` visual rows (at least one), summed over the hard-newline lines
|
|
80
|
+
* and capped. A non-positive width (before layout is known) counts hard
|
|
81
|
+
* newlines only. Beyond the cap the textarea scrolls internally and keeps the
|
|
82
|
+
* caret line in view.
|
|
83
|
+
*/
|
|
84
|
+
export function composeRowCount(
|
|
85
|
+
text: string,
|
|
86
|
+
contentWidth: number,
|
|
87
|
+
cap: number = COMPOSE_MAX_ROWS,
|
|
88
|
+
): number {
|
|
89
|
+
const usableWidth = contentWidth > 0 ? contentWidth : Number.MAX_SAFE_INTEGER;
|
|
90
|
+
let visualRowCount = 0;
|
|
91
|
+
|
|
92
|
+
for (const line of text.split("\n")) {
|
|
93
|
+
visualRowCount += Math.max(1, Math.ceil(line.length / usableWidth));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return Math.min(cap, Math.max(1, visualRowCount));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function DraftEditor({
|
|
100
|
+
draft,
|
|
101
|
+
rows,
|
|
102
|
+
onRowsChange,
|
|
103
|
+
theme,
|
|
104
|
+
}: {
|
|
105
|
+
draft: AnnotationDraft;
|
|
106
|
+
/** Current visible height in rows; owned by the parent so the card frame agrees. */
|
|
107
|
+
rows: number;
|
|
108
|
+
onRowsChange: (rows: number) => void;
|
|
109
|
+
theme?: Theme;
|
|
110
|
+
}): React.ReactNode {
|
|
111
|
+
const tokens = useComponentTheme(theme);
|
|
112
|
+
const editorRef = useRef<TextareaRenderable | null>(null);
|
|
113
|
+
// re-edit opens with the caret after the existing body, like a text field
|
|
114
|
+
const initialTextLength = useRef(draft.text.length);
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
const editor = editorRef.current;
|
|
118
|
+
|
|
119
|
+
if (!editor) return;
|
|
120
|
+
editor.cursorOffset = initialTextLength.current;
|
|
121
|
+
// the box is laid out now, so its width is known: size to the wrapped body
|
|
122
|
+
onRowsChange(composeRowCount(editor.plainText, editor.width));
|
|
123
|
+
}, [onRowsChange]);
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<>
|
|
127
|
+
<textarea
|
|
128
|
+
ref={editorRef}
|
|
129
|
+
focused
|
|
130
|
+
initialValue={draft.text}
|
|
131
|
+
placeholder="write a note..."
|
|
132
|
+
keyBindings={COMPOSE_KEY_BINDINGS}
|
|
133
|
+
{...(draft.onSubmit ? { onSubmit: draft.onSubmit } : {})}
|
|
134
|
+
onContentChange={() => {
|
|
135
|
+
const editor = editorRef.current;
|
|
136
|
+
|
|
137
|
+
if (!editor) return;
|
|
138
|
+
draft.onInput(editor.plainText);
|
|
139
|
+
onRowsChange(composeRowCount(editor.plainText, editor.width));
|
|
140
|
+
}}
|
|
141
|
+
style={{
|
|
142
|
+
height: rows,
|
|
143
|
+
backgroundColor: "transparent",
|
|
144
|
+
focusedBackgroundColor: "transparent",
|
|
145
|
+
textColor: tokens.text,
|
|
146
|
+
focusedTextColor: tokens.text,
|
|
147
|
+
}}
|
|
148
|
+
/>
|
|
149
|
+
<Toolbar>
|
|
150
|
+
<Button variant="solid" marginRight={2} onPress={draft.onSave} theme={theme}>
|
|
151
|
+
{" Save "}
|
|
152
|
+
</Button>
|
|
153
|
+
<Button onPress={draft.onCancel} theme={theme}>
|
|
154
|
+
{" Cancel "}
|
|
155
|
+
</Button>
|
|
156
|
+
</Toolbar>
|
|
157
|
+
</>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function AnnotationCard({
|
|
162
|
+
id,
|
|
163
|
+
kind,
|
|
164
|
+
quote,
|
|
165
|
+
draft,
|
|
166
|
+
saved,
|
|
167
|
+
theme,
|
|
168
|
+
}: AnnotationCardProps): React.ReactNode {
|
|
169
|
+
const tokens = useComponentTheme(theme);
|
|
170
|
+
// the composer wears the same blue as the saved comment card it becomes
|
|
171
|
+
const kindColor = tokens.blue;
|
|
172
|
+
const activeDraft = draft ?? saved?.editing ?? null;
|
|
173
|
+
// The composer's visible height, grown from the wrapped text. It is shared
|
|
174
|
+
// with the card frame (contentRows) so the border never clips the textarea
|
|
175
|
+
// or the toolbar. Seeded from hard newlines, then corrected once the mounted
|
|
176
|
+
// textarea reports its measured width.
|
|
177
|
+
const [editorRowCount, setEditorRowCount] = useState(() =>
|
|
178
|
+
// Width 0 is the "layout not known yet" contract: count hard newlines only,
|
|
179
|
+
// until the mounted textarea reports its measured width below.
|
|
180
|
+
composeRowCount(activeDraft?.text ?? "", 0),
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
if (draft) {
|
|
184
|
+
const verb = "comment on";
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<Card
|
|
188
|
+
title={` ${verb} "${truncateToSingleLine(quote, 40)}" `}
|
|
189
|
+
contentRows={editorRowCount + 1}
|
|
190
|
+
borderColor={kindColor}
|
|
191
|
+
backgroundColor="transparent"
|
|
192
|
+
theme={theme}
|
|
193
|
+
>
|
|
194
|
+
<DraftEditor
|
|
195
|
+
draft={draft}
|
|
196
|
+
rows={editorRowCount}
|
|
197
|
+
onRowsChange={setEditorRowCount}
|
|
198
|
+
theme={theme}
|
|
199
|
+
/>
|
|
200
|
+
</Card>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
const card = saved!;
|
|
204
|
+
// border = "what + who" (+ an orphaned flag when the anchor no longer resolves)
|
|
205
|
+
const flags = card.isOrphan ? ["ORPHANED"] : [];
|
|
206
|
+
const title = ` ${[kind.toUpperCase(), card.author, ...flags].join(" · ")} `;
|
|
207
|
+
// every saved card is bordered, so the border + side padding always eat this width
|
|
208
|
+
const borderInset = 4;
|
|
209
|
+
// a bordered box must declare a height or it collapses: quote + body, or the editor
|
|
210
|
+
const contentRows = card.editing ? editorRowCount + 2 : 2;
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
<box
|
|
214
|
+
id={id}
|
|
215
|
+
title={title}
|
|
216
|
+
style={{
|
|
217
|
+
flexDirection: "column",
|
|
218
|
+
height: cardHeight(contentRows),
|
|
219
|
+
border: true,
|
|
220
|
+
borderStyle: FRAME_BORDER_STYLE,
|
|
221
|
+
// the border (and its title) always wears the card's tone - salmon for
|
|
222
|
+
// own notes, blue for a collaborator's; the card background stays
|
|
223
|
+
// transparent so it sits flat on the terminal theme. Selection reads
|
|
224
|
+
// from the quote line taking the card's tone (below) and from the
|
|
225
|
+
// matching text highlight in the document.
|
|
226
|
+
borderColor: card.tone,
|
|
227
|
+
backgroundColor: "transparent",
|
|
228
|
+
paddingLeft: 1,
|
|
229
|
+
paddingRight: 1,
|
|
230
|
+
}}
|
|
231
|
+
onMouseUp={card.onPress}
|
|
232
|
+
>
|
|
233
|
+
<text
|
|
234
|
+
fg={card.isSelected ? card.tone : tokens.textDim}
|
|
235
|
+
>{`"${truncateToSingleLine(quote, 26 - borderInset)}"`}</text>
|
|
236
|
+
{card.editing ? (
|
|
237
|
+
<DraftEditor
|
|
238
|
+
draft={card.editing}
|
|
239
|
+
rows={editorRowCount}
|
|
240
|
+
onRowsChange={setEditorRowCount}
|
|
241
|
+
theme={theme}
|
|
242
|
+
/>
|
|
243
|
+
) : (
|
|
244
|
+
<text fg={card.isOrphan ? tokens.textDim : tokens.textMuted}>
|
|
245
|
+
{truncateToSingleLine(card.body, 28 - borderInset)}
|
|
246
|
+
</text>
|
|
247
|
+
)}
|
|
248
|
+
</box>
|
|
249
|
+
);
|
|
250
|
+
}
|
|
@@ -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,45 @@
|
|
|
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
|
+
|
|
34
|
+
return (
|
|
35
|
+
<box style={{ height: 1, backgroundColor: tokens.panel, paddingLeft: 1, flexDirection: "row" }}>
|
|
36
|
+
<text fg={tokens.text}>
|
|
37
|
+
{items.map((item, index) => (
|
|
38
|
+
<span key={index} fg={toneColor(item.tone)}>
|
|
39
|
+
{index === 0 ? item.label : ` · ${item.label}`}
|
|
40
|
+
</span>
|
|
41
|
+
))}
|
|
42
|
+
</text>
|
|
43
|
+
</box>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -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,84 @@
|
|
|
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
|
+
|
|
47
|
+
return (
|
|
48
|
+
<box id={id} style={{ flexDirection: "column", marginTop }}>
|
|
49
|
+
<text>
|
|
50
|
+
<span fg={isCursor ? tokens.accent : tokens.textDim}>{isCursor ? "▎ " : " "}</span>
|
|
51
|
+
<span fg={tokens.textDim}>{language ?? "code"}</span>
|
|
52
|
+
{isAnnotated ? <span fg={tokens.accent}> ◆</span> : null}
|
|
53
|
+
{changeTag ? <span fg={tagColor}> [{changeTag}]</span> : null}
|
|
54
|
+
</text>
|
|
55
|
+
<box
|
|
56
|
+
style={{
|
|
57
|
+
flexDirection: "column",
|
|
58
|
+
backgroundColor: tokens.elevated,
|
|
59
|
+
paddingLeft: 2,
|
|
60
|
+
paddingRight: 2,
|
|
61
|
+
paddingTop: 1,
|
|
62
|
+
paddingBottom: 1,
|
|
63
|
+
marginLeft: 2,
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
{cut ? (
|
|
67
|
+
<text style={{ wrapMode: "none" }} selectable={false}>
|
|
68
|
+
<span fg={tokens.textDim} attributes={CUT_ATTRIBUTES}>
|
|
69
|
+
{content}
|
|
70
|
+
</span>
|
|
71
|
+
</text>
|
|
72
|
+
) : (
|
|
73
|
+
<code
|
|
74
|
+
content={content}
|
|
75
|
+
filetype={filetypeFor(language)}
|
|
76
|
+
syntaxStyle={syntaxStyleFor(tokens)}
|
|
77
|
+
selectable={false}
|
|
78
|
+
style={{ wrapMode: "none", fg: tokens.textMuted, bg: tokens.elevated }}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
</box>
|
|
82
|
+
</box>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -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
|
+
};
|