@cueloop/client 0.1.0-alpha.11 → 0.1.0-alpha.111
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 +42 -34
- package/src/annotations/annotation-palette.ts +63 -0
- package/src/annotations/components/AnnotationCards.stories.tsx +86 -0
- package/src/annotations/components/AnnotationCards.test.tsx +42 -0
- package/src/annotations/components/AnnotationCards.tsx +383 -0
- package/src/annotations/components/DiscussionMarkerRail.stories.tsx +54 -0
- package/src/annotations/components/DiscussionMarkerRail.tsx +189 -0
- package/src/annotations/discussions.ts +78 -0
- package/src/annotations/thread-selection.test.ts +210 -0
- package/src/annotations/thread-selection.ts +248 -0
- package/src/annotations/use-annotation-surface.tsx +1378 -0
- package/src/app/App.appearance.test.tsx +53 -0
- package/src/{App.autoclose.test.tsx → app/App.autoclose.test.tsx} +77 -51
- package/src/app/App.deleted-scroll.test.tsx +190 -0
- package/src/app/App.diff.test.tsx +313 -0
- package/src/app/App.export.test.tsx +105 -0
- package/src/app/App.focus.test.ts +89 -0
- package/src/app/App.harness-settings.test.tsx +77 -0
- package/src/app/App.identity.test.tsx +84 -0
- package/src/app/App.plan-render.test.tsx +211 -0
- package/src/app/App.plan-review.test.tsx +429 -0
- package/src/app/App.prototype-markdown.test.tsx +129 -0
- package/src/app/App.prototype.test.tsx +176 -0
- package/src/app/App.readonly.test.tsx +274 -0
- package/src/app/App.regression.test.tsx +99 -0
- package/src/app/App.rendering.test.tsx +134 -0
- package/src/app/App.share-dialog.test.tsx +177 -0
- package/src/app/App.submit-confirm.test.tsx +267 -0
- package/src/app/App.test.tsx +497 -0
- package/src/app/App.thread-agent.test.ts +20 -0
- package/src/app/App.toast.test.tsx +124 -0
- package/src/app/App.tsx +1758 -0
- package/src/app/App.visual.test.tsx +60 -0
- package/src/app/App.walk.test.tsx +300 -0
- package/src/app/App.workbench.test.tsx +1153 -0
- package/src/app/app-key-state.ts +61 -0
- package/src/app/app-screens.tsx +607 -0
- package/src/app/app-view-model.ts +178 -0
- package/src/app/components/AppHeader.stories.tsx +50 -0
- package/src/app/components/AppHeader.tsx +81 -0
- package/src/app/components/AppShell.brand.test.tsx +58 -0
- package/src/app/components/AppShell.extensions.test.tsx +191 -0
- package/src/app/components/AppShell.stories.tsx +89 -0
- package/src/app/components/AppShell.tsx +358 -0
- package/src/app/components/AppShell.zoom.test.tsx +149 -0
- package/src/app/components/Breadcrumb.stories.tsx +19 -0
- package/src/app/components/Breadcrumb.tsx +45 -0
- package/src/app/components/MenuBar.stories.tsx +28 -0
- package/src/app/components/MenuBar.tsx +44 -0
- package/src/app/components/PaneGrid.stories.tsx +84 -0
- package/src/app/components/PaneGrid.tsx +128 -0
- package/src/app/components/PanelColumn.stories.tsx +25 -0
- package/src/app/components/PanelColumn.tsx +93 -0
- package/src/app/components/ShellHeader.stories.tsx +50 -0
- package/src/app/components/ShellHeader.tsx +137 -0
- package/src/app/components/WorkspacePanels.stories.tsx +36 -0
- package/src/app/components/WorkspacePanels.tsx +121 -0
- package/src/app/components/pages/Workspace.stories.tsx +181 -0
- package/src/app/intent-dispatch.test.ts +729 -0
- package/src/app/intent-dispatch.ts +713 -0
- package/src/app/launch-layout.test.ts +78 -0
- package/src/app/launch-layout.ts +57 -0
- package/src/app/ready-signal.test.ts +85 -0
- package/src/app/ready-signal.ts +54 -0
- package/src/app/run.ts +111 -0
- package/src/{serve.test.ts → app/serve.test.ts} +28 -12
- package/src/app/serve.ts +111 -0
- package/src/app/version.ts +5 -0
- package/src/appearance/components/theme-context.stories.tsx +46 -0
- package/src/appearance/components/theme-context.tsx +37 -0
- package/src/appearance/theme-presets.test.ts +51 -0
- package/src/appearance/theme-presets.ts +219 -0
- package/src/appearance/theme.ts +112 -0
- package/src/appearance/visual/contrast.test.ts +35 -0
- package/src/appearance/visual/contrast.ts +33 -0
- package/src/diff/components/AnnotatableFileView.stories.tsx +42 -0
- package/src/diff/components/AnnotatableFileView.test.tsx +160 -0
- package/src/diff/components/AnnotatableFileView.tsx +142 -0
- package/src/diff/components/BareWorkbenchFileView.stories.tsx +27 -0
- package/src/diff/components/BareWorkbenchFileView.tsx +63 -0
- package/src/diff/components/DiffContentView.scroll.test.tsx +443 -0
- package/src/diff/components/DiffContentView.split.test.tsx +140 -0
- package/src/diff/components/DiffContentView.stories.tsx +80 -0
- package/src/diff/components/DiffContentView.syntax.test.tsx +85 -0
- package/src/diff/components/DiffContentView.tsx +1080 -0
- package/src/diff/components/WalkWizard.stories.tsx +100 -0
- package/src/diff/components/WalkWizard.tsx +146 -0
- package/src/diff/components/diff-content-view-layout.test.ts +198 -0
- package/src/diff/components/diff-content-view-layout.ts +87 -0
- package/src/diff/diff-fold.test.ts +78 -0
- package/src/diff/diff-fold.ts +130 -0
- package/src/diff/diff-hunk-curate.test.ts +315 -0
- package/src/diff/diff-hunk-curate.ts +155 -0
- package/src/diff/diff-intraline.test.ts +239 -0
- package/src/diff/diff-intraline.ts +244 -0
- package/src/diff/diff-syntax.test.ts +125 -0
- package/src/diff/diff-syntax.ts +194 -0
- package/src/diff/split-diff.test.ts +110 -0
- package/src/diff/split-diff.ts +150 -0
- package/src/diff/view-diff.test.ts +325 -0
- package/src/diff/view-diff.ts +540 -0
- package/src/diff/walk.test.ts +121 -0
- package/src/diff/walk.ts +76 -0
- package/src/index.ts +32 -2
- package/src/integrations/attribution.test.ts +31 -0
- package/src/integrations/attribution.ts +44 -0
- package/src/integrations/client-extension-registry.test.tsx +61 -0
- package/src/integrations/client-extension-registry.ts +163 -0
- package/src/integrations/clipboard.test.ts +23 -0
- package/src/integrations/clipboard.ts +34 -0
- package/src/integrations/components/ExtensionZone.stories.tsx +28 -0
- package/src/integrations/components/ExtensionZone.tsx +145 -0
- package/src/integrations/components/ShareDialog.agent.test.tsx +52 -0
- package/src/integrations/components/ShareDialog.stories.tsx +121 -0
- package/src/integrations/components/ShareDialog.tsx +602 -0
- package/src/integrations/components/share-dialog-store.ts +59 -0
- package/src/integrations/editor.test.ts +149 -0
- package/src/integrations/editor.ts +163 -0
- package/src/integrations/github-identity.test.ts +59 -0
- package/src/integrations/github-identity.ts +42 -0
- package/src/integrations/herdr.test.ts +43 -0
- package/src/integrations/herdr.ts +40 -0
- package/src/integrations/integrations.test.ts +41 -0
- package/src/integrations/integrations.ts +32 -0
- package/src/integrations/pasted-image.test.ts +67 -0
- package/src/integrations/pasted-image.ts +62 -0
- package/src/integrations/share.ts +283 -0
- package/src/keyboard/components/CompletionOverlay.stories.tsx +37 -0
- package/src/keyboard/components/CompletionOverlay.tsx +75 -0
- package/src/keyboard/components/HandleChipsInput.stories.tsx +24 -0
- package/src/keyboard/components/HandleChipsInput.test.tsx +35 -0
- package/src/keyboard/components/HandleChipsInput.tsx +147 -0
- package/src/keyboard/components/KeybindsDialog.stories.tsx +31 -0
- package/src/keyboard/components/KeybindsDialog.tsx +103 -0
- package/src/keyboard/components/NavModeHint.stories.tsx +40 -0
- package/src/keyboard/components/NavModeHint.tsx +31 -0
- package/src/keyboard/components/SlashComposer.stories.tsx +37 -0
- package/src/keyboard/components/SlashComposer.tsx +90 -0
- package/src/keyboard/key-bindings.test.ts +156 -0
- package/src/keyboard/key-bindings.ts +462 -0
- package/src/keyboard/keymap.test.ts +611 -0
- package/src/keyboard/keymap.ts +446 -0
- package/src/keyboard/skills.test.ts +74 -0
- package/src/keyboard/skills.ts +77 -0
- package/src/keyboard/slash-palette.test.ts +103 -0
- package/src/keyboard/slash-palette.ts +137 -0
- package/src/keyboard/thread-chords.test.ts +79 -0
- package/src/keyboard/thread-chords.ts +168 -0
- package/src/keyboard/use-shared-keyboard.ts +56 -0
- package/src/markdown/__snapshots__/view-plan.regression.test.ts.snap +100 -0
- package/src/markdown/components/MarkdownGridBlock.stories.tsx +33 -0
- package/src/markdown/components/MarkdownGridBlock.tsx +72 -0
- package/src/markdown/components/MarkdownThreadEditor.stories.tsx +15 -0
- package/src/markdown/components/MarkdownThreadEditor.test.tsx +98 -0
- package/src/markdown/components/MarkdownThreadEditor.tsx +165 -0
- package/src/markdown/components/ThreadView.selection.test.tsx +954 -0
- package/src/markdown/components/ThreadView.slash.test.tsx +146 -0
- package/src/markdown/components/ThreadView.stories.tsx +26 -0
- package/src/markdown/components/ThreadView.tsx +577 -0
- package/src/markdown/mark-runs.ts +125 -0
- package/src/markdown/markdown-editor-syntax-style.ts +66 -0
- package/src/markdown/markdown-grid.test.ts +101 -0
- package/src/markdown/markdown-grid.ts +209 -0
- package/src/markdown/markdown-highlight.test.ts +61 -0
- package/src/markdown/markdown-highlight.ts +125 -0
- package/src/markdown/thread-code-syntax.ts +48 -0
- package/src/markdown/use-thread-body-editing.tsx +54 -0
- package/src/markdown/view-plan.regression.test.ts +60 -0
- package/src/markdown/view-plan.test.ts +545 -0
- package/src/markdown/view-plan.ts +1061 -0
- package/src/performance/otlp-trace.test.ts +119 -0
- package/src/performance/otlp-trace.ts +134 -0
- package/src/performance/perf-report.ts +19 -0
- package/src/performance/perf-timings.test.ts +18 -0
- package/src/performance/perf-timings.ts +40 -0
- package/src/prototype/components/PrototypeContentView.stories.tsx +19 -0
- package/src/prototype/components/PrototypeContentView.tsx +459 -0
- package/src/prototype/prototype-browser.test.ts +81 -0
- package/src/prototype/prototype-browser.ts +332 -0
- package/src/prototype/prototype-pixels.tsx +35 -0
- package/src/settings/components/SettingsDialog.stories.tsx +117 -0
- package/src/settings/components/SettingsDialog.tsx +186 -0
- package/src/settings/components/SettingsRows.stories.tsx +18 -0
- package/src/settings/components/SettingsRows.tsx +112 -0
- package/src/settings/components/quick-actions-editor.stories.tsx +58 -0
- package/src/settings/components/quick-actions-editor.test.tsx +120 -0
- package/src/settings/components/quick-actions-editor.tsx +222 -0
- package/src/settings/config-identity.test.ts +78 -0
- package/src/settings/config.test.ts +771 -0
- package/src/settings/config.ts +722 -0
- package/src/settings/use-settings-dialog.test.tsx +172 -0
- package/src/settings/use-settings-dialog.tsx +465 -0
- package/src/settings/use-thread-harness-setting.test.tsx +87 -0
- package/src/settings/use-thread-harness-setting.ts +86 -0
- package/src/stories/__snapshots__/stories.test.tsx.snap +2358 -0
- package/src/stories/stories-app.tsx +196 -0
- package/src/stories/stories.test.tsx +78 -0
- package/src/stories/story-fixtures.ts +102 -0
- package/src/stories/story-tree.test.ts +108 -0
- package/src/stories/story.ts +160 -0
- package/src/terminal/ansi-screen.test.ts +28 -0
- package/src/terminal/ansi-screen.ts +77 -0
- package/src/terminal/components/AnsiScreen.stories.tsx +12 -0
- package/src/terminal/components/AnsiScreen.tsx +28 -0
- package/src/terminal/components/terminal-pane.test.tsx +40 -0
- package/src/terminal/components/terminal-pane.ts +208 -0
- package/src/terminal/ghostty-terminal.test.ts +85 -0
- package/src/terminal/ghostty-terminal.ts +207 -0
- package/src/terminal/kitty-image.test.ts +66 -0
- package/src/terminal/kitty-image.ts +140 -0
- package/src/terminal/pty.test.ts +81 -0
- package/src/terminal/pty.ts +255 -0
- package/src/testing/test-support.test.ts +266 -0
- package/src/testing/test-support.ts +449 -0
- package/src/thread/agent-continuation.test.ts +34 -0
- package/src/thread/agent-continuation.ts +13 -0
- package/src/thread/agent-transcript.test.ts +161 -0
- package/src/thread/agent-transcript.ts +344 -0
- package/src/thread/components/AgentConfigControls.stories.tsx +39 -0
- package/src/thread/components/AgentConfigControls.test.tsx +153 -0
- package/src/thread/components/AgentConfigControls.tsx +121 -0
- package/src/thread/components/AgentThreadPane.stories.tsx +105 -0
- package/src/thread/components/AgentThreadPane.test.tsx +1248 -0
- package/src/thread/components/AgentThreadPane.tsx +458 -0
- package/src/thread/components/ThreadFooter.stories.tsx +30 -0
- package/src/thread/components/ThreadFooter.test.tsx +49 -0
- package/src/thread/components/ThreadFooter.tsx +77 -0
- package/src/thread/components/ThreadTree.stories.tsx +46 -0
- package/src/thread/components/ThreadTree.test.tsx +41 -0
- package/src/thread/components/ThreadTree.tsx +268 -0
- package/src/thread/components/thread-tree.test.ts +138 -0
- package/src/thread/components/thread-tree.ts +112 -0
- package/src/thread/thread-controller.curate.test.ts +504 -0
- package/src/thread/thread-controller.derivation.test.ts +62 -0
- package/src/thread/thread-controller.live-diff.test.ts +357 -0
- package/src/thread/thread-controller.optimistic.test.ts +69 -0
- package/src/thread/thread-controller.share.test.ts +618 -0
- package/src/thread/thread-controller.switch-cache.test.ts +174 -0
- package/src/thread/thread-controller.tree.test.ts +263 -0
- package/src/thread/thread-controller.ts +2151 -0
- package/src/thread/tree-view.test.ts +128 -0
- package/src/thread/tree-view.ts +150 -0
- package/src/thread/use-thread-agent.test.tsx +209 -0
- package/src/thread/use-thread-agent.ts +122 -0
- package/src/ui/components/CodeBlock.stories.tsx +42 -0
- package/src/ui/components/CodeBlock.tsx +82 -0
- package/src/ui/components/ConfirmCard.stories.tsx +37 -0
- package/src/ui/components/ConfirmCard.tsx +151 -0
- package/src/ui/components/ConfirmDialog.stories.tsx +21 -0
- package/src/ui/components/ConfirmDialog.tsx +72 -0
- package/src/ui/components/OverlayScrollbar.stories.tsx +33 -0
- package/src/ui/components/OverlayScrollbar.test.tsx +142 -0
- package/src/ui/components/OverlayScrollbar.tsx +134 -0
- package/src/ui/components/PromptDialog.stories.tsx +36 -0
- package/src/ui/components/PromptDialog.test.tsx +65 -0
- package/src/ui/components/PromptDialog.tsx +101 -0
- package/src/ui/components/RootOverlay.stories.tsx +45 -0
- package/src/ui/components/RootOverlay.tsx +50 -0
- package/src/ui/components/ScrollArea.stories.tsx +20 -0
- package/src/ui/components/ScrollArea.tsx +63 -0
- package/src/ui/components/Toast.stories.tsx +19 -0
- package/src/ui/components/Toast.tsx +54 -0
- package/src/ui/components/Tooltip.stories.tsx +26 -0
- package/src/ui/components/Tooltip.tsx +93 -0
- package/src/ui/components/menu-control.stories.tsx +35 -0
- package/src/ui/components/menu-control.tsx +43 -0
- package/src/ui/components/primitives/Button.stories.tsx +32 -0
- package/src/ui/components/primitives/Button.tsx +58 -0
- package/src/ui/components/primitives/Card.stories.tsx +25 -0
- package/src/ui/components/primitives/Card.tsx +62 -0
- package/src/ui/components/primitives/Dialog.stories.tsx +24 -0
- package/src/ui/components/primitives/Dialog.test.tsx +38 -0
- package/src/ui/components/primitives/Dialog.tsx +69 -0
- package/src/ui/components/primitives/DialogActions.stories.tsx +20 -0
- package/src/ui/components/primitives/DialogActions.tsx +39 -0
- package/src/ui/components/primitives/IconButton.stories.tsx +36 -0
- package/src/ui/components/primitives/IconButton.tsx +58 -0
- package/src/ui/components/primitives/StatusBar.stories.tsx +11 -0
- package/src/ui/components/primitives/StatusBar.tsx +23 -0
- package/src/ui/components/primitives/Switch.stories.tsx +17 -0
- package/src/ui/components/primitives/Switch.tsx +32 -0
- package/src/ui/components/primitives/Tabs.stories.tsx +29 -0
- package/src/ui/components/primitives/Tabs.tsx +102 -0
- package/src/ui/components/primitives/Toolbar.stories.tsx +17 -0
- package/src/ui/components/primitives/Toolbar.tsx +14 -0
- package/src/ui/components/primitives/Tree.stories.tsx +124 -0
- package/src/ui/components/primitives/Tree.tsx +137 -0
- package/src/ui/components/primitives/frame.test.ts +12 -0
- package/src/ui/components/primitives/frame.ts +17 -0
- package/src/ui/components/primitives/icons.ts +61 -0
- package/src/ui/components/primitives/tree-model.test.ts +99 -0
- package/src/ui/components/primitives/tree-model.ts +144 -0
- package/src/ui/components/syntax-highlight.ts +154 -0
- package/src/ui/components/truncate-text.ts +7 -0
- package/src/ui/components/truncate-title.test.ts +31 -0
- package/src/ui/components/truncate-title.ts +16 -0
- package/src/ui/use-frame-measure.ts +88 -0
- package/src/ui/use-terminal-virtualizer.ts +286 -0
- package/src/workbench/components/ChangesColumn.stories.tsx +44 -0
- package/src/workbench/components/ChangesColumn.tsx +210 -0
- package/src/workbench/components/ChangesFileTree.test.tsx +184 -0
- package/src/workbench/components/EditorGrid.split.test.tsx +119 -0
- package/src/workbench/components/EditorGrid.stories.tsx +86 -0
- package/src/workbench/components/EditorGrid.tabs.test.tsx +118 -0
- package/src/workbench/components/EditorGrid.tsx +552 -0
- package/src/workbench/components/EditorGrid.zoom.test.tsx +132 -0
- package/src/workbench/components/FileContentsView.stories.tsx +16 -0
- package/src/workbench/components/FileContentsView.test.tsx +29 -0
- package/src/workbench/components/FileContentsView.tsx +104 -0
- package/src/workbench/components/GridTabContent.actions.test.tsx +151 -0
- package/src/workbench/components/GridTabContent.stories.tsx +59 -0
- package/src/workbench/components/GridTabContent.tsx +195 -0
- package/src/workbench/components/ProjectTreeView.stories.tsx +25 -0
- package/src/workbench/components/ProjectTreeView.test.tsx +239 -0
- package/src/workbench/components/ProjectTreeView.tsx +159 -0
- package/src/workbench/components/TreePane.stories.tsx +106 -0
- package/src/workbench/components/TreePane.tsx +157 -0
- package/src/workbench/components/WelcomePlayground.stories.tsx +12 -0
- package/src/workbench/components/WelcomePlayground.test.tsx +83 -0
- package/src/workbench/components/WelcomePlayground.tsx +138 -0
- package/src/workbench/components/editor-grid.test.ts +184 -0
- package/src/workbench/components/editor-grid.ts +284 -0
- package/src/workbench/components/file-tree.test.ts +60 -0
- package/src/workbench/components/file-tree.ts +114 -0
- package/src/workbench/use-changes-workbench.ts +210 -0
- package/src/workbench/use-remember-layout.ts +33 -0
- package/src/workbench/use-repo-changes.ts +93 -0
- package/src/workbench/workbench-snapshot.test.ts +99 -0
- package/src/workbench/workbench-snapshot.ts +59 -0
- package/src/App.diff.test.tsx +0 -99
- package/src/App.export.test.tsx +0 -88
- package/src/App.plan-review.test.tsx +0 -259
- package/src/App.readonly.test.tsx +0 -148
- package/src/App.rendering.test.tsx +0 -108
- package/src/App.submit-confirm.test.tsx +0 -183
- package/src/App.test.tsx +0 -218
- package/src/App.tsx +0 -1249
- package/src/config.test.ts +0 -116
- package/src/config.ts +0 -150
- package/src/editor.ts +0 -34
- package/src/herdr.test.ts +0 -68
- package/src/herdr.ts +0 -34
- package/src/keymap.test.ts +0 -270
- package/src/keymap.ts +0 -173
- package/src/run.ts +0 -30
- package/src/serve.ts +0 -75
- package/src/session-controller.ts +0 -398
- package/src/syntax.test.ts +0 -41
- package/src/syntax.ts +0 -88
- package/src/theme.ts +0 -46
- package/src/view-diff.test.ts +0 -55
- package/src/view-diff.ts +0 -86
- package/src/view.test.ts +0 -157
- package/src/view.ts +0 -364
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { loadConfig } from "./config";
|
|
5
|
+
import { expect, test } from "bun:test";
|
|
6
|
+
import React, { useState } from "react";
|
|
7
|
+
import { useKeyboard } from "@opentui/react";
|
|
8
|
+
import { testRender } from "@opentui/react/test-utils";
|
|
9
|
+
import { DARK } from "../appearance/theme";
|
|
10
|
+
import { settle, locateText, typeText } from "../testing/test-support";
|
|
11
|
+
import { SettingsDialog } from "./components/SettingsDialog";
|
|
12
|
+
import { useSettingsDialog } from "./use-settings-dialog";
|
|
13
|
+
|
|
14
|
+
function TestThreadSettings({
|
|
15
|
+
enabled,
|
|
16
|
+
onSwitch,
|
|
17
|
+
}: {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
onSwitch: (harness: string) => void;
|
|
20
|
+
}) {
|
|
21
|
+
const [harness, setHarness] = useState<"pi" | "fx">("pi");
|
|
22
|
+
const [threadDefaults, setThreadDefaults] = useState(() => {
|
|
23
|
+
const config = loadConfig();
|
|
24
|
+
|
|
25
|
+
return { pi: config.thread.pi, fx: config.thread.fx };
|
|
26
|
+
});
|
|
27
|
+
const model = useSettingsDialog({
|
|
28
|
+
threadDefaults,
|
|
29
|
+
setThreadDefaults,
|
|
30
|
+
theme: DARK,
|
|
31
|
+
appearance: "dark",
|
|
32
|
+
autoClose: "off",
|
|
33
|
+
setAutoClose() {},
|
|
34
|
+
diffView: "split",
|
|
35
|
+
setDiffView() {},
|
|
36
|
+
themeName: "cueloop",
|
|
37
|
+
setThemeName() {},
|
|
38
|
+
themeOverrides: {},
|
|
39
|
+
setTheme() {},
|
|
40
|
+
quickActions: [],
|
|
41
|
+
setQuickActions() {},
|
|
42
|
+
setMenuDialog() {},
|
|
43
|
+
identityProvider: "typed",
|
|
44
|
+
onSyncGithubIdentity() {},
|
|
45
|
+
onRenameDisplayName() {},
|
|
46
|
+
reviewSkill: "code-review",
|
|
47
|
+
reviewWorkspace: "worktree",
|
|
48
|
+
setReviewWorkspace() {},
|
|
49
|
+
canSwitchHarness: enabled,
|
|
50
|
+
threadHarness: harness,
|
|
51
|
+
onSwitchHarness(next) {
|
|
52
|
+
setHarness(next);
|
|
53
|
+
onSwitch(next);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
useKeyboard((key) => model.handleSettingsKey(key.name));
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<SettingsDialog
|
|
61
|
+
isOpen
|
|
62
|
+
version="test"
|
|
63
|
+
categories={model.settingsCategories}
|
|
64
|
+
values={model.settingsValues}
|
|
65
|
+
keybindsSections={[]}
|
|
66
|
+
activeCategoryId={model.settingsNav.categoryId}
|
|
67
|
+
activeRowIndex={model.settingsNav.rowIndex}
|
|
68
|
+
activeZone={model.settingsNav.zone}
|
|
69
|
+
onCategorySelect={model.onCategorySelect}
|
|
70
|
+
onRowActivate={(row) => model.cycleSetting(row.key)}
|
|
71
|
+
onClose={() => {}}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
test("Thread settings switches harness by mouse and disappears without owner capability", async () => {
|
|
77
|
+
const changes: string[] = [];
|
|
78
|
+
const setup = await testRender(
|
|
79
|
+
<TestThreadSettings enabled onSwitch={(next) => changes.push(next)} />,
|
|
80
|
+
{ width: 90, height: 28 },
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
await settle(setup);
|
|
85
|
+
const category = locateText(setup, "Thread");
|
|
86
|
+
|
|
87
|
+
await setup.mockMouse.click(category.column, category.row);
|
|
88
|
+
await settle(setup);
|
|
89
|
+
const row = locateText(setup, "Harness");
|
|
90
|
+
|
|
91
|
+
await setup.mockMouse.click(row.column, row.row);
|
|
92
|
+
await settle(setup);
|
|
93
|
+
expect(changes).toEqual(["fx"]);
|
|
94
|
+
expect(setup.captureCharFrame()).toContain("fx");
|
|
95
|
+
await setup.mockMouse.click(row.column, row.row);
|
|
96
|
+
await settle(setup);
|
|
97
|
+
expect(changes).toEqual(["fx", "pi"]);
|
|
98
|
+
} finally {
|
|
99
|
+
setup.renderer.destroy();
|
|
100
|
+
}
|
|
101
|
+
const disabled = await testRender(<TestThreadSettings enabled={false} onSwitch={() => {}} />, {
|
|
102
|
+
width: 90,
|
|
103
|
+
height: 28,
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
await settle(disabled);
|
|
108
|
+
expect(disabled.captureCharFrame()).not.toContain("Thread");
|
|
109
|
+
} finally {
|
|
110
|
+
disabled.renderer.destroy();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("Thread settings edits model defaults and effort and persists them to TOML", async () => {
|
|
115
|
+
const directory = mkdtempSync(join(tmpdir(), "cueloop-settings-model-"));
|
|
116
|
+
const previous = process.env.CUELOOP_CONFIG;
|
|
117
|
+
const path = join(directory, "config.toml");
|
|
118
|
+
|
|
119
|
+
process.env.CUELOOP_CONFIG = path;
|
|
120
|
+
const setup = await testRender(<TestThreadSettings enabled onSwitch={() => {}} />, {
|
|
121
|
+
width: 100,
|
|
122
|
+
height: 30,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
await settle(setup);
|
|
127
|
+
const category = locateText(setup, "Thread");
|
|
128
|
+
|
|
129
|
+
await setup.mockMouse.click(category.column, category.row);
|
|
130
|
+
await settle(setup);
|
|
131
|
+
expect(setup.captureCharFrame()).toContain("gpt-6.1-sol");
|
|
132
|
+
expect(setup.captureCharFrame()).toContain("grok-4.7");
|
|
133
|
+
const effort = locateText(setup, "pi default effort");
|
|
134
|
+
|
|
135
|
+
await setup.mockMouse.click(effort.column, effort.row);
|
|
136
|
+
await settle(setup);
|
|
137
|
+
expect(loadConfig({ userConfigPath: path }).thread.pi.effort).toBe("high");
|
|
138
|
+
const model = locateText(setup, "pi default model");
|
|
139
|
+
|
|
140
|
+
await setup.mockMouse.click(model.column, model.row);
|
|
141
|
+
await settle(setup);
|
|
142
|
+
await typeText(setup, "-custom");
|
|
143
|
+
await settle(setup);
|
|
144
|
+
const save = locateText(setup, "save");
|
|
145
|
+
|
|
146
|
+
await setup.mockMouse.click(save.column, save.row);
|
|
147
|
+
await settle(setup);
|
|
148
|
+
expect(loadConfig({ userConfigPath: path }).thread.pi.model).toBe(
|
|
149
|
+
"openai-codex/gpt-6.1-sol-custom",
|
|
150
|
+
);
|
|
151
|
+
expect(setup.captureCharFrame()).toContain("gpt-6.1-sol-custom");
|
|
152
|
+
const fxModel = locateText(setup, "fx default model");
|
|
153
|
+
|
|
154
|
+
await setup.mockMouse.click(fxModel.column, fxModel.row);
|
|
155
|
+
await settle(setup);
|
|
156
|
+
await typeText(setup, "-cancelled");
|
|
157
|
+
setup.mockInput.pressKey("ESC");
|
|
158
|
+
await settle(setup);
|
|
159
|
+
expect(setup.captureCharFrame()).not.toContain("Default model for new Threads");
|
|
160
|
+
expect(loadConfig({ userConfigPath: path }).thread.fx).toEqual({
|
|
161
|
+
model: "grok/grok-4.7",
|
|
162
|
+
effort: "medium",
|
|
163
|
+
});
|
|
164
|
+
} finally {
|
|
165
|
+
setup.renderer.destroy();
|
|
166
|
+
|
|
167
|
+
if (previous === undefined) delete process.env.CUELOOP_CONFIG;
|
|
168
|
+
else process.env.CUELOOP_CONFIG = previous;
|
|
169
|
+
|
|
170
|
+
rmSync(directory, { recursive: true, force: true });
|
|
171
|
+
}
|
|
172
|
+
});
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import React, { useState, type Dispatch, type SetStateAction } from "react";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_QUICK_ACTIONS,
|
|
4
|
+
persistThreadModelDefault,
|
|
5
|
+
persistActions,
|
|
6
|
+
persistAutoClose,
|
|
7
|
+
persistDiffView,
|
|
8
|
+
persistReviewWorkspace,
|
|
9
|
+
persistTheme,
|
|
10
|
+
type AutoClose,
|
|
11
|
+
type DiffViewMode,
|
|
12
|
+
type QuickAction,
|
|
13
|
+
type ReviewWorkspaceMode,
|
|
14
|
+
} from "./config";
|
|
15
|
+
import {
|
|
16
|
+
composeTheme,
|
|
17
|
+
THEME_LABELS,
|
|
18
|
+
THEME_NAMES,
|
|
19
|
+
type Appearance,
|
|
20
|
+
type ThemeName,
|
|
21
|
+
} from "../appearance/theme-presets";
|
|
22
|
+
import {
|
|
23
|
+
AGENT_REASONING_EFFORTS,
|
|
24
|
+
type ThreadModelDefaults,
|
|
25
|
+
type AgentReasoningEffort,
|
|
26
|
+
} from "@cueloop/schema";
|
|
27
|
+
import { PromptDialog } from "../ui/components/PromptDialog";
|
|
28
|
+
import type { Theme } from "../appearance/theme";
|
|
29
|
+
import type { SettingsCategory } from "./components/SettingsDialog";
|
|
30
|
+
import { QuickActionsEditor } from "./components/quick-actions-editor";
|
|
31
|
+
|
|
32
|
+
export interface SettingsNav {
|
|
33
|
+
categoryId: string;
|
|
34
|
+
rowIndex: number;
|
|
35
|
+
zone: "nav" | "body";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SettingsDialogModel {
|
|
39
|
+
settingsNav: SettingsNav;
|
|
40
|
+
actionsExpandedIndex: number | null;
|
|
41
|
+
setActionsExpandedIndex: Dispatch<SetStateAction<number | null>>;
|
|
42
|
+
settingsCategories: SettingsCategory[];
|
|
43
|
+
settingsValues: Record<string, string>;
|
|
44
|
+
cycleSetting: (rowKey: string) => void;
|
|
45
|
+
handleSettingsKey: (name: string) => void;
|
|
46
|
+
onCategorySelect: (categoryId: string) => void;
|
|
47
|
+
openSettings: () => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const DOWN_KEYS = new Set(["j", "down"]);
|
|
51
|
+
const UP_KEYS = new Set(["k", "up"]);
|
|
52
|
+
const ENTER_BODY_KEYS = new Set(["l", "right", "tab", "return"]);
|
|
53
|
+
const BACK_TO_NAV_KEYS = new Set(["h", "left", "tab"]);
|
|
54
|
+
const ACTIVATE_KEYS = new Set(["return", "space", "l"]);
|
|
55
|
+
|
|
56
|
+
function moveNavZone(
|
|
57
|
+
name: string,
|
|
58
|
+
categoryIndex: number,
|
|
59
|
+
categories: SettingsCategory[],
|
|
60
|
+
): SettingsNav | null {
|
|
61
|
+
if (DOWN_KEYS.has(name))
|
|
62
|
+
return {
|
|
63
|
+
categoryId: categories[Math.min(categories.length - 1, categoryIndex + 1)]!.id,
|
|
64
|
+
rowIndex: 0,
|
|
65
|
+
zone: "nav",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
if (UP_KEYS.has(name))
|
|
69
|
+
return { categoryId: categories[Math.max(0, categoryIndex - 1)]!.id, rowIndex: 0, zone: "nav" };
|
|
70
|
+
|
|
71
|
+
if (ENTER_BODY_KEYS.has(name))
|
|
72
|
+
return { categoryId: categories[categoryIndex]!.id, rowIndex: 0, zone: "body" };
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function moveBodyRow(name: string, nav: SettingsNav, rowCount: number): SettingsNav | null {
|
|
78
|
+
if (DOWN_KEYS.has(name)) return { ...nav, rowIndex: Math.min(rowCount - 1, nav.rowIndex + 1) };
|
|
79
|
+
|
|
80
|
+
if (UP_KEYS.has(name)) return { ...nav, rowIndex: Math.max(0, nav.rowIndex - 1) };
|
|
81
|
+
|
|
82
|
+
if (BACK_TO_NAV_KEYS.has(name)) return { ...nav, zone: "nav" };
|
|
83
|
+
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function useSettingsDialog(params: {
|
|
88
|
+
threadDefaults: Record<"pi" | "fx", ThreadModelDefaults>;
|
|
89
|
+
setThreadDefaults: Dispatch<SetStateAction<Record<"pi" | "fx", ThreadModelDefaults>>>;
|
|
90
|
+
theme: Theme;
|
|
91
|
+
appearance: Appearance;
|
|
92
|
+
autoClose: AutoClose;
|
|
93
|
+
setAutoClose: Dispatch<SetStateAction<AutoClose>>;
|
|
94
|
+
diffView: DiffViewMode;
|
|
95
|
+
setDiffView: Dispatch<SetStateAction<DiffViewMode>>;
|
|
96
|
+
themeName: ThemeName;
|
|
97
|
+
setThemeName: Dispatch<SetStateAction<ThemeName>>;
|
|
98
|
+
themeOverrides: Partial<Theme>;
|
|
99
|
+
setTheme: Dispatch<SetStateAction<Theme>>;
|
|
100
|
+
quickActions: QuickAction[];
|
|
101
|
+
setQuickActions: Dispatch<SetStateAction<QuickAction[]>>;
|
|
102
|
+
setMenuDialog: Dispatch<SetStateAction<"keybinds" | "settings" | null>>;
|
|
103
|
+
identityName?: string;
|
|
104
|
+
identityProvider: "typed" | "github";
|
|
105
|
+
onSyncGithubIdentity: () => void;
|
|
106
|
+
onRenameDisplayName: () => void;
|
|
107
|
+
reviewSkill: string;
|
|
108
|
+
reviewWorkspace: ReviewWorkspaceMode;
|
|
109
|
+
setReviewWorkspace: Dispatch<SetStateAction<ReviewWorkspaceMode>>;
|
|
110
|
+
threadHarness?: "pi" | "fx";
|
|
111
|
+
canSwitchHarness?: boolean;
|
|
112
|
+
onSwitchHarness?: (harness: "pi" | "fx") => void;
|
|
113
|
+
}): SettingsDialogModel {
|
|
114
|
+
const {
|
|
115
|
+
theme,
|
|
116
|
+
appearance,
|
|
117
|
+
autoClose,
|
|
118
|
+
setAutoClose,
|
|
119
|
+
diffView,
|
|
120
|
+
setDiffView,
|
|
121
|
+
themeName,
|
|
122
|
+
setThemeName,
|
|
123
|
+
themeOverrides,
|
|
124
|
+
setTheme,
|
|
125
|
+
quickActions,
|
|
126
|
+
setQuickActions,
|
|
127
|
+
setMenuDialog,
|
|
128
|
+
identityName,
|
|
129
|
+
identityProvider,
|
|
130
|
+
onSyncGithubIdentity,
|
|
131
|
+
onRenameDisplayName,
|
|
132
|
+
reviewSkill,
|
|
133
|
+
reviewWorkspace,
|
|
134
|
+
setReviewWorkspace,
|
|
135
|
+
threadHarness,
|
|
136
|
+
canSwitchHarness,
|
|
137
|
+
onSwitchHarness,
|
|
138
|
+
} = params;
|
|
139
|
+
|
|
140
|
+
const { threadDefaults, setThreadDefaults } = params;
|
|
141
|
+
const [modelEditor, setModelEditor] = useState<{ harness: "pi" | "fx"; text: string } | null>(
|
|
142
|
+
null,
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const saveModelDefault = (): void => {
|
|
146
|
+
if (!modelEditor?.text.trim()) return;
|
|
147
|
+
|
|
148
|
+
const { harness, text } = modelEditor;
|
|
149
|
+
const model = text.trim();
|
|
150
|
+
|
|
151
|
+
persistThreadModelDefault(harness, "model", model);
|
|
152
|
+
setThreadDefaults((defaults) => ({ ...defaults, [harness]: { ...defaults[harness], model } }));
|
|
153
|
+
setModelEditor(null);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
// open focused on the left nav, so up/down browses categories until l/tab/enter enters the body
|
|
157
|
+
const [settingsNav, setSettingsNav] = useState<SettingsNav>({
|
|
158
|
+
categoryId: "general",
|
|
159
|
+
rowIndex: 0,
|
|
160
|
+
zone: "nav",
|
|
161
|
+
});
|
|
162
|
+
const [actionsExpandedIndex, setActionsExpandedIndex] = useState<number | null>(null);
|
|
163
|
+
const [actionsExpandedField, setActionsExpandedField] = useState<"prompt" | "metadata">("prompt");
|
|
164
|
+
|
|
165
|
+
const commitActions = (next: QuickAction[]): void => {
|
|
166
|
+
setQuickActions(next);
|
|
167
|
+
persistActions(next);
|
|
168
|
+
};
|
|
169
|
+
const editActionPrompt = (index: number, prompt: string): void => {
|
|
170
|
+
// a blank title fails the config schema and would vanish on reload, so never persist one
|
|
171
|
+
if (prompt.trim().length === 0) return;
|
|
172
|
+
|
|
173
|
+
commitActions(
|
|
174
|
+
quickActions.map((action, actionIndex) =>
|
|
175
|
+
actionIndex === index ? { ...action, prompt } : action,
|
|
176
|
+
),
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
const editActionMetadata = (index: number, metadata: string): void =>
|
|
180
|
+
commitActions(
|
|
181
|
+
quickActions.map((action, actionIndex) =>
|
|
182
|
+
actionIndex === index
|
|
183
|
+
? { ...action, metadata: metadata.trim() ? metadata : undefined }
|
|
184
|
+
: action,
|
|
185
|
+
),
|
|
186
|
+
);
|
|
187
|
+
const resetActions = (): void => {
|
|
188
|
+
setActionsExpandedIndex(null);
|
|
189
|
+
commitActions(DEFAULT_QUICK_ACTIONS.map((action) => ({ ...action })));
|
|
190
|
+
};
|
|
191
|
+
const addAction = (): void => {
|
|
192
|
+
setSettingsNav((state) => ({ ...state, zone: "body", rowIndex: quickActions.length }));
|
|
193
|
+
commitActions([...quickActions, { prompt: "New action" }]);
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const settingsCategories: SettingsCategory[] = [
|
|
197
|
+
{
|
|
198
|
+
id: "general",
|
|
199
|
+
name: "General",
|
|
200
|
+
rows: [
|
|
201
|
+
{
|
|
202
|
+
key: "autoClose",
|
|
203
|
+
label: "Auto-close on submit",
|
|
204
|
+
kind: "cycle",
|
|
205
|
+
options: ["off", "3s", "10s"],
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
key: "diffView",
|
|
209
|
+
label: "Diff view",
|
|
210
|
+
kind: "cycle",
|
|
211
|
+
options: ["Split", "Stacked"],
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
id: "account",
|
|
217
|
+
name: "Account",
|
|
218
|
+
rows: [
|
|
219
|
+
{ key: "displayName", label: "Display name", kind: "text" },
|
|
220
|
+
{ key: "identitySource", label: "Source", kind: "text" },
|
|
221
|
+
{ key: "syncGithub", label: "Sync from GitHub", kind: "text" },
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
id: "appearance",
|
|
226
|
+
name: "Appearance",
|
|
227
|
+
rows: [
|
|
228
|
+
{
|
|
229
|
+
key: "theme",
|
|
230
|
+
label: "Theme",
|
|
231
|
+
kind: "cycle",
|
|
232
|
+
options: THEME_NAMES.map((name) => THEME_LABELS[name]),
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
id: "review",
|
|
238
|
+
name: "Review",
|
|
239
|
+
rows: [
|
|
240
|
+
{
|
|
241
|
+
key: "reviewSkill",
|
|
242
|
+
label: "Skill",
|
|
243
|
+
kind: "text",
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
key: "reviewWorkspace",
|
|
247
|
+
label: "Workspace",
|
|
248
|
+
kind: "cycle",
|
|
249
|
+
options: ["worktree", "current"],
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
...(canSwitchHarness
|
|
254
|
+
? [
|
|
255
|
+
{
|
|
256
|
+
id: "thread",
|
|
257
|
+
name: "Thread",
|
|
258
|
+
rows: [
|
|
259
|
+
{
|
|
260
|
+
key: "threadHarness",
|
|
261
|
+
label: "Harness",
|
|
262
|
+
kind: "cycle" as const,
|
|
263
|
+
options: ["pi", "fx"],
|
|
264
|
+
},
|
|
265
|
+
{ key: "piModel", label: "pi default model", kind: "text" as const },
|
|
266
|
+
{
|
|
267
|
+
key: "piEffort",
|
|
268
|
+
label: "pi default effort",
|
|
269
|
+
kind: "cycle" as const,
|
|
270
|
+
options: [...AGENT_REASONING_EFFORTS],
|
|
271
|
+
},
|
|
272
|
+
{ key: "fxModel", label: "fx default model", kind: "text" as const },
|
|
273
|
+
{
|
|
274
|
+
key: "fxEffort",
|
|
275
|
+
label: "fx default effort",
|
|
276
|
+
kind: "cycle" as const,
|
|
277
|
+
options: [...AGENT_REASONING_EFFORTS],
|
|
278
|
+
},
|
|
279
|
+
],
|
|
280
|
+
customBody: modelEditor ? (
|
|
281
|
+
<PromptDialog
|
|
282
|
+
isOpen
|
|
283
|
+
title=" Default model for new Threads "
|
|
284
|
+
label={`${modelEditor.harness} model (provider/model)`}
|
|
285
|
+
value={modelEditor.text}
|
|
286
|
+
onInput={(text) => setModelEditor({ ...modelEditor, text })}
|
|
287
|
+
onSave={saveModelDefault}
|
|
288
|
+
onCancel={() => setModelEditor(null)}
|
|
289
|
+
theme={theme}
|
|
290
|
+
/>
|
|
291
|
+
) : undefined,
|
|
292
|
+
},
|
|
293
|
+
]
|
|
294
|
+
: []),
|
|
295
|
+
{
|
|
296
|
+
id: "actions",
|
|
297
|
+
name: "Actions",
|
|
298
|
+
rows: [],
|
|
299
|
+
customBody: (
|
|
300
|
+
<QuickActionsEditor
|
|
301
|
+
actions={quickActions}
|
|
302
|
+
selectedIndex={settingsNav.categoryId === "actions" ? settingsNav.rowIndex : -1}
|
|
303
|
+
expandedIndex={actionsExpandedIndex}
|
|
304
|
+
expandedField={actionsExpandedField}
|
|
305
|
+
onToggleExpand={(index, field) => {
|
|
306
|
+
setSettingsNav((state) => ({ ...state, zone: "body", rowIndex: index }));
|
|
307
|
+
setActionsExpandedField(field);
|
|
308
|
+
setActionsExpandedIndex((current) => (current === index ? null : index));
|
|
309
|
+
}}
|
|
310
|
+
onEditPrompt={editActionPrompt}
|
|
311
|
+
onEditMetadata={editActionMetadata}
|
|
312
|
+
onReset={resetActions}
|
|
313
|
+
onAdd={addAction}
|
|
314
|
+
theme={theme}
|
|
315
|
+
/>
|
|
316
|
+
),
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: "keybinds",
|
|
320
|
+
name: "Keybinds",
|
|
321
|
+
rows: [],
|
|
322
|
+
},
|
|
323
|
+
];
|
|
324
|
+
const settingsValues = {
|
|
325
|
+
autoClose: autoClose === "off" ? "off" : `${autoClose}s`,
|
|
326
|
+
diffView: diffView === "split" ? "Split" : "Stacked",
|
|
327
|
+
theme: THEME_LABELS[themeName],
|
|
328
|
+
displayName: identityName ?? "-- not set --",
|
|
329
|
+
identitySource: identityProvider === "github" ? "GitHub" : "typed",
|
|
330
|
+
syncGithub: "enter to sync",
|
|
331
|
+
reviewSkill,
|
|
332
|
+
reviewWorkspace,
|
|
333
|
+
threadHarness: threadHarness ?? "pi",
|
|
334
|
+
piModel: threadDefaults.pi.model.replace(/^[^/]+\//, ""),
|
|
335
|
+
piEffort: threadDefaults.pi.effort,
|
|
336
|
+
fxModel: threadDefaults.fx.model.replace(/^[^/]+\//, ""),
|
|
337
|
+
fxEffort: threadDefaults.fx.effort,
|
|
338
|
+
};
|
|
339
|
+
const cycleSetting = (rowKey: string): void => {
|
|
340
|
+
if (rowKey === "piModel" || rowKey === "fxModel") {
|
|
341
|
+
const harness = rowKey === "piModel" ? "pi" : "fx";
|
|
342
|
+
|
|
343
|
+
setModelEditor({ harness, text: threadDefaults[harness].model });
|
|
344
|
+
} else if (rowKey === "piEffort" || rowKey === "fxEffort") {
|
|
345
|
+
const harness = rowKey === "piEffort" ? "pi" : "fx";
|
|
346
|
+
const efforts = AGENT_REASONING_EFFORTS;
|
|
347
|
+
const effort: AgentReasoningEffort =
|
|
348
|
+
efforts[(efforts.indexOf(threadDefaults[harness].effort) + 1) % efforts.length]!;
|
|
349
|
+
|
|
350
|
+
persistThreadModelDefault(harness, "effort", effort);
|
|
351
|
+
setThreadDefaults((defaults) => ({
|
|
352
|
+
...defaults,
|
|
353
|
+
[harness]: { ...defaults[harness], effort },
|
|
354
|
+
}));
|
|
355
|
+
} else if (rowKey === "threadHarness") {
|
|
356
|
+
onSwitchHarness?.(threadHarness === "fx" ? "pi" : "fx");
|
|
357
|
+
} else if (rowKey === "autoClose") {
|
|
358
|
+
const next: AutoClose = autoClose === "off" ? 3 : autoClose === 3 ? 10 : "off";
|
|
359
|
+
|
|
360
|
+
setAutoClose(next);
|
|
361
|
+
persistAutoClose(next);
|
|
362
|
+
} else if (rowKey === "diffView") {
|
|
363
|
+
const next: DiffViewMode = diffView === "stacked" ? "split" : "stacked";
|
|
364
|
+
|
|
365
|
+
setDiffView(next);
|
|
366
|
+
persistDiffView(next);
|
|
367
|
+
} else if (rowKey === "theme") {
|
|
368
|
+
const next = THEME_NAMES[(THEME_NAMES.indexOf(themeName) + 1) % THEME_NAMES.length]!;
|
|
369
|
+
|
|
370
|
+
setThemeName(next);
|
|
371
|
+
setTheme(composeTheme(next, themeOverrides, appearance));
|
|
372
|
+
persistTheme(next);
|
|
373
|
+
} else if (rowKey === "syncGithub") {
|
|
374
|
+
onSyncGithubIdentity();
|
|
375
|
+
} else if (rowKey === "displayName") {
|
|
376
|
+
onRenameDisplayName();
|
|
377
|
+
} else if (rowKey === "reviewWorkspace") {
|
|
378
|
+
const next: ReviewWorkspaceMode = reviewWorkspace === "worktree" ? "current" : "worktree";
|
|
379
|
+
|
|
380
|
+
setReviewWorkspace(next);
|
|
381
|
+
persistReviewWorkspace(next);
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const openSettings = (): void => {
|
|
386
|
+
setSettingsNav({ categoryId: "general", rowIndex: 0, zone: "nav" });
|
|
387
|
+
setActionsExpandedIndex(null);
|
|
388
|
+
setMenuDialog("settings");
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
const onCategorySelect = (categoryId: string): void => {
|
|
392
|
+
// ignore a select that names no real category, so the key handler never dereferences nothing
|
|
393
|
+
if (!settingsCategories.some((category) => category.id === categoryId)) return;
|
|
394
|
+
|
|
395
|
+
setActionsExpandedIndex(null);
|
|
396
|
+
setSettingsNav({ categoryId, rowIndex: 0, zone: "body" });
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
const handleSettingsKey = (name: string): void => {
|
|
400
|
+
if (modelEditor) {
|
|
401
|
+
if (name === "escape") setModelEditor(null);
|
|
402
|
+
else if (name === "return") saveModelDefault();
|
|
403
|
+
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// an open system-prompt input owns typing; only esc (close it) escapes here
|
|
408
|
+
if (actionsExpandedIndex !== null) {
|
|
409
|
+
if (name === "escape") setActionsExpandedIndex(null);
|
|
410
|
+
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (name === "escape") return void setMenuDialog(null);
|
|
415
|
+
|
|
416
|
+
const categoryIndex = settingsCategories.findIndex(
|
|
417
|
+
(category) => category.id === settingsNav.categoryId,
|
|
418
|
+
);
|
|
419
|
+
const category = settingsCategories[categoryIndex]!;
|
|
420
|
+
|
|
421
|
+
if (settingsNav.zone === "nav") {
|
|
422
|
+
const next = moveNavZone(name, categoryIndex, settingsCategories);
|
|
423
|
+
|
|
424
|
+
if (next) setSettingsNav(next);
|
|
425
|
+
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// the Actions category is a list of quick actions plus a trailing "add" row
|
|
430
|
+
if (category.id === "actions") {
|
|
431
|
+
const moved = moveBodyRow(name, settingsNav, quickActions.length + 1);
|
|
432
|
+
|
|
433
|
+
if (moved) return void setSettingsNav(moved);
|
|
434
|
+
|
|
435
|
+
if (ACTIVATE_KEYS.has(name)) {
|
|
436
|
+
if (settingsNav.rowIndex === quickActions.length) addAction();
|
|
437
|
+
else {
|
|
438
|
+
setActionsExpandedField("prompt");
|
|
439
|
+
setActionsExpandedIndex(settingsNav.rowIndex);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const moved = moveBodyRow(name, settingsNav, category.rows.length);
|
|
447
|
+
|
|
448
|
+
if (moved) return void setSettingsNav(moved);
|
|
449
|
+
|
|
450
|
+
if (name === "return" || name === "space")
|
|
451
|
+
cycleSetting(category.rows[settingsNav.rowIndex]!.key);
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
return {
|
|
455
|
+
settingsNav,
|
|
456
|
+
actionsExpandedIndex,
|
|
457
|
+
setActionsExpandedIndex,
|
|
458
|
+
settingsCategories,
|
|
459
|
+
settingsValues,
|
|
460
|
+
cycleSetting,
|
|
461
|
+
handleSettingsKey,
|
|
462
|
+
onCategorySelect,
|
|
463
|
+
openSettings,
|
|
464
|
+
};
|
|
465
|
+
}
|