@cueloop/client 0.1.0-alpha.10 → 0.1.0-alpha.100
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 +62 -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 +364 -0
- package/src/annotations/components/DiscussionMarkerRail.stories.tsx +54 -0
- package/src/annotations/components/DiscussionMarkerRail.tsx +186 -0
- package/src/annotations/discussions.ts +77 -0
- package/src/annotations/thread-selection.test.ts +210 -0
- package/src/annotations/thread-selection.ts +242 -0
- package/src/annotations/use-annotation-surface.tsx +1238 -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 +187 -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.identity.test.tsx +84 -0
- package/src/app/App.plan-render.test.tsx +209 -0
- package/src/app/App.plan-review.test.tsx +428 -0
- package/src/app/App.prototype-markdown.test.tsx +128 -0
- package/src/app/App.prototype.test.tsx +176 -0
- package/src/app/App.readonly.test.tsx +210 -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 +496 -0
- package/src/app/App.thread-agent.test.ts +12 -0
- package/src/app/App.toast.test.tsx +124 -0
- package/src/app/App.tsx +1650 -0
- package/src/app/App.visual.test.tsx +59 -0
- package/src/app/App.walk.test.tsx +299 -0
- package/src/app/App.workbench.test.tsx +1149 -0
- package/src/app/app-key-state.ts +61 -0
- package/src/app/app-screens.tsx +606 -0
- package/src/app/app-view-model.ts +168 -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 +120 -0
- package/src/app/components/pages/Workspace.stories.tsx +181 -0
- package/src/app/intent-dispatch.test.ts +728 -0
- package/src/app/intent-dispatch.ts +687 -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 +52 -0
- package/src/app/run.ts +109 -0
- package/src/{serve.test.ts → app/serve.test.ts} +24 -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 +157 -0
- package/src/diff/components/AnnotatableFileView.tsx +141 -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 +434 -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 +82 -0
- package/src/diff/components/DiffContentView.tsx +1055 -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 +84 -0
- package/src/diff/diff-fold.test.ts +78 -0
- package/src/diff/diff-fold.ts +126 -0
- package/src/diff/diff-hunk-curate.test.ts +315 -0
- package/src/diff/diff-hunk-curate.ts +152 -0
- package/src/diff/diff-intraline.test.ts +239 -0
- package/src/diff/diff-intraline.ts +238 -0
- package/src/diff/diff-syntax.test.ts +125 -0
- package/src/diff/diff-syntax.ts +186 -0
- package/src/diff/split-diff.test.ts +110 -0
- package/src/diff/split-diff.ts +144 -0
- package/src/diff/view-diff.test.ts +325 -0
- package/src/diff/view-diff.ts +522 -0
- package/src/diff/walk.test.ts +121 -0
- package/src/diff/walk.ts +73 -0
- package/src/index.ts +31 -2
- package/src/integrations/attribution.test.ts +31 -0
- package/src/integrations/attribution.ts +42 -0
- package/src/integrations/client-extension-registry.test.tsx +61 -0
- package/src/integrations/client-extension-registry.ts +159 -0
- package/src/integrations/clipboard.test.ts +23 -0
- package/src/integrations/clipboard.ts +33 -0
- package/src/integrations/components/ExtensionZone.stories.tsx +28 -0
- package/src/integrations/components/ExtensionZone.tsx +145 -0
- package/src/integrations/components/ShareDialog.stories.tsx +121 -0
- package/src/integrations/components/ShareDialog.tsx +550 -0
- package/src/integrations/components/share-dialog-store.ts +55 -0
- package/src/integrations/editor.test.ts +149 -0
- package/src/integrations/editor.ts +160 -0
- package/src/integrations/github-identity.test.ts +58 -0
- package/src/integrations/github-identity.ts +41 -0
- package/src/integrations/herdr.test.ts +43 -0
- package/src/integrations/herdr.ts +38 -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 +60 -0
- package/src/integrations/share.ts +238 -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 +143 -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 +87 -0
- package/src/keyboard/key-bindings.test.ts +156 -0
- package/src/keyboard/key-bindings.ts +459 -0
- package/src/keyboard/keymap.test.ts +611 -0
- package/src/keyboard/keymap.ts +395 -0
- package/src/keyboard/skills.test.ts +74 -0
- package/src/keyboard/skills.ts +75 -0
- package/src/keyboard/slash-palette.test.ts +103 -0
- package/src/keyboard/slash-palette.ts +129 -0
- package/src/keyboard/thread-chords.test.ts +79 -0
- package/src/keyboard/thread-chords.ts +163 -0
- package/src/keyboard/use-shared-keyboard.ts +55 -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 +160 -0
- package/src/markdown/components/ThreadView.selection.test.tsx +951 -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 +560 -0
- package/src/markdown/mark-runs.ts +121 -0
- package/src/markdown/markdown-editor-syntax-style.ts +50 -0
- package/src/markdown/markdown-grid.test.ts +101 -0
- package/src/markdown/markdown-grid.ts +203 -0
- package/src/markdown/markdown-highlight.test.ts +61 -0
- package/src/markdown/markdown-highlight.ts +124 -0
- package/src/markdown/thread-code-syntax.ts +45 -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 +1009 -0
- package/src/performance/otlp-trace.test.ts +119 -0
- package/src/performance/otlp-trace.ts +134 -0
- package/src/performance/perf-report.ts +18 -0
- package/src/performance/perf-timings.test.ts +18 -0
- package/src/performance/perf-timings.ts +39 -0
- package/src/prototype/components/PrototypeContentView.stories.tsx +19 -0
- package/src/prototype/components/PrototypeContentView.tsx +442 -0
- package/src/prototype/prototype-browser.test.ts +81 -0
- package/src/prototype/prototype-browser.ts +321 -0
- package/src/prototype/prototype-pixels.tsx +35 -0
- package/src/settings/components/SettingsDialog.stories.tsx +117 -0
- package/src/settings/components/SettingsDialog.tsx +183 -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 +676 -0
- package/src/settings/config.ts +628 -0
- package/src/settings/use-settings-dialog.tsx +351 -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 +74 -0
- package/src/stories/story-fixtures.ts +102 -0
- package/src/stories/story-tree.test.ts +108 -0
- package/src/stories/story.ts +154 -0
- package/src/terminal/ansi-screen.test.ts +28 -0
- package/src/terminal/ansi-screen.ts +72 -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 +196 -0
- package/src/terminal/ghostty-terminal.test.ts +85 -0
- package/src/terminal/ghostty-terminal.ts +197 -0
- package/src/terminal/kitty-image.test.ts +66 -0
- package/src/terminal/kitty-image.ts +137 -0
- package/src/terminal/pty.test.ts +81 -0
- package/src/terminal/pty.ts +246 -0
- package/src/testing/test-support.test.ts +264 -0
- package/src/testing/test-support.ts +367 -0
- package/src/thread/agent-continuation.test.ts +32 -0
- package/src/thread/agent-continuation.ts +13 -0
- package/src/thread/agent-transcript.test.ts +161 -0
- package/src/thread/agent-transcript.ts +336 -0
- package/src/thread/components/AgentConfigControls.stories.tsx +39 -0
- package/src/thread/components/AgentConfigControls.test.tsx +112 -0
- package/src/thread/components/AgentConfigControls.tsx +114 -0
- package/src/thread/components/AgentThreadPane.stories.tsx +105 -0
- package/src/thread/components/AgentThreadPane.test.tsx +829 -0
- package/src/thread/components/AgentThreadPane.tsx +367 -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 +267 -0
- package/src/thread/components/thread-tree.test.ts +137 -0
- package/src/thread/components/thread-tree.ts +112 -0
- package/src/thread/thread-controller.curate.test.ts +502 -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 +573 -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 +2018 -0
- package/src/thread/tree-view.test.ts +128 -0
- package/src/thread/tree-view.ts +146 -0
- package/src/thread/use-thread-agent.test.tsx +208 -0
- package/src/thread/use-thread-agent.ts +111 -0
- package/src/ui/components/CodeBlock.stories.tsx +42 -0
- package/src/ui/components/CodeBlock.tsx +80 -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 +139 -0
- package/src/ui/components/OverlayScrollbar.tsx +129 -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 +99 -0
- package/src/ui/components/RootOverlay.stories.tsx +45 -0
- package/src/ui/components/RootOverlay.tsx +49 -0
- package/src/ui/components/ScrollArea.stories.tsx +20 -0
- package/src/ui/components/ScrollArea.tsx +61 -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 +72 -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 +57 -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 +101 -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 +133 -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 +137 -0
- package/src/ui/components/syntax-highlight.ts +133 -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 +15 -0
- package/src/ui/use-frame-measure.ts +74 -0
- package/src/ui/use-terminal-virtualizer.ts +259 -0
- package/src/workbench/components/ChangesColumn.stories.tsx +44 -0
- package/src/workbench/components/ChangesColumn.tsx +203 -0
- package/src/workbench/components/ChangesFileTree.test.tsx +181 -0
- package/src/workbench/components/EditorGrid.split.test.tsx +118 -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 +544 -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 +100 -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 +193 -0
- package/src/workbench/components/ProjectTreeView.stories.tsx +25 -0
- package/src/workbench/components/ProjectTreeView.test.tsx +236 -0
- package/src/workbench/components/ProjectTreeView.tsx +151 -0
- package/src/workbench/components/TreePane.stories.tsx +106 -0
- package/src/workbench/components/TreePane.tsx +155 -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 +281 -0
- package/src/workbench/components/file-tree.test.ts +60 -0
- package/src/workbench/components/file-tree.ts +112 -0
- package/src/workbench/use-changes-workbench.ts +205 -0
- package/src/workbench/use-remember-layout.ts +31 -0
- package/src/workbench/use-repo-changes.ts +91 -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,80 @@
|
|
|
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 "../../appearance/theme";
|
|
11
|
+
import { useComponentTheme } from "../../appearance/components/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
|
+
language?: string;
|
|
20
|
+
content: string;
|
|
21
|
+
isCursor?: boolean;
|
|
22
|
+
marginTop?: number;
|
|
23
|
+
isAnnotated?: boolean;
|
|
24
|
+
changeTag?: "new" | "edited";
|
|
25
|
+
cut?: boolean;
|
|
26
|
+
theme?: Theme;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function CodeBlock({
|
|
30
|
+
id,
|
|
31
|
+
language,
|
|
32
|
+
content,
|
|
33
|
+
isCursor = false,
|
|
34
|
+
marginTop = 0,
|
|
35
|
+
isAnnotated = false,
|
|
36
|
+
changeTag,
|
|
37
|
+
cut = false,
|
|
38
|
+
theme,
|
|
39
|
+
}: CodeBlockProps): React.ReactNode {
|
|
40
|
+
const tokens = useComponentTheme(theme);
|
|
41
|
+
const tagColor = changeTag === "new" ? tokens.green : tokens.accent;
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<box id={id} style={{ flexDirection: "column", marginTop }}>
|
|
45
|
+
<text>
|
|
46
|
+
<span fg={isCursor ? tokens.accent : tokens.textDim}>{isCursor ? "▎ " : " "}</span>
|
|
47
|
+
<span fg={tokens.textDim}>{language ?? "code"}</span>
|
|
48
|
+
{isAnnotated ? <span fg={tokens.accent}> ◆</span> : null}
|
|
49
|
+
{changeTag ? <span fg={tagColor}> [{changeTag}]</span> : null}
|
|
50
|
+
</text>
|
|
51
|
+
<box
|
|
52
|
+
style={{
|
|
53
|
+
flexDirection: "column",
|
|
54
|
+
backgroundColor: tokens.elevated,
|
|
55
|
+
paddingLeft: 2,
|
|
56
|
+
paddingRight: 2,
|
|
57
|
+
paddingTop: 1,
|
|
58
|
+
paddingBottom: 1,
|
|
59
|
+
marginLeft: 2,
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
{cut ? (
|
|
63
|
+
<text style={{ wrapMode: "none" }} selectable={false}>
|
|
64
|
+
<span fg={tokens.textDim} attributes={CUT_ATTRIBUTES}>
|
|
65
|
+
{content}
|
|
66
|
+
</span>
|
|
67
|
+
</text>
|
|
68
|
+
) : (
|
|
69
|
+
<code
|
|
70
|
+
content={content}
|
|
71
|
+
filetype={filetypeFor(language)}
|
|
72
|
+
syntaxStyle={syntaxStyleFor(tokens)}
|
|
73
|
+
selectable={false}
|
|
74
|
+
style={{ wrapMode: "none", fg: tokens.textMuted, bg: tokens.elevated }}
|
|
75
|
+
/>
|
|
76
|
+
)}
|
|
77
|
+
</box>
|
|
78
|
+
</box>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DARK } from "../../appearance/theme";
|
|
3
|
+
import { DEFAULT_QUICK_ACTIONS } from "../../settings/config";
|
|
4
|
+
import type { Story, StoryMeta } from "../../stories/story";
|
|
5
|
+
import { ConfirmCard } from "./ConfirmCard";
|
|
6
|
+
|
|
7
|
+
export const meta: StoryMeta = { title: "Cards/ConfirmCard" };
|
|
8
|
+
|
|
9
|
+
const callbacks = {
|
|
10
|
+
onInput: () => {},
|
|
11
|
+
onSelectMessage: () => {},
|
|
12
|
+
onSubmit: () => {},
|
|
13
|
+
onCancel: () => {},
|
|
14
|
+
quickActions: DEFAULT_QUICK_ACTIONS,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const ApproveDefault: Story = {
|
|
18
|
+
render: () => <ConfirmCard message="approved" summary="" {...callbacks} />,
|
|
19
|
+
expectedColors: [DARK.green, DARK.accent],
|
|
20
|
+
size: { width: 40, height: 14 },
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const RequestChanges: Story = {
|
|
24
|
+
render: () => (
|
|
25
|
+
<ConfirmCard message="changes_requested" summary="Tighten the steps." {...callbacks} />
|
|
26
|
+
),
|
|
27
|
+
expectedColors: [DARK.red],
|
|
28
|
+
size: { width: 40, height: 14 },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const WithViewedSummary: Story = {
|
|
32
|
+
render: () => (
|
|
33
|
+
<ConfirmCard message="approved" summary="" viewedSummary="2/3 files viewed" {...callbacks} />
|
|
34
|
+
),
|
|
35
|
+
expectedColors: [DARK.green, DARK.textDim],
|
|
36
|
+
size: { width: 40, height: 14 },
|
|
37
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Submit button expanded into a bordered confirm card at the rail bottom:
|
|
3
|
+
* the message selector (arrow keys or click), the optional summary, and plain
|
|
4
|
+
* word-buttons - key hints live in the status line only. The bordered height
|
|
5
|
+
* derives from the content rows through Card, so layout and render never drift.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, { useContext } from "react";
|
|
9
|
+
import { useTerminalDimensions } from "@opentui/react";
|
|
10
|
+
import { MESSAGE_OUTCOMES, type MessageOutcome } from "@cueloop/schema";
|
|
11
|
+
import type { Theme } from "../../appearance/theme";
|
|
12
|
+
import type { QuickAction } from "../../settings/config";
|
|
13
|
+
import { SlashSkillsContext } from "../../keyboard/skills";
|
|
14
|
+
import {
|
|
15
|
+
activeSlashToken,
|
|
16
|
+
mergeSlashItems,
|
|
17
|
+
slashFilter,
|
|
18
|
+
slashItemsFrom,
|
|
19
|
+
} from "../../keyboard/slash-palette";
|
|
20
|
+
import { useComponentTheme } from "../../appearance/components/theme-context";
|
|
21
|
+
import { Card } from "./primitives/Card";
|
|
22
|
+
import { composeRowCount } from "../../annotations/components/AnnotationCards";
|
|
23
|
+
import { SlashComposer } from "../../keyboard/components/SlashComposer";
|
|
24
|
+
import { DialogActions } from "./primitives/DialogActions";
|
|
25
|
+
|
|
26
|
+
const SUBMIT_CARD_MAX_WIDTH = 52;
|
|
27
|
+
const PALETTE_WINDOW = 5;
|
|
28
|
+
|
|
29
|
+
/** Selector words in the confirm card - one word per message. */
|
|
30
|
+
export const MESSAGE_OUTCOME_LABEL: Record<MessageOutcome, string> = {
|
|
31
|
+
comment: "comment",
|
|
32
|
+
approved: "approve",
|
|
33
|
+
changes_requested: "changes",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export interface ConfirmCardProps {
|
|
37
|
+
message: MessageOutcome;
|
|
38
|
+
summary: string;
|
|
39
|
+
viewedSummary?: string;
|
|
40
|
+
onInput: (summary: string) => void;
|
|
41
|
+
onSelectMessage: (message: MessageOutcome) => void;
|
|
42
|
+
onSubmit: () => void;
|
|
43
|
+
onCancel: () => void;
|
|
44
|
+
quickActions: QuickAction[];
|
|
45
|
+
theme?: Theme;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** 1-row message selector, spacer, summary input, spacer, buttons. */
|
|
49
|
+
const CONFIRM_CONTENT_ROWS = 5;
|
|
50
|
+
|
|
51
|
+
export function outcomeColor(message: MessageOutcome, tokens: Theme): string {
|
|
52
|
+
return message === "approved"
|
|
53
|
+
? tokens.green
|
|
54
|
+
: message === "changes_requested"
|
|
55
|
+
? tokens.red
|
|
56
|
+
: tokens.blue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The message selector: one row of pressable words in reading order.
|
|
61
|
+
* Selection stays controlled by the grammar (←/→ cycle the message); a click
|
|
62
|
+
* selects directly. Every message keeps its brackets so active color never changes the row's
|
|
63
|
+
* width or moves a neighboring choice.
|
|
64
|
+
*/
|
|
65
|
+
function MessageSelector({
|
|
66
|
+
message,
|
|
67
|
+
onSelectMessage,
|
|
68
|
+
theme,
|
|
69
|
+
}: {
|
|
70
|
+
message: MessageOutcome;
|
|
71
|
+
onSelectMessage: (message: MessageOutcome) => void;
|
|
72
|
+
theme?: Theme;
|
|
73
|
+
}): React.ReactNode {
|
|
74
|
+
const tokens = useComponentTheme(theme);
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<box style={{ flexDirection: "row", height: 1, width: "100%", justifyContent: "center" }}>
|
|
78
|
+
{MESSAGE_OUTCOMES.map((candidate) => (
|
|
79
|
+
<box
|
|
80
|
+
key={candidate}
|
|
81
|
+
style={{ paddingRight: 1 }}
|
|
82
|
+
onMouseUp={() => onSelectMessage(candidate)}
|
|
83
|
+
>
|
|
84
|
+
<text fg={candidate === message ? outcomeColor(candidate, tokens) : tokens.textDim}>
|
|
85
|
+
{`[${MESSAGE_OUTCOME_LABEL[candidate]}]`}
|
|
86
|
+
</text>
|
|
87
|
+
</box>
|
|
88
|
+
))}
|
|
89
|
+
</box>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function ConfirmCard({
|
|
94
|
+
message,
|
|
95
|
+
summary,
|
|
96
|
+
viewedSummary,
|
|
97
|
+
onInput,
|
|
98
|
+
onSelectMessage,
|
|
99
|
+
onSubmit,
|
|
100
|
+
onCancel,
|
|
101
|
+
quickActions,
|
|
102
|
+
theme,
|
|
103
|
+
}: ConfirmCardProps): React.ReactNode {
|
|
104
|
+
const tokens = useComponentTheme(theme);
|
|
105
|
+
const skills = useContext(SlashSkillsContext);
|
|
106
|
+
const { width: terminalWidth } = useTerminalDimensions();
|
|
107
|
+
const cardWidth = Math.max(24, Math.min(terminalWidth - 2, SUBMIT_CARD_MAX_WIDTH));
|
|
108
|
+
|
|
109
|
+
const composerRows = composeRowCount(summary, cardWidth - 4);
|
|
110
|
+
const token = activeSlashToken(summary, summary.length);
|
|
111
|
+
const paletteItems =
|
|
112
|
+
token !== null
|
|
113
|
+
? slashFilter(mergeSlashItems(slashItemsFrom(quickActions), skills), token.slice(1))
|
|
114
|
+
: [];
|
|
115
|
+
const paletteRows =
|
|
116
|
+
paletteItems.length > 0
|
|
117
|
+
? Math.min(PALETTE_WINDOW, paletteItems.length) +
|
|
118
|
+
(paletteItems.length > PALETTE_WINDOW ? 1 : 0)
|
|
119
|
+
: 0;
|
|
120
|
+
const contentRows =
|
|
121
|
+
CONFIRM_CONTENT_ROWS - 1 + composerRows + paletteRows + (viewedSummary !== undefined ? 2 : 0);
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<Card
|
|
125
|
+
contentRows={contentRows}
|
|
126
|
+
width={cardWidth}
|
|
127
|
+
borderColor={tokens.accent}
|
|
128
|
+
backgroundColor={tokens.elevated}
|
|
129
|
+
theme={theme}
|
|
130
|
+
>
|
|
131
|
+
{viewedSummary !== undefined ? <text fg={tokens.textDim}>{viewedSummary}</text> : null}
|
|
132
|
+
{viewedSummary !== undefined ? <box style={{ height: 1 }} /> : null}
|
|
133
|
+
<MessageSelector message={message} onSelectMessage={onSelectMessage} theme={theme} />
|
|
134
|
+
<box style={{ height: 1 }} />
|
|
135
|
+
<SlashComposer
|
|
136
|
+
seed={summary}
|
|
137
|
+
glyph=""
|
|
138
|
+
quickActions={quickActions}
|
|
139
|
+
tokens={tokens}
|
|
140
|
+
placeholder="summary for the agent (optional)"
|
|
141
|
+
onSubmit={(text) => {
|
|
142
|
+
onInput(text);
|
|
143
|
+
onSubmit();
|
|
144
|
+
}}
|
|
145
|
+
onInput={onInput}
|
|
146
|
+
/>
|
|
147
|
+
<box style={{ height: 1 }} />
|
|
148
|
+
<DialogActions confirmLabel="send" onConfirm={onSubmit} onCancel={onCancel} theme={theme} />
|
|
149
|
+
</Card>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DARK } from "../../appearance/theme";
|
|
3
|
+
import type { Story, StoryMeta } from "../../stories/story";
|
|
4
|
+
import { ConfirmDialog } from "./ConfirmDialog";
|
|
5
|
+
|
|
6
|
+
export const meta: StoryMeta = { title: "Overlays/ConfirmDialog" };
|
|
7
|
+
|
|
8
|
+
const callbacks = { onConfirm: () => {}, onCancel: () => {} };
|
|
9
|
+
|
|
10
|
+
export const DeleteThread: Story = {
|
|
11
|
+
render: () => (
|
|
12
|
+
<ConfirmDialog
|
|
13
|
+
isOpen
|
|
14
|
+
title=" delete thread "
|
|
15
|
+
message={'Delete "Auth rollout"? This removes the thread.'}
|
|
16
|
+
{...callbacks}
|
|
17
|
+
/>
|
|
18
|
+
),
|
|
19
|
+
expectedColors: [DARK.accent],
|
|
20
|
+
size: { width: 64, height: 16 },
|
|
21
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A centered yes/no confirmation on the shared Dialog overlay. Presentational:
|
|
3
|
+
* the key grammar (⏎ confirm, esc cancel) is driven by the reducer; the buttons
|
|
4
|
+
* carry the same intents for the mouse. Used for destructive actions like the
|
|
5
|
+
* inbox delete.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { useTerminalDimensions } from "@opentui/react";
|
|
10
|
+
import type { Theme } from "../../appearance/theme";
|
|
11
|
+
import { useComponentTheme } from "../../appearance/components/theme-context";
|
|
12
|
+
import { Dialog } from "./primitives/Dialog";
|
|
13
|
+
import { DialogActions } from "./primitives/DialogActions";
|
|
14
|
+
|
|
15
|
+
export interface ConfirmDialogProps {
|
|
16
|
+
isOpen: boolean;
|
|
17
|
+
title?: string;
|
|
18
|
+
message: string;
|
|
19
|
+
confirmLabel?: string;
|
|
20
|
+
cancelLabel?: string;
|
|
21
|
+
onConfirm: () => void;
|
|
22
|
+
onCancel: () => void;
|
|
23
|
+
theme?: Theme;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function ConfirmDialog({
|
|
27
|
+
isOpen,
|
|
28
|
+
title,
|
|
29
|
+
message,
|
|
30
|
+
confirmLabel = "delete",
|
|
31
|
+
cancelLabel = "cancel",
|
|
32
|
+
onConfirm,
|
|
33
|
+
onCancel,
|
|
34
|
+
theme,
|
|
35
|
+
}: ConfirmDialogProps): React.ReactNode {
|
|
36
|
+
const tokens = useComponentTheme(theme);
|
|
37
|
+
const { width: terminalWidth } = useTerminalDimensions();
|
|
38
|
+
|
|
39
|
+
if (!isOpen) return null;
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Dialog
|
|
43
|
+
isOpen
|
|
44
|
+
title={title}
|
|
45
|
+
width={Math.min(54, terminalWidth - 6)}
|
|
46
|
+
height={7}
|
|
47
|
+
background={tokens.elevated}
|
|
48
|
+
onDismiss={onCancel}
|
|
49
|
+
theme={theme}
|
|
50
|
+
>
|
|
51
|
+
<box
|
|
52
|
+
style={{
|
|
53
|
+
flexDirection: "column",
|
|
54
|
+
flexGrow: 1,
|
|
55
|
+
paddingLeft: 1,
|
|
56
|
+
paddingRight: 1,
|
|
57
|
+
paddingTop: 1,
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<text fg={tokens.text}>{message}</text>
|
|
61
|
+
<box style={{ flexGrow: 1 }} />
|
|
62
|
+
<DialogActions
|
|
63
|
+
confirmLabel={confirmLabel}
|
|
64
|
+
cancelLabel={cancelLabel}
|
|
65
|
+
onConfirm={onConfirm}
|
|
66
|
+
onCancel={onCancel}
|
|
67
|
+
theme={theme}
|
|
68
|
+
/>
|
|
69
|
+
</box>
|
|
70
|
+
</Dialog>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { useRef } from "react";
|
|
2
|
+
import type { ScrollBoxRenderable } from "@opentui/core";
|
|
3
|
+
import { DARK } from "../../appearance/theme";
|
|
4
|
+
import { OverlayScrollbar } from "./OverlayScrollbar";
|
|
5
|
+
import type { Story, StoryMeta } from "../../stories/story";
|
|
6
|
+
|
|
7
|
+
export const meta: StoryMeta = { title: "Chrome/OverlayScrollbar" };
|
|
8
|
+
|
|
9
|
+
function TallSurface(): React.ReactNode {
|
|
10
|
+
const scrollRef = useRef<ScrollBoxRenderable | null>(null);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<box style={{ width: 24, height: 8, flexDirection: "row", backgroundColor: DARK.background }}>
|
|
14
|
+
<scrollbox
|
|
15
|
+
ref={scrollRef}
|
|
16
|
+
style={{ flexGrow: 1 }}
|
|
17
|
+
focused={false}
|
|
18
|
+
verticalScrollbarOptions={{ visible: false }}
|
|
19
|
+
>
|
|
20
|
+
{Array.from({ length: 24 }, (_unused, index) => (
|
|
21
|
+
<text key={index} fg={DARK.textMuted}>{`row ${index + 1}`}</text>
|
|
22
|
+
))}
|
|
23
|
+
</scrollbox>
|
|
24
|
+
<OverlayScrollbar scrollbox={scrollRef} />
|
|
25
|
+
</box>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// At rest the overlay bar is hidden; the thumb only appears while the surface is scrolling.
|
|
30
|
+
export const AtRest: Story = {
|
|
31
|
+
render: () => <TallSurface />,
|
|
32
|
+
size: { width: 24, height: 8 },
|
|
33
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The mirrored scrollbar: thumb geometry follows the scroll state, and on a surface it
|
|
3
|
+
* draws as the panel's rightmost column, past the discussion dots - not inside the
|
|
4
|
+
* scrollbox's own viewport row.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { describe, expect, test } from "bun:test";
|
|
8
|
+
import { testRender } from "@opentui/react/test-utils";
|
|
9
|
+
import { ScrollBoxRenderable, type Renderable } from "@opentui/core";
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { DiffContentView } from "../../diff/components/DiffContentView";
|
|
12
|
+
import { diffRows, marksByRows } from "../../diff/view-diff";
|
|
13
|
+
import { allowEventLoopUpdates } from "../../testing/test-support";
|
|
14
|
+
import { fixtureDiffSession } from "../../stories/story-fixtures";
|
|
15
|
+
import { DARK } from "../../appearance/theme";
|
|
16
|
+
import { thumbGeometry } from "./OverlayScrollbar";
|
|
17
|
+
|
|
18
|
+
const noop = (): void => {};
|
|
19
|
+
|
|
20
|
+
function findById(node: Renderable, id: string): Renderable | undefined {
|
|
21
|
+
if (node.id === id) return node;
|
|
22
|
+
for (const child of node.getChildren()) {
|
|
23
|
+
const found = findById(child, id);
|
|
24
|
+
|
|
25
|
+
if (found) return found;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function hex(color: { toInts(): [number, number, number, number] }): string {
|
|
32
|
+
const [red, green, blue] = color.toInts();
|
|
33
|
+
|
|
34
|
+
return "#" + [red, green, blue].map((part) => part.toString(16).padStart(2, "0")).join("");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe("thumbGeometry", () => {
|
|
38
|
+
test("nothing to scroll draws no thumb", () => {
|
|
39
|
+
// Arrange / Act / Assert - content fits the viewport
|
|
40
|
+
expect(thumbGeometry({ top: 0, height: 10, viewport: 14 }, 14)).toBeNull();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("the thumb's height is the viewport's share of the content, at least one row", () => {
|
|
44
|
+
// Act
|
|
45
|
+
const tall = thumbGeometry({ top: 0, height: 44, viewport: 14 }, 14);
|
|
46
|
+
const tiny = thumbGeometry({ top: 0, height: 10_000, viewport: 14 }, 14);
|
|
47
|
+
|
|
48
|
+
// Assert
|
|
49
|
+
expect(tall).toEqual({ row: 0, height: 4 });
|
|
50
|
+
expect(tiny?.height).toBe(1);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("the thumb reaches the track's end at the maximum scroll offset", () => {
|
|
54
|
+
// Act - scrolled to the bottom
|
|
55
|
+
const thumb = thumbGeometry({ top: 30, height: 44, viewport: 14 }, 14);
|
|
56
|
+
|
|
57
|
+
// Assert - its last row is the track's last row
|
|
58
|
+
expect(thumb).toEqual({ row: 10, height: 4 });
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("the diff sheet's scrollbar", () => {
|
|
63
|
+
const body = Array.from({ length: 40 }, (_unused, index) => `+line ${index} of the change;`).join(
|
|
64
|
+
"\n",
|
|
65
|
+
);
|
|
66
|
+
const patch = `diff --git a/x.ts b/x.ts\n--- a/x.ts\n+++ b/x.ts\n@@ -0,0 +1,40 @@\n${body}\n`;
|
|
67
|
+
|
|
68
|
+
test("draws as the rightmost column, past the discussion dot", async () => {
|
|
69
|
+
// Arrange - a diff taller than the viewport, with one discussion so the dot rail has a dot
|
|
70
|
+
const rows = diffRows(patch);
|
|
71
|
+
const session = fixtureDiffSession({
|
|
72
|
+
annotations: [
|
|
73
|
+
{
|
|
74
|
+
id: "a1",
|
|
75
|
+
kind: "comment",
|
|
76
|
+
body: "hm",
|
|
77
|
+
anchor: { quote: "line 7 of the change;", prefix: "", suffix: "" },
|
|
78
|
+
createdAt: "2026-01-01T00:00:00Z",
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
});
|
|
82
|
+
const width = 60;
|
|
83
|
+
const setup = await testRender(
|
|
84
|
+
<DiffContentView
|
|
85
|
+
rows={rows}
|
|
86
|
+
session={session}
|
|
87
|
+
marks={marksByRows(session.annotations, rows)}
|
|
88
|
+
quickActions={[]}
|
|
89
|
+
observer={false}
|
|
90
|
+
onAnnotate={noop}
|
|
91
|
+
onReply={noop}
|
|
92
|
+
onUpdateAnnotation={noop}
|
|
93
|
+
onExit={noop}
|
|
94
|
+
/>,
|
|
95
|
+
{ width, height: 14 },
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
allowEventLoopUpdates();
|
|
99
|
+
await setup.waitForVisualIdle();
|
|
100
|
+
// the overlay bar hides at rest; a scroll reveals the thumb
|
|
101
|
+
const scroller = findById(setup.renderer.root, "diff-scroll");
|
|
102
|
+
|
|
103
|
+
if (!(scroller instanceof ScrollBoxRenderable))
|
|
104
|
+
throw new Error("diff-scroll is not a scrollbox");
|
|
105
|
+
const countThumbRows = (): number =>
|
|
106
|
+
setup.captureSpans().lines.filter((line) => {
|
|
107
|
+
let column = 0;
|
|
108
|
+
|
|
109
|
+
for (const span of line.spans) {
|
|
110
|
+
column += span.text.length;
|
|
111
|
+
if (column >= width) return span.bg !== undefined && hex(span.bg) === DARK.textDim;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return false;
|
|
115
|
+
}).length;
|
|
116
|
+
|
|
117
|
+
// the overlay bar reveals on a scroll and hides after an idle delay; alternate the offset to
|
|
118
|
+
// re-trigger the reveal until the thumb is captured, so a slow CI settle never races the hide
|
|
119
|
+
let thumbRows = 0;
|
|
120
|
+
|
|
121
|
+
for (let attempt = 0; attempt < 20 && thumbRows === 0; attempt++) {
|
|
122
|
+
scroller.scrollTo(attempt % 2 === 0 ? 4 : 5);
|
|
123
|
+
await setup.waitForVisualIdle();
|
|
124
|
+
thumbRows = countThumbRows();
|
|
125
|
+
}
|
|
126
|
+
const frame = setup.captureCharFrame().split("\n");
|
|
127
|
+
|
|
128
|
+
// Assert - the thumb occupies the last column at the top (scroll offset 0), and the dot sits
|
|
129
|
+
// to its left in the rail, so the order reads content, dots, scrollbar
|
|
130
|
+
expect(thumbRows).toBe(4);
|
|
131
|
+
const dotLine = frame.find((line) => line.includes("○"));
|
|
132
|
+
|
|
133
|
+
expect(dotLine).toBeDefined();
|
|
134
|
+
expect(dotLine!.indexOf("○")).toBeLessThan(width - 1);
|
|
135
|
+
// let the async highlight settle before the renderer goes away
|
|
136
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
137
|
+
setup.renderer.destroy();
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A one-cell vertical scrollbar that mirrors a scrollbox's scroll state, so the bar can sit
|
|
3
|
+
* where the layout wants it (the panel's rightmost column, past the discussion dots) instead
|
|
4
|
+
* of inside the scrollbox's own viewport row. It is an overlay: the thumb appears while the
|
|
5
|
+
* surface is scrolling and hides once scrolling has been idle, so a resting surface shows none.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, { useEffect, useRef, useState, type RefObject } from "react";
|
|
9
|
+
import type { BoxRenderable, ScrollBoxRenderable } from "@opentui/core";
|
|
10
|
+
import type { Theme } from "../../appearance/theme";
|
|
11
|
+
import { useFrameMeasure } from "../use-frame-measure";
|
|
12
|
+
import { useComponentTheme } from "../../appearance/components/theme-context";
|
|
13
|
+
|
|
14
|
+
const HIDE_DELAY_MS = 1500;
|
|
15
|
+
|
|
16
|
+
interface ScrollState {
|
|
17
|
+
top: number;
|
|
18
|
+
height: number;
|
|
19
|
+
viewport: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ThumbGeometry {
|
|
23
|
+
row: number;
|
|
24
|
+
height: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function thumbGeometry(state: ScrollState, track: number): ThumbGeometry | null {
|
|
28
|
+
if (track <= 0 || state.height <= state.viewport || state.viewport <= 0) return null;
|
|
29
|
+
const height = Math.max(1, Math.round((state.viewport / state.height) * track));
|
|
30
|
+
const maxTop = state.height - state.viewport;
|
|
31
|
+
const row = Math.round((state.top / maxTop) * (track - height));
|
|
32
|
+
|
|
33
|
+
return { row: Math.min(track - height, Math.max(0, row)), height };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface OverlayScrollbarProps {
|
|
37
|
+
scrollbox: RefObject<ScrollBoxRenderable | null>;
|
|
38
|
+
theme?: Theme;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function OverlayScrollbar({ scrollbox, theme }: OverlayScrollbarProps): React.ReactNode {
|
|
42
|
+
const tokens = useComponentTheme(theme);
|
|
43
|
+
const trackRef = useRef<BoxRenderable | null>(null);
|
|
44
|
+
const [visible, setVisible] = useState(false);
|
|
45
|
+
const draggingRef = useRef(false);
|
|
46
|
+
const hideTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
47
|
+
const prevTopRef = useRef<number | null>(null);
|
|
48
|
+
|
|
49
|
+
const state = useFrameMeasure<ScrollState>(
|
|
50
|
+
() => ({
|
|
51
|
+
top: scrollbox.current?.scrollTop ?? 0,
|
|
52
|
+
height: scrollbox.current?.scrollHeight ?? 0,
|
|
53
|
+
viewport: scrollbox.current?.viewport.height ?? 0,
|
|
54
|
+
}),
|
|
55
|
+
(left, right) =>
|
|
56
|
+
left.top === right.top && left.height === right.height && left.viewport === right.viewport,
|
|
57
|
+
{ top: 0, height: 0, viewport: 0 },
|
|
58
|
+
);
|
|
59
|
+
const track = useFrameMeasure(
|
|
60
|
+
() => trackRef.current?.height ?? 0,
|
|
61
|
+
(left, right) => left === right,
|
|
62
|
+
0,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const reveal = (): void => {
|
|
66
|
+
setVisible(true);
|
|
67
|
+
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
68
|
+
hideTimerRef.current = setTimeout(() => {
|
|
69
|
+
if (!draggingRef.current) setVisible(false);
|
|
70
|
+
}, HIDE_DELAY_MS);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// reveal on real scroll movement, never on first mount, then hide once idle
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (prevTopRef.current !== null && state.top !== prevTopRef.current) reveal();
|
|
76
|
+
prevTopRef.current = state.top;
|
|
77
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
|
+
}, [state.top]);
|
|
79
|
+
|
|
80
|
+
useEffect(
|
|
81
|
+
() => () => {
|
|
82
|
+
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
83
|
+
},
|
|
84
|
+
[],
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const geometry = thumbGeometry(state, track);
|
|
88
|
+
const thumb = visible ? geometry : null;
|
|
89
|
+
|
|
90
|
+
const scrollToTrackRow = (screenY: number): void => {
|
|
91
|
+
const box = scrollbox.current;
|
|
92
|
+
|
|
93
|
+
if (!box || !geometry) return;
|
|
94
|
+
const row = screenY - (trackRef.current?.y ?? 0) - Math.floor(geometry.height / 2);
|
|
95
|
+
const ratio = Math.min(1, Math.max(0, row / Math.max(1, track - geometry.height)));
|
|
96
|
+
|
|
97
|
+
box.scrollTo(Math.round(ratio * (state.height - state.viewport)));
|
|
98
|
+
reveal();
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<box
|
|
103
|
+
ref={trackRef}
|
|
104
|
+
style={{ width: 1, flexShrink: 0, flexDirection: "column" }}
|
|
105
|
+
onMouseDown={(event) => {
|
|
106
|
+
draggingRef.current = true;
|
|
107
|
+
scrollToTrackRow(event.y);
|
|
108
|
+
}}
|
|
109
|
+
onMouseDrag={(event) => scrollToTrackRow(event.y)}
|
|
110
|
+
onMouseUp={() => {
|
|
111
|
+
draggingRef.current = false;
|
|
112
|
+
reveal();
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
{thumb ? (
|
|
116
|
+
<box
|
|
117
|
+
style={{
|
|
118
|
+
position: "absolute",
|
|
119
|
+
top: thumb.row,
|
|
120
|
+
left: 0,
|
|
121
|
+
width: 1,
|
|
122
|
+
height: thumb.height,
|
|
123
|
+
backgroundColor: tokens.textDim,
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
) : null}
|
|
127
|
+
</box>
|
|
128
|
+
);
|
|
129
|
+
}
|