@cueloop/client 0.1.0-alpha.77 → 0.1.0-alpha.79
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/package.json +14 -13
- package/src/App.autoclose.test.tsx +3 -3
- package/src/App.diff.test.tsx +22 -5
- package/src/App.export.test.tsx +1 -2
- package/src/App.focus.test.ts +1 -59
- package/src/App.identity.test.tsx +3 -3
- package/src/App.plan-render.test.tsx +209 -0
- package/src/App.plan-review.test.tsx +91 -26
- package/src/App.readonly.test.tsx +6 -5
- package/src/App.share-dialog.test.tsx +172 -0
- package/src/App.submit-confirm.test.tsx +39 -8
- package/src/App.test.tsx +33 -30
- package/src/App.toast.test.tsx +11 -4
- package/src/App.tsx +263 -274
- package/src/App.walk.test.tsx +11 -10
- package/src/App.workbench.test.tsx +86 -0
- package/src/__snapshots__/view-plan.regression.test.ts.snap +1 -1
- package/src/annotation-palette.ts +1 -0
- package/src/ansi-screen.test.ts +28 -0
- package/src/ansi-screen.ts +72 -0
- package/src/app-screens.tsx +19 -9
- package/src/app-view-model.ts +3 -1
- package/src/components/AnnotatableFileView.tsx +1 -1
- package/src/components/AnnotationCards.tsx +18 -2
- package/src/components/AnsiScreen.stories.tsx +12 -0
- package/src/components/AnsiScreen.tsx +28 -0
- package/src/components/CompletionOverlay.stories.tsx +15 -1
- package/src/components/CompletionOverlay.tsx +22 -5
- package/src/components/ConfirmCard.stories.tsx +2 -0
- package/src/components/ConfirmCard.tsx +45 -18
- package/src/components/ConfirmDialog.stories.tsx +3 -3
- package/src/components/ConfirmDialog.tsx +11 -12
- package/src/components/DiffContentView.tsx +18 -11
- package/src/components/DiscussionMarkerRail.tsx +9 -4
- package/src/components/FileContentsView.tsx +1 -1
- package/src/components/GridTabContent.tsx +8 -2
- package/src/components/HandleChipsInput.stories.tsx +24 -0
- package/src/components/HandleChipsInput.test.tsx +35 -0
- package/src/components/HandleChipsInput.tsx +145 -0
- package/src/components/MarkdownGridBlock.stories.tsx +33 -0
- package/src/components/MarkdownGridBlock.tsx +72 -0
- package/src/components/MarkdownThreadEditor.stories.tsx +15 -0
- package/src/components/MarkdownThreadEditor.test.tsx +98 -0
- package/src/components/MarkdownThreadEditor.tsx +162 -0
- package/src/components/NavModeHint.stories.tsx +40 -0
- package/src/components/NavModeHint.tsx +31 -0
- package/src/components/PromptDialog.test.tsx +2 -2
- package/src/components/PromptDialog.tsx +9 -10
- package/src/components/SettingsDialog.tsx +1 -0
- package/src/components/ShareDialog.stories.tsx +121 -0
- package/src/components/ShareDialog.tsx +552 -0
- package/src/components/SlashComposer.stories.tsx +37 -0
- package/src/components/SlashComposer.tsx +87 -0
- package/src/components/ThreadFooter.tsx +4 -1
- package/src/components/ThreadTree.tsx +12 -7
- package/src/components/ThreadView.selection.test.tsx +88 -1
- package/src/components/ThreadView.slash.test.tsx +0 -36
- package/src/components/ThreadView.tsx +200 -67
- package/src/components/Toast.stories.tsx +7 -0
- package/src/components/Toast.tsx +15 -8
- package/src/components/WalkWizard.stories.tsx +2 -2
- package/src/components/WalkWizard.tsx +10 -12
- package/src/components/__snapshots__/stories.test.tsx.snap +436 -182
- package/src/components/primitives/Button.tsx +6 -2
- package/src/components/primitives/Card.tsx +5 -2
- package/src/components/primitives/Dialog.tsx +2 -2
- package/src/components/primitives/DialogActions.stories.tsx +20 -0
- package/src/components/primitives/DialogActions.tsx +39 -0
- package/src/components/primitives/Switch.stories.tsx +17 -0
- package/src/components/primitives/Switch.tsx +32 -0
- package/src/components/primitives/Tree.tsx +5 -1
- package/src/components/primitives/frame.ts +5 -0
- package/src/components/session-tree.ts +7 -6
- package/src/components/share-dialog-store.ts +58 -0
- package/src/components/stories-app.tsx +13 -4
- package/src/components/stories.test.tsx +12 -4
- package/src/components/story-tree.test.ts +32 -24
- package/src/components/story.ts +32 -15
- package/src/config.test.ts +18 -0
- package/src/config.ts +8 -1
- package/src/diff-fold.ts +1 -1
- package/src/diff-intraline.test.ts +75 -2
- package/src/diff-intraline.ts +95 -26
- package/src/intent-dispatch.test.ts +12 -3
- package/src/intent-dispatch.ts +10 -25
- package/src/key-bindings.ts +0 -6
- package/src/keymap.test.ts +2 -2
- package/src/keymap.ts +0 -2
- package/src/markdown-editor-syntax-style.ts +50 -0
- package/src/markdown-grid.test.ts +101 -0
- package/src/markdown-grid.ts +203 -0
- package/src/markdown-highlight.test.ts +61 -0
- package/src/markdown-highlight.ts +122 -0
- package/src/pasted-image.test.ts +67 -0
- package/src/pasted-image.ts +60 -0
- package/src/prototype-browser.test.ts +9 -1
- package/src/prototype-browser.ts +22 -0
- package/src/run.ts +39 -25
- package/src/serve.ts +1 -1
- package/src/share.ts +16 -2
- package/src/slash-palette.test.ts +17 -0
- package/src/slash-palette.ts +11 -0
- package/src/test-support.ts +14 -0
- package/src/thread-chords.test.ts +55 -178
- package/src/thread-chords.ts +78 -169
- package/src/thread-controller.curate.test.ts +1 -0
- package/src/thread-controller.derivation.test.ts +62 -0
- package/src/thread-controller.live-diff.test.ts +3 -0
- package/src/thread-controller.optimistic.test.ts +69 -0
- package/src/thread-controller.share.test.ts +60 -5
- package/src/thread-controller.switch-cache.test.ts +176 -0
- package/src/thread-controller.tree.test.ts +6 -1
- package/src/thread-controller.ts +386 -78
- package/src/use-annotation-surface.tsx +88 -63
- package/src/use-settings-dialog.tsx +14 -3
- package/src/use-thread-body-editing.tsx +58 -0
- package/src/view-plan.test.ts +56 -6
- package/src/view-plan.ts +154 -5
- package/src/App.share-choice.test.tsx +0 -105
- package/src/components/ManageAccessDialog.stories.tsx +0 -36
- package/src/components/ManageAccessDialog.test.tsx +0 -94
- package/src/components/ManageAccessDialog.tsx +0 -120
- package/src/components/ShareChoiceDialog.stories.tsx +0 -34
- package/src/components/ShareChoiceDialog.test.tsx +0 -103
- package/src/components/ShareChoiceDialog.tsx +0 -82
- package/src/components/ThreadsSidebar.stories.tsx +0 -36
- package/src/components/ThreadsSidebar.tsx +0 -71
- package/src/components/agent-launcher.stories.tsx +0 -26
- package/src/components/agent-launcher.test.tsx +0 -50
- package/src/components/agent-launcher.tsx +0 -149
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The share public/private choice, as an app-level overlay the share shortcut
|
|
3
|
-
* opens from any view. Public publishes a link for anyone; private opens the
|
|
4
|
-
* manage-access allowlist surface. The header share button and the shortcut both
|
|
5
|
-
* open this one surface. Selection moves with the keyboard (owned by the App) or
|
|
6
|
-
* a pointer click on a row.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import React from "react";
|
|
10
|
-
import { useTerminalDimensions } from "@opentui/react";
|
|
11
|
-
import type { Theme } from "../theme";
|
|
12
|
-
import { useComponentTheme } from "./theme-context";
|
|
13
|
-
import { Dialog } from "./primitives/Dialog";
|
|
14
|
-
|
|
15
|
-
export type ShareChoice = "public" | "private";
|
|
16
|
-
|
|
17
|
-
interface ShareChoiceRow {
|
|
18
|
-
choice: ShareChoice;
|
|
19
|
-
label: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const SHARE_CHOICES: ShareChoiceRow[] = [
|
|
23
|
-
{ choice: "public", label: "public link" },
|
|
24
|
-
{ choice: "private", label: "private link" },
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
export interface ShareChoiceDialogProps {
|
|
28
|
-
isOpen: boolean;
|
|
29
|
-
/** The highlighted row; the App drives it from the shareChoice mode. */
|
|
30
|
-
selectedIndex: number;
|
|
31
|
-
/** Publish a public link and copy its connection line. */
|
|
32
|
-
onPublicShare: () => void;
|
|
33
|
-
/** Open the private-share manage-access allowlist surface. */
|
|
34
|
-
onPrivateShare: () => void;
|
|
35
|
-
onClose: () => void;
|
|
36
|
-
theme?: Theme;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function ShareChoiceDialog({
|
|
40
|
-
isOpen,
|
|
41
|
-
selectedIndex,
|
|
42
|
-
onPublicShare,
|
|
43
|
-
onPrivateShare,
|
|
44
|
-
onClose,
|
|
45
|
-
theme,
|
|
46
|
-
}: ShareChoiceDialogProps): React.ReactNode {
|
|
47
|
-
const tokens = useComponentTheme(theme);
|
|
48
|
-
const { width: terminalWidth } = useTerminalDimensions();
|
|
49
|
-
|
|
50
|
-
const pick = (choice: ShareChoice): void => {
|
|
51
|
-
onClose();
|
|
52
|
-
if (choice === "public") onPublicShare();
|
|
53
|
-
else onPrivateShare();
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
if (!isOpen) return null;
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<Dialog
|
|
60
|
-
isOpen
|
|
61
|
-
title=" Share "
|
|
62
|
-
width={Math.min(46, terminalWidth - 6)}
|
|
63
|
-
height={7}
|
|
64
|
-
background={tokens.elevated}
|
|
65
|
-
onDismiss={onClose}
|
|
66
|
-
theme={theme}
|
|
67
|
-
>
|
|
68
|
-
<box style={{ flexDirection: "column", flexGrow: 1, paddingLeft: 1, paddingRight: 1 }}>
|
|
69
|
-
{SHARE_CHOICES.map((row, index) => (
|
|
70
|
-
<box key={row.choice} onMouseUp={() => pick(row.choice)} style={{ flexDirection: "row" }}>
|
|
71
|
-
<text fg={index === selectedIndex ? tokens.accent : tokens.text}>
|
|
72
|
-
{index === selectedIndex ? "› " : " "}
|
|
73
|
-
{row.label}
|
|
74
|
-
</text>
|
|
75
|
-
</box>
|
|
76
|
-
))}
|
|
77
|
-
<box style={{ flexGrow: 1 }} />
|
|
78
|
-
<text fg={tokens.textDim}>↑↓ choose · enter select · esc cancel</text>
|
|
79
|
-
</box>
|
|
80
|
-
</Dialog>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { DARK } from "../theme";
|
|
3
|
-
import type { Story, StoryMeta } from "./story";
|
|
4
|
-
import { ThreadsSidebar } from "./ThreadsSidebar";
|
|
5
|
-
import { groupInbox } from "./session-tree";
|
|
6
|
-
import { fixtureDiffSession, fixturePlanSession } from "./story-fixtures";
|
|
7
|
-
|
|
8
|
-
export const meta: StoryMeta = { title: "Surfaces/ThreadsSidebar" };
|
|
9
|
-
|
|
10
|
-
function Frame({ children }: { children: React.ReactNode }): React.ReactNode {
|
|
11
|
-
return <box style={{ width: "100%", height: "100%", flexDirection: "row" }}>{children}</box>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const plan = fixturePlanSession();
|
|
15
|
-
const projectPlan = {
|
|
16
|
-
...plan,
|
|
17
|
-
workspace: { ...plan.workspace, rootCommit: "root-1", remote: "git@github.com:acme/widget.git" },
|
|
18
|
-
};
|
|
19
|
-
const { rows, ordered } = groupInbox([projectPlan, fixtureDiffSession()]);
|
|
20
|
-
|
|
21
|
-
export const Open: Story = {
|
|
22
|
-
render: () => (
|
|
23
|
-
<Frame>
|
|
24
|
-
<ThreadsSidebar
|
|
25
|
-
open
|
|
26
|
-
rows={rows}
|
|
27
|
-
cursor={0}
|
|
28
|
-
activeId={ordered[0]!.id}
|
|
29
|
-
onSelect={() => {}}
|
|
30
|
-
theme={DARK}
|
|
31
|
-
/>
|
|
32
|
-
</Frame>
|
|
33
|
-
),
|
|
34
|
-
expectedColors: [DARK.accent, DARK.border],
|
|
35
|
-
size: { width: 60, height: 12 },
|
|
36
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// The left Projects and Threads column: a collapsible, scrollable tree beside the
|
|
2
|
-
// thread. A click jumps to that thread; the open thread stays highlighted. Renders
|
|
3
|
-
// nothing when collapsed so the thread reclaims the width.
|
|
4
|
-
|
|
5
|
-
import { ScrollArea } from "./ScrollArea";
|
|
6
|
-
import React from "react";
|
|
7
|
-
import type { Theme } from "../theme";
|
|
8
|
-
import { ThreadTree } from "./ThreadTree";
|
|
9
|
-
import type { InboxRow } from "./session-tree";
|
|
10
|
-
|
|
11
|
-
export interface ThreadsSidebarProps {
|
|
12
|
-
open: boolean;
|
|
13
|
-
rows: InboxRow[];
|
|
14
|
-
cursor: number;
|
|
15
|
-
/** The open thread's id, highlighted in the list. */
|
|
16
|
-
activeId?: string;
|
|
17
|
-
/** Ids of pinned threads. */
|
|
18
|
-
pinnedIds?: ReadonlySet<string>;
|
|
19
|
-
onSelect: (sessionId: string) => void;
|
|
20
|
-
/** Ask to delete a thread (the row menu's Delete, wired to the confirm dialog). */
|
|
21
|
-
onRequestDelete?: (id: string, title: string) => void;
|
|
22
|
-
/** Toggle a thread's pinned state (the row menu's Pin/Unpin). */
|
|
23
|
-
onPin?: (id: string) => void;
|
|
24
|
-
/** Rename a thread's title (the row menu's Rename). */
|
|
25
|
-
onRename?: (id: string, title: string) => void;
|
|
26
|
-
width?: number;
|
|
27
|
-
theme?: Theme;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function ThreadsSidebar({
|
|
31
|
-
open,
|
|
32
|
-
rows,
|
|
33
|
-
cursor,
|
|
34
|
-
activeId,
|
|
35
|
-
pinnedIds,
|
|
36
|
-
onSelect,
|
|
37
|
-
onRequestDelete,
|
|
38
|
-
onPin,
|
|
39
|
-
onRename,
|
|
40
|
-
width = 30,
|
|
41
|
-
theme,
|
|
42
|
-
}: ThreadsSidebarProps): React.ReactNode {
|
|
43
|
-
if (!open) return null;
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<box
|
|
47
|
-
style={{
|
|
48
|
-
width,
|
|
49
|
-
flexDirection: "column",
|
|
50
|
-
borderStyle: "single",
|
|
51
|
-
border: ["right"],
|
|
52
|
-
borderColor: theme?.border,
|
|
53
|
-
}}
|
|
54
|
-
>
|
|
55
|
-
<ScrollArea>
|
|
56
|
-
<ThreadTree
|
|
57
|
-
rows={rows}
|
|
58
|
-
cursor={cursor}
|
|
59
|
-
activeId={activeId}
|
|
60
|
-
pinnedIds={pinnedIds}
|
|
61
|
-
width={width}
|
|
62
|
-
onSelect={onSelect}
|
|
63
|
-
onRequestDelete={onRequestDelete}
|
|
64
|
-
onPin={onPin}
|
|
65
|
-
onRename={onRename}
|
|
66
|
-
theme={theme}
|
|
67
|
-
/>
|
|
68
|
-
</ScrollArea>
|
|
69
|
-
</box>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { DARK } from "../theme";
|
|
3
|
-
import type { Story, StoryMeta } from "./story";
|
|
4
|
-
import { AgentLauncher } from "./agent-launcher";
|
|
5
|
-
import { fixturePlanSession } from "./story-fixtures";
|
|
6
|
-
|
|
7
|
-
export const meta: StoryMeta = { title: "Chrome/AgentLauncher" };
|
|
8
|
-
|
|
9
|
-
/** The launcher expects the rail's narrow, height-constrained column. */
|
|
10
|
-
function RailFrame({ children }: { children: React.ReactNode }): React.ReactNode {
|
|
11
|
-
return (
|
|
12
|
-
<box style={{ width: 40, height: 24, paddingLeft: 2, backgroundColor: DARK.panel }}>
|
|
13
|
-
{children}
|
|
14
|
-
</box>
|
|
15
|
-
);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const Launcher: Story = {
|
|
19
|
-
render: () => (
|
|
20
|
-
<RailFrame>
|
|
21
|
-
<AgentLauncher session={fixturePlanSession()} onLaunchHarness={() => {}} theme={DARK} />
|
|
22
|
-
</RailFrame>
|
|
23
|
-
),
|
|
24
|
-
expectedColors: [DARK.accent],
|
|
25
|
-
size: { width: 40, height: 24 },
|
|
26
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { testRender } from "@opentui/react/test-utils";
|
|
4
|
-
import { DARK } from "../theme";
|
|
5
|
-
import { fixturePlanSession } from "./story-fixtures";
|
|
6
|
-
import { waitForText } from "../test-support";
|
|
7
|
-
import { AgentLauncher, HARNESS_LAUNCHERS, planHandoffBriefing } from "./agent-launcher";
|
|
8
|
-
|
|
9
|
-
describe("planHandoffBriefing", () => {
|
|
10
|
-
test("references the session by id and directs the agent to read then annotate, not rewrite", () => {
|
|
11
|
-
// Act
|
|
12
|
-
const briefing = planHandoffBriefing("ses_42");
|
|
13
|
-
|
|
14
|
-
// Assert
|
|
15
|
-
expect(briefing).toContain("cueloop session get ses_42");
|
|
16
|
-
expect(briefing).toContain("cueloop session annotate ses_42");
|
|
17
|
-
expect(briefing).toContain("Do not rewrite the plan");
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe("HARNESS_LAUNCHERS", () => {
|
|
22
|
-
test("carries the three harnesses with real binary commands (never the `cc` alias)", () => {
|
|
23
|
-
// Assert - `cc` resolves to the system C compiler when spawned on a PTY, so
|
|
24
|
-
// the Claude harness must run `claude`, the real binary, not the shell alias
|
|
25
|
-
expect(HARNESS_LAUNCHERS.map((harness) => harness.command)).toEqual(["claude", "pi", "codex"]);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe("AgentLauncher", () => {
|
|
30
|
-
test("renders a button for every harness, in order", async () => {
|
|
31
|
-
// Arrange
|
|
32
|
-
const setup = await testRender(
|
|
33
|
-
<box style={{ width: 44, height: 20, flexDirection: "column" }}>
|
|
34
|
-
<AgentLauncher session={fixturePlanSession()} onLaunchHarness={() => {}} theme={DARK} />
|
|
35
|
-
</box>,
|
|
36
|
-
{ width: 44, height: 20 },
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
// Act
|
|
40
|
-
await waitForText(setup, "Claude Code");
|
|
41
|
-
const frame = setup.captureCharFrame();
|
|
42
|
-
|
|
43
|
-
// Assert - all three launcher names present, in launch order
|
|
44
|
-
const names = HARNESS_LAUNCHERS.map((harness) => harness.name);
|
|
45
|
-
const positions = names.map((name) => frame.indexOf(name));
|
|
46
|
-
|
|
47
|
-
expect(positions.every((position) => position >= 0)).toBe(true);
|
|
48
|
-
expect(positions).toEqual(positions.toSorted((left, right) => left - right));
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Agent rail launcher: bring-your-own review harness. Branded claude code /
|
|
3
|
-
* pi / codex cards that, on click, run that harness in a herdr split beside the
|
|
4
|
-
* review (see launchHarnessInSplit) so a reviewer can ask an agent about the plan
|
|
5
|
-
* without leaving the tab. A plan-context toggle seeds a briefing into the split.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
9
|
-
import type { Thread } from "@cueloop/schema";
|
|
10
|
-
import type { Theme } from "../theme";
|
|
11
|
-
import { useComponentTheme } from "./theme-context";
|
|
12
|
-
import { FRAME_BORDER_STYLE } from "./primitives/frame";
|
|
13
|
-
import {
|
|
14
|
-
embeddedTerminalAvailable,
|
|
15
|
-
registerTerminalPane,
|
|
16
|
-
type TerminalPaneRenderable,
|
|
17
|
-
} from "./terminal-pane";
|
|
18
|
-
|
|
19
|
-
registerTerminalPane();
|
|
20
|
-
|
|
21
|
-
/** A running in-tab agent terminal, handed to the app so it can route keys and detach. */
|
|
22
|
-
export interface AgentTerminalHandle {
|
|
23
|
-
write: (data: string) => void;
|
|
24
|
-
detach: () => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/** One launchable harness: its display name and the rail command. */
|
|
28
|
-
export interface HarnessLauncher {
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
/** The shell command that starts the harness, run in the split. */
|
|
32
|
-
command: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Off-white for the running-terminal header, shared by every harness. */
|
|
36
|
-
const HARNESS_HEADER_COLOR = "#e4e6ec";
|
|
37
|
-
|
|
38
|
-
/** The bring-your-own harnesses, in launch order. The command is the real binary
|
|
39
|
-
* name spawned on a PTY (not a shell alias, so `claude` - never `cc`, which is
|
|
40
|
-
* the system C compiler). */
|
|
41
|
-
export const HARNESS_LAUNCHERS: HarnessLauncher[] = [
|
|
42
|
-
{ id: "claude", name: "Claude Code", command: "claude" },
|
|
43
|
-
{ id: "pi", name: "Pi", command: "pi" },
|
|
44
|
-
{ id: "codex", name: "OpenAI Codex", command: "codex" },
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
/** The briefing typed into a launched harness when the plan-context toggle is on. */
|
|
48
|
-
export function planHandoffBriefing(sessionId: string): string {
|
|
49
|
-
return `Review this cueloop plan: read it with 'cueloop session get ${sessionId}', then comment with 'cueloop session annotate ${sessionId} --author me --quote "<exact span>" --body "<comment>"'. Do not rewrite the plan.`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** Props for the Agent tab body: the session under review plus the launch callbacks. */
|
|
53
|
-
export interface AgentLauncherProps {
|
|
54
|
-
session: Thread;
|
|
55
|
-
/**
|
|
56
|
-
* Fallback launch when no embedded terminal ships for this platform: run the
|
|
57
|
-
* harness in a herdr split. seedText is the plan-context briefing.
|
|
58
|
-
*/
|
|
59
|
-
onLaunchHarness: (command: string, seedText?: string) => void;
|
|
60
|
-
/** Notifies the app of the in-tab terminal handle (or null when detached) so it can route keys. */
|
|
61
|
-
onAgentTerminal?: (handle: AgentTerminalHandle | null) => void;
|
|
62
|
-
theme?: Theme;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* The Agent tab body: branded launcher cards plus a plan-context toggle. Replaces
|
|
67
|
-
* the old dead agent/status/revision placeholder (now a dim footer line). When a
|
|
68
|
-
* prebuilt libghostty-vt ships for the platform, a picked harness runs embedded
|
|
69
|
-
* inside this tab; otherwise it falls back to a herdr split.
|
|
70
|
-
*/
|
|
71
|
-
export function AgentLauncher({
|
|
72
|
-
session,
|
|
73
|
-
onLaunchHarness,
|
|
74
|
-
onAgentTerminal,
|
|
75
|
-
theme,
|
|
76
|
-
}: AgentLauncherProps): React.ReactNode {
|
|
77
|
-
const tokens = useComponentTheme(theme);
|
|
78
|
-
const [seedContext, setSeedContext] = useState(true);
|
|
79
|
-
const [running, setRunning] = useState<{ harness: HarnessLauncher; seed?: string } | null>(null);
|
|
80
|
-
const paneRef = useRef<TerminalPaneRenderable | null>(null);
|
|
81
|
-
|
|
82
|
-
const launch = (harness: HarnessLauncher): void => {
|
|
83
|
-
const seed = seedContext ? planHandoffBriefing(session.id) : undefined;
|
|
84
|
-
|
|
85
|
-
if (embeddedTerminalAvailable()) setRunning({ harness, seed });
|
|
86
|
-
else onLaunchHarness(harness.command, seed);
|
|
87
|
-
};
|
|
88
|
-
const detach = (): void => {
|
|
89
|
-
// The reconciler's removeChild detaches the pane without destroying it, so
|
|
90
|
-
// kill the child + free the VT here or they leak. shutdown() is idempotent.
|
|
91
|
-
paneRef.current?.shutdown();
|
|
92
|
-
setRunning(null);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
if (!running) return onAgentTerminal?.(null);
|
|
97
|
-
onAgentTerminal?.({ write: (data) => paneRef.current?.write(data), detach });
|
|
98
|
-
|
|
99
|
-
return () => onAgentTerminal?.(null);
|
|
100
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
-
}, [running]);
|
|
102
|
-
|
|
103
|
-
if (running) {
|
|
104
|
-
return (
|
|
105
|
-
<box style={{ flexDirection: "column", flexGrow: 1 }}>
|
|
106
|
-
<box style={{ flexDirection: "row" }} onMouseUp={detach}>
|
|
107
|
-
<text fg={HARNESS_HEADER_COLOR}>{running.harness.name}</text>
|
|
108
|
-
<box style={{ flexGrow: 1 }} />
|
|
109
|
-
<text fg={tokens.textDim}>✕ detach</text>
|
|
110
|
-
</box>
|
|
111
|
-
{React.createElement("terminalPane", {
|
|
112
|
-
ref: paneRef,
|
|
113
|
-
command: running.harness.command,
|
|
114
|
-
cwd: session.artifact.meta.cwd ?? process.cwd(),
|
|
115
|
-
seedText: running.seed,
|
|
116
|
-
onExit: detach,
|
|
117
|
-
style: { flexGrow: 1 },
|
|
118
|
-
})}
|
|
119
|
-
</box>
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<box style={{ flexDirection: "column", flexGrow: 1 }}>
|
|
125
|
-
{HARNESS_LAUNCHERS.map((harness) => (
|
|
126
|
-
<box
|
|
127
|
-
key={harness.id}
|
|
128
|
-
style={{
|
|
129
|
-
flexDirection: "row",
|
|
130
|
-
height: 3,
|
|
131
|
-
border: true,
|
|
132
|
-
borderStyle: FRAME_BORDER_STYLE,
|
|
133
|
-
backgroundColor: "transparent",
|
|
134
|
-
borderColor: tokens.text,
|
|
135
|
-
paddingLeft: 1,
|
|
136
|
-
paddingRight: 1,
|
|
137
|
-
}}
|
|
138
|
-
onMouseUp={() => launch(harness)}
|
|
139
|
-
>
|
|
140
|
-
<text fg={tokens.textMuted}>{harness.name}</text>
|
|
141
|
-
</box>
|
|
142
|
-
))}
|
|
143
|
-
<box style={{ flexDirection: "row" }} onMouseUp={() => setSeedContext((on) => !on)}>
|
|
144
|
-
<text fg={tokens.textDim}>plan context: </text>
|
|
145
|
-
<text fg={tokens.accent}>{seedContext ? "seed the plan" : "none"}</text>
|
|
146
|
-
</box>
|
|
147
|
-
</box>
|
|
148
|
-
);
|
|
149
|
-
}
|