@comma-agents/tui 2.0.0-rc.0
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/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/App/App.d.ts +24 -0
- package/dist/App/App.theme.d.ts +12 -0
- package/dist/App/App.types.d.ts +8 -0
- package/dist/App/index.d.ts +4 -0
- package/dist/Theme/DefineTheme.d.ts +53 -0
- package/dist/Theme/Theme.d.ts +11 -0
- package/dist/Theme/Theme.types.d.ts +100 -0
- package/dist/Theme/index.d.ts +9 -0
- package/dist/Theme/themes/dark.d.ts +14 -0
- package/dist/Theme/themes/dracula.d.ts +9 -0
- package/dist/Theme/themes/index.d.ts +25 -0
- package/dist/Theme/themes/light.d.ts +10 -0
- package/dist/Theme/themes/solarized-dark.d.ts +9 -0
- package/dist/Theme/useTheme/index.d.ts +3 -0
- package/dist/Theme/useTheme/useTheme.context.d.ts +31 -0
- package/dist/Theme/useTheme/useTheme.d.ts +11 -0
- package/dist/Theme/useTheme/useTheme.types.d.ts +10 -0
- package/dist/components/BorderedPanel/BorderedPanel.d.ts +70 -0
- package/dist/components/BorderedPanel/BorderedPanel.theme.d.ts +59 -0
- package/dist/components/BorderedPanel/index.d.ts +4 -0
- package/dist/components/Button/Button.d.ts +69 -0
- package/dist/components/Button/Button.theme.d.ts +50 -0
- package/dist/components/Button/Button.types.d.ts +9 -0
- package/dist/components/Button/index.d.ts +4 -0
- package/dist/components/ChatTextArea/ChatTextArea.d.ts +85 -0
- package/dist/components/ChatTextArea/ChatTextArea.theme.d.ts +34 -0
- package/dist/components/ChatTextArea/index.d.ts +2 -0
- package/dist/components/CodeView/CodeView.constants.d.ts +9 -0
- package/dist/components/CodeView/CodeView.d.ts +23 -0
- package/dist/components/CodeView/CodeView.theme.d.ts +26 -0
- package/dist/components/CodeView/index.d.ts +4 -0
- package/dist/components/CommandPalette/CommandPalette.constants.d.ts +8 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +62 -0
- package/dist/components/CommandPalette/CommandPalette.theme.d.ts +50 -0
- package/dist/components/CommandPalette/CommandPalette.types.d.ts +50 -0
- package/dist/components/CommandPalette/CommandPalette.utils.d.ts +6 -0
- package/dist/components/CommandPalette/index.d.ts +5 -0
- package/dist/components/CommandPalette/pages/HelpPage/HelpPage.constants.d.ts +2 -0
- package/dist/components/CommandPalette/pages/HelpPage/HelpPage.d.ts +12 -0
- package/dist/components/CommandPalette/pages/HelpPage/HelpPage.types.d.ts +5 -0
- package/dist/components/CommandPalette/pages/HelpPage/index.d.ts +3 -0
- package/dist/components/CommandPalette/pages/ListProvidersPage/ListProvidersPage.d.ts +42 -0
- package/dist/components/CommandPalette/pages/ListProvidersPage/index.d.ts +1 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.constants.d.ts +3 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.d.ts +40 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.types.d.ts +13 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/RegisteredProvidersPage.utils.d.ts +9 -0
- package/dist/components/CommandPalette/pages/RegisteredProvidersPage/index.d.ts +2 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.constants.d.ts +3 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.d.ts +31 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.types.d.ts +8 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/RunPickerPage.utils.d.ts +7 -0
- package/dist/components/CommandPalette/pages/RunPickerPage/index.d.ts +3 -0
- package/dist/components/CommandPalette/pages/SettingsPage/SettingsPage.d.ts +24 -0
- package/dist/components/CommandPalette/pages/SettingsPage/index.d.ts +2 -0
- package/dist/components/Frame/Frame.d.ts +48 -0
- package/dist/components/Frame/Frame.theme.d.ts +52 -0
- package/dist/components/Frame/index.d.ts +4 -0
- package/dist/components/Hide/Hide.d.ts +20 -0
- package/dist/components/Hide/Hide.types.d.ts +12 -0
- package/dist/components/Hide/index.d.ts +2 -0
- package/dist/components/MessageList/AgentMessage/AgentMessage.d.ts +71 -0
- package/dist/components/MessageList/AgentMessage/index.d.ts +2 -0
- package/dist/components/MessageList/ContextUsageModal/ContextUsageModal.constants.d.ts +2 -0
- package/dist/components/MessageList/ContextUsageModal/ContextUsageModal.d.ts +9 -0
- package/dist/components/MessageList/ContextUsageModal/ContextUsageModal.types.d.ts +12 -0
- package/dist/components/MessageList/ContextUsageModal/index.d.ts +4 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.constants.d.ts +51 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.d.ts +34 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.theme.d.ts +89 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.types.d.ts +96 -0
- package/dist/components/MessageList/MarkdownView/MarkdownView.utils.d.ts +58 -0
- package/dist/components/MessageList/MarkdownView/index.d.ts +6 -0
- package/dist/components/MessageList/MessageList.d.ts +20 -0
- package/dist/components/MessageList/MessageList.theme.d.ts +170 -0
- package/dist/components/MessageList/MessageList.types.d.ts +26 -0
- package/dist/components/MessageList/OutputModal/OutputModal.constants.d.ts +22 -0
- package/dist/components/MessageList/OutputModal/OutputModal.d.ts +37 -0
- package/dist/components/MessageList/OutputModal/OutputModal.theme.d.ts +68 -0
- package/dist/components/MessageList/OutputModal/OutputModal.types.d.ts +56 -0
- package/dist/components/MessageList/OutputModal/OutputModal.utils.d.ts +3 -0
- package/dist/components/MessageList/OutputModal/index.d.ts +6 -0
- package/dist/components/MessageList/SpawnedStrategyView/SpawnedStrategyView.d.ts +47 -0
- package/dist/components/MessageList/SpawnedStrategyView/SpawnedStrategyView.theme.d.ts +58 -0
- package/dist/components/MessageList/SpawnedStrategyView/index.d.ts +4 -0
- package/dist/components/MessageList/SystemMessage/SystemMessage.d.ts +21 -0
- package/dist/components/MessageList/SystemMessage/index.d.ts +2 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.constants.d.ts +42 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.d.ts +71 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.theme.d.ts +47 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.types.d.ts +60 -0
- package/dist/components/MessageList/ToolCallView/ToolCallView.utils.d.ts +40 -0
- package/dist/components/MessageList/ToolCallView/index.d.ts +8 -0
- package/dist/components/MessageList/UserMessage/UserMessage.d.ts +25 -0
- package/dist/components/MessageList/UserMessage/index.d.ts +2 -0
- package/dist/components/MessageList/index.d.ts +14 -0
- package/dist/components/Modal/Modal.d.ts +64 -0
- package/dist/components/Modal/Modal.theme.d.ts +29 -0
- package/dist/components/Modal/index.d.ts +4 -0
- package/dist/components/MouseProvider/MouseContext.d.ts +36 -0
- package/dist/components/MouseProvider/MouseProvider.d.ts +20 -0
- package/dist/components/MouseProvider/index.d.ts +4 -0
- package/dist/components/PermissionPrompt/PermissionPrompt.d.ts +33 -0
- package/dist/components/PermissionPrompt/index.d.ts +2 -0
- package/dist/components/QuestionPrompt/QuestionPrompt.d.ts +4 -0
- package/dist/components/QuestionPrompt/QuestionPrompt.types.d.ts +18 -0
- package/dist/components/QuestionPrompt/index.d.ts +2 -0
- package/dist/components/ScrollableList/ScrollableList.d.ts +33 -0
- package/dist/components/ScrollableList/ScrollableList.theme.d.ts +33 -0
- package/dist/components/ScrollableList/ScrollableList.types.d.ts +66 -0
- package/dist/components/ScrollableList/index.d.ts +4 -0
- package/dist/components/ScrollableView/ScrollableView.d.ts +34 -0
- package/dist/components/ScrollableView/ScrollableView.theme.d.ts +34 -0
- package/dist/components/ScrollableView/ScrollableView.types.d.ts +113 -0
- package/dist/components/ScrollableView/index.d.ts +4 -0
- package/dist/components/Scrollbar/Scrollbar.d.ts +21 -0
- package/dist/components/Scrollbar/Scrollbar.theme.d.ts +16 -0
- package/dist/components/Scrollbar/Scrollbar.types.d.ts +27 -0
- package/dist/components/Scrollbar/Scrollbar.utils.d.ts +21 -0
- package/dist/components/Scrollbar/index.d.ts +4 -0
- package/dist/components/SearchInput/SearchInput.d.ts +22 -0
- package/dist/components/SearchInput/SearchInput.theme.d.ts +30 -0
- package/dist/components/SearchInput/SearchInput.types.d.ts +25 -0
- package/dist/components/SearchInput/SearchInput.utils.d.ts +22 -0
- package/dist/components/SearchInput/index.d.ts +5 -0
- package/dist/components/Separator/Separator.d.ts +39 -0
- package/dist/components/Separator/Separator.theme.d.ts +22 -0
- package/dist/components/Separator/index.d.ts +4 -0
- package/dist/components/StatusBar/StatusBar.d.ts +4 -0
- package/dist/components/StatusBar/StatusBar.theme.d.ts +35 -0
- package/dist/components/StatusBar/StatusBar.types.d.ts +24 -0
- package/dist/components/StatusBar/index.d.ts +2 -0
- package/dist/components/TextAreaInput/TextAreaInput.d.ts +68 -0
- package/dist/components/TextAreaInput/TextAreaInput.theme.d.ts +14 -0
- package/dist/components/TextAreaInput/TextAreaInput.utils.d.ts +69 -0
- package/dist/components/TextAreaInput/index.d.ts +2 -0
- package/dist/components/TitleIcon/TitleIcon.d.ts +13 -0
- package/dist/components/TitleIcon/TitleIcon.theme.d.ts +19 -0
- package/dist/components/TitleIcon/index.d.ts +1 -0
- package/dist/components/index.d.ts +61 -0
- package/dist/hooks/index.d.ts +27 -0
- package/dist/hooks/useBreakpoint/index.d.ts +2 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.d.ts +15 -0
- package/dist/hooks/useBreakpoint/useBreakpoint.types.d.ts +18 -0
- package/dist/hooks/useChat/index.d.ts +22 -0
- package/dist/hooks/useChat/useChat.context.d.ts +7 -0
- package/dist/hooks/useChat/useChat.d.ts +11 -0
- package/dist/hooks/useChat/useChat.types.d.ts +209 -0
- package/dist/hooks/useChat/useChat.utils.d.ts +18 -0
- package/dist/hooks/useChat/useChatActions.d.ts +10 -0
- package/dist/hooks/useChat/useChatAgentMessages/index.d.ts +1 -0
- package/dist/hooks/useChat/useChatAgentMessages/useChatAgentMessages.d.ts +2 -0
- package/dist/hooks/useChat/useChatInputRequests/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatInputRequests/useChatInputRequests.d.ts +3 -0
- package/dist/hooks/useChat/useChatInputRequests/useChatInputRequests.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatLifecycle.d.ts +5 -0
- package/dist/hooks/useChat/useChatPermissionRequests/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatPermissionRequests/useChatPermissionRequestSubscriptions.d.ts +2 -0
- package/dist/hooks/useChat/useChatPermissionRequests/useChatPermissionRequests.d.ts +3 -0
- package/dist/hooks/useChat/useChatPermissionRequests/useChatPermissionRequests.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatQuestionRequests/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatQuestionRequests/useChatQuestionRequestSubscriptions.d.ts +2 -0
- package/dist/hooks/useChat/useChatQuestionRequests/useChatQuestionRequests.d.ts +3 -0
- package/dist/hooks/useChat/useChatQuestionRequests/useChatQuestionRequests.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatRunLifecycle/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatRunLifecycle/useChatRunLifecycle.d.ts +3 -0
- package/dist/hooks/useChat/useChatRunLifecycle/useChatRunLifecycle.types.d.ts +11 -0
- package/dist/hooks/useChat/useChatRunLifecycle/useChatRunLifecycleSubscriptions.d.ts +2 -0
- package/dist/hooks/useChat/useChatRunStore/index.d.ts +1 -0
- package/dist/hooks/useChat/useChatRunStore/useChatRunStore.d.ts +3 -0
- package/dist/hooks/useChat/useChatRuns.d.ts +10 -0
- package/dist/hooks/useChat/useChatState.d.ts +17 -0
- package/dist/hooks/useChat/useChatSteering/index.d.ts +2 -0
- package/dist/hooks/useChat/useChatSteering/useChatSteering.d.ts +3 -0
- package/dist/hooks/useChat/useChatSteering/useChatSteering.types.d.ts +4 -0
- package/dist/hooks/useChat/useChatStepMessages/index.d.ts +1 -0
- package/dist/hooks/useChat/useChatStepMessages/useChatStepMessages.d.ts +2 -0
- package/dist/hooks/useChat/usePersistedRunList/index.d.ts +2 -0
- package/dist/hooks/useChat/usePersistedRunList/usePersistedRunList.d.ts +3 -0
- package/dist/hooks/useChat/usePersistedRunList/usePersistedRunList.types.d.ts +5 -0
- package/dist/hooks/useDaemon/index.d.ts +6 -0
- package/dist/hooks/useDaemon/useDaemon.context.d.ts +18 -0
- package/dist/hooks/useDaemon/useDaemon.d.ts +7 -0
- package/dist/hooks/useDaemon/useDaemon.types.d.ts +62 -0
- package/dist/hooks/useDaemon/useDaemonCommand/index.d.ts +2 -0
- package/dist/hooks/useDaemon/useDaemonCommand/useDaemonCommand.d.ts +20 -0
- package/dist/hooks/useDaemon/useDaemonCommand/useDaemonCommand.types.d.ts +28 -0
- package/dist/hooks/useDaemon/useDaemonSubscription/index.d.ts +1 -0
- package/dist/hooks/useDaemon/useDaemonSubscription/useDaemonSubscription.d.ts +18 -0
- package/dist/hooks/useDebugRender/index.d.ts +2 -0
- package/dist/hooks/useDebugRender/useDebugRender.constants.d.ts +18 -0
- package/dist/hooks/useDebugRender/useDebugRender.d.ts +35 -0
- package/dist/hooks/useDebugRender/useDebugRender.types.d.ts +60 -0
- package/dist/hooks/useDebugRender/useDebugRender.utils.d.ts +34 -0
- package/dist/hooks/useLogs/index.d.ts +3 -0
- package/dist/hooks/useLogs/logStore.d.ts +18 -0
- package/dist/hooks/useLogs/useLogs.constants.d.ts +2 -0
- package/dist/hooks/useLogs/useLogs.d.ts +15 -0
- package/dist/hooks/useLogs/useLogs.types.d.ts +47 -0
- package/dist/hooks/useLogs/useLogs.utils.d.ts +13 -0
- package/dist/hooks/useModal/index.d.ts +3 -0
- package/dist/hooks/useModal/useModal.context.d.ts +20 -0
- package/dist/hooks/useModal/useModal.d.ts +22 -0
- package/dist/hooks/useModal/useModal.types.d.ts +49 -0
- package/dist/hooks/useMouse/index.d.ts +2 -0
- package/dist/hooks/useMouse/useMouse.types.d.ts +43 -0
- package/dist/hooks/useMouse/useMouse.utils.d.ts +30 -0
- package/dist/hooks/useMouseClick/index.d.ts +2 -0
- package/dist/hooks/useMouseClick/useMouseClick.d.ts +23 -0
- package/dist/hooks/useMouseClick/useMouseClick.types.d.ts +28 -0
- package/dist/hooks/useMouseHover/index.d.ts +2 -0
- package/dist/hooks/useMouseHover/useMouseHover.d.ts +25 -0
- package/dist/hooks/useMouseHover/useMouseHover.types.d.ts +38 -0
- package/dist/hooks/useMouseWheelScroll/index.d.ts +2 -0
- package/dist/hooks/useMouseWheelScroll/useMouseWheelScroll.d.ts +28 -0
- package/dist/hooks/useMouseWheelScroll/useMouseWheelScroll.types.d.ts +32 -0
- package/dist/hooks/useRegion/index.d.ts +3 -0
- package/dist/hooks/useRegion/useRegion.d.ts +21 -0
- package/dist/hooks/useRegion/useRegion.types.d.ts +41 -0
- package/dist/hooks/useRegion/useRegion.utils.d.ts +51 -0
- package/dist/hooks/useStrategies/useStrategies.d.ts +10 -0
- package/dist/hooks/useToolSpinner/index.d.ts +1 -0
- package/dist/hooks/useToolSpinner/useToolSpinner.d.ts +28 -0
- package/dist/hooks/useUserConfig/index.d.ts +4 -0
- package/dist/hooks/useUserConfig/useUserConfig.constants.d.ts +17 -0
- package/dist/hooks/useUserConfig/useUserConfig.context.d.ts +9 -0
- package/dist/hooks/useUserConfig/useUserConfig.d.ts +9 -0
- package/dist/hooks/useUserConfig/useUserConfig.types.d.ts +30 -0
- package/dist/hooks/useUserConfig/useUserConfig.utils.d.ts +19 -0
- package/dist/hooks/useWebSocket/index.d.ts +2 -0
- package/dist/hooks/useWebSocket/useWebSocket.d.ts +17 -0
- package/dist/hooks/useWebSocket/useWebSocket.types.d.ts +27 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10592 -0
- package/dist/main.js +10655 -0
- package/dist/pages/ChatPage/ChatPage.constants.d.ts +2 -0
- package/dist/pages/ChatPage/ChatPage.d.ts +25 -0
- package/dist/pages/ChatPage/ChatPage.theme.d.ts +56 -0
- package/dist/pages/ChatPage/index.d.ts +4 -0
- package/dist/pages/IntroPage/IntroPage.d.ts +14 -0
- package/dist/pages/IntroPage/IntroPage.theme.d.ts +13 -0
- package/dist/pages/IntroPage/index.d.ts +4 -0
- package/dist/pages/LogsPage/LogsPage.d.ts +14 -0
- package/dist/pages/LogsPage/LogsPage.theme.d.ts +49 -0
- package/dist/pages/LogsPage/LogsPage.utils.d.ts +5 -0
- package/dist/pages/LogsPage/index.d.ts +4 -0
- package/dist/pages/SpawnedStrategyPage/SpawnedStrategyPage.d.ts +12 -0
- package/dist/pages/SpawnedStrategyPage/index.d.ts +2 -0
- package/dist/run-tui.d.ts +12 -0
- package/dist/run-tui.types.d.ts +12 -0
- package/dist/utils/debug.d.ts +12 -0
- package/dist/utils/mouseEscape.d.ts +29 -0
- package/dist/utils/yogaLayout.d.ts +32 -0
- package/package.json +66 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ThemeOf } from "../../../Theme";
|
|
2
|
+
/**
|
|
3
|
+
* Memoized themed style objects for the {@link ToolCallView} component.
|
|
4
|
+
*
|
|
5
|
+
* Every nested object is a spread-ready literal sized to be applied
|
|
6
|
+
* directly to an Ink `<Box>` or `<Text>` — the consumer never reaches in
|
|
7
|
+
* to mutate or re-derive styles, which keeps the render path branch-free
|
|
8
|
+
* and makes snapshot diffs predictable.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useToolCallViewTheme: () => {
|
|
11
|
+
/** Outer container — a single column row spaced from the previous segment. */
|
|
12
|
+
container: {
|
|
13
|
+
flexDirection: "column";
|
|
14
|
+
marginTop: number;
|
|
15
|
+
};
|
|
16
|
+
/** Glyph color when the call is still in flight. */
|
|
17
|
+
runningGlyph: {
|
|
18
|
+
color: string;
|
|
19
|
+
};
|
|
20
|
+
/** Glyph color on success. */
|
|
21
|
+
completedGlyph: {
|
|
22
|
+
color: string;
|
|
23
|
+
};
|
|
24
|
+
/** Glyph color on failure. */
|
|
25
|
+
errorGlyph: {
|
|
26
|
+
color: string;
|
|
27
|
+
};
|
|
28
|
+
/** Tool name style. */
|
|
29
|
+
toolName: {
|
|
30
|
+
bold: boolean;
|
|
31
|
+
color: string;
|
|
32
|
+
};
|
|
33
|
+
/** Args preview style. */
|
|
34
|
+
args: {
|
|
35
|
+
dimColor: boolean;
|
|
36
|
+
};
|
|
37
|
+
/** Result summary (success path). */
|
|
38
|
+
resultSummary: {
|
|
39
|
+
dimColor: boolean;
|
|
40
|
+
};
|
|
41
|
+
/** Result summary (error path). */
|
|
42
|
+
errorSummary: {
|
|
43
|
+
color: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** Resolved style object shape returned by {@link useToolCallViewTheme}. */
|
|
47
|
+
export type ToolCallViewTheme = ThemeOf<typeof useToolCallViewTheme>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ToolCallViewTheme } from "./ToolCallView.theme";
|
|
2
|
+
/**
|
|
3
|
+
* Visual state of a tool call.
|
|
4
|
+
*
|
|
5
|
+
* - `running` — call sent, no paired result yet (implicit on the
|
|
6
|
+
* wire; the result segment simply hasn't arrived).
|
|
7
|
+
* - `completed` — paired tool-result with `status: "completed"`.
|
|
8
|
+
* - `error` — paired tool-result with `status: "error"` (mapped
|
|
9
|
+
* from the AI SDK `tool-error` part by `mapStreamPart`).
|
|
10
|
+
*/
|
|
11
|
+
export type ToolCallViewStatus = "running" | "completed" | "error";
|
|
12
|
+
/**
|
|
13
|
+
* Map a wire-level tool-call/tool-result pairing to the renderer's
|
|
14
|
+
* status. When `result` is absent the call is still in flight; when
|
|
15
|
+
* present its `status` field decides between `completed` and `error`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function deriveToolCallViewStatus(result: {
|
|
18
|
+
readonly status: "completed" | "error";
|
|
19
|
+
} | undefined): ToolCallViewStatus;
|
|
20
|
+
export interface ToolCallViewProps {
|
|
21
|
+
/** Bare name of the tool that was invoked (e.g. `"read_file"`). */
|
|
22
|
+
readonly toolName: string;
|
|
23
|
+
/**
|
|
24
|
+
* Stringified tool-call arguments. Multi-line / long blobs are
|
|
25
|
+
* collapsed and clipped to a single visual row by the renderer; pass
|
|
26
|
+
* the raw value here.
|
|
27
|
+
*/
|
|
28
|
+
readonly args: string;
|
|
29
|
+
/** Current visual state. */
|
|
30
|
+
readonly status: ToolCallViewStatus;
|
|
31
|
+
/**
|
|
32
|
+
* Stringified tool-result output. Only used for `status === "completed"`
|
|
33
|
+
* to derive the trailing `→ N lines` summary. Ignored for `running`
|
|
34
|
+
* and `error`.
|
|
35
|
+
*/
|
|
36
|
+
readonly output?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Error message, populated when the tool errored. Replaces the
|
|
39
|
+
* trailing summary with `→ <error>` for `status === "error"`.
|
|
40
|
+
*/
|
|
41
|
+
readonly error?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ToolCallViewRenderProps {
|
|
44
|
+
/** Resolved theme styles. */
|
|
45
|
+
readonly theme: ToolCallViewTheme;
|
|
46
|
+
/** Glyph rendered at the head of the row. */
|
|
47
|
+
readonly leadingGlyph: string;
|
|
48
|
+
/** Bare name of the tool. */
|
|
49
|
+
readonly toolName: string;
|
|
50
|
+
/** Pre-truncated, single-line args preview (may be empty). */
|
|
51
|
+
readonly argsPreview: string;
|
|
52
|
+
/**
|
|
53
|
+
* Pre-formatted result summary (e.g. `"\u2192 12 lines"` or
|
|
54
|
+
* `"\u2192 ENOENT: no such file"`). Empty string when there is no
|
|
55
|
+
* result yet.
|
|
56
|
+
*/
|
|
57
|
+
readonly resultSummary: string;
|
|
58
|
+
/** Visual status — drives glyph color. */
|
|
59
|
+
readonly status: ToolCallViewStatus;
|
|
60
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ToolCallViewStatus } from "./ToolCallView.types";
|
|
2
|
+
/**
|
|
3
|
+
* Collapse a possibly-multiline args blob into a single visual row and
|
|
4
|
+
* clip it to {@link TOOL_CALL_ARGS_PREVIEW_LENGTH} characters.
|
|
5
|
+
*
|
|
6
|
+
* - CR / CRLF / LF are normalized then collapsed (along with tabs and
|
|
7
|
+
* runs of spaces) into single spaces, so JSON pretty-printed across
|
|
8
|
+
* many lines still renders as one row.
|
|
9
|
+
* - Empty / all-whitespace input returns an empty string so the
|
|
10
|
+
* renderer can omit the args span entirely (no leading separator).
|
|
11
|
+
* - Truncation appends a single typographic ellipsis (`\u2026`); the
|
|
12
|
+
* ellipsis is *not* counted toward the cap so the output is at most
|
|
13
|
+
* `cap + 1` characters.
|
|
14
|
+
*
|
|
15
|
+
* Exported so the row-height estimator can compute heights against the
|
|
16
|
+
* exact same string the renderer will draw.
|
|
17
|
+
*/
|
|
18
|
+
export declare function formatArgsPreview(rawArgs: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Build the trailing summary fragment for a paired tool-result.
|
|
21
|
+
*
|
|
22
|
+
* - `running` → empty string (no result yet).
|
|
23
|
+
* - `completed` → `\u2192 N lines` where `N` is the line count of the
|
|
24
|
+
* raw output (1 for a single line, 0 for an empty string). Using
|
|
25
|
+
* line count rather than byte count surfaces the "shape" of the
|
|
26
|
+
* result without leaking content.
|
|
27
|
+
* - `error` → `\u2192 <message>` clipped to
|
|
28
|
+
* {@link TOOL_CALL_ERROR_PREVIEW_LENGTH} characters; the leading
|
|
29
|
+
* newline is stripped so the message stays on the same row.
|
|
30
|
+
*
|
|
31
|
+
* Exported so the row estimator can mirror the rendered row exactly.
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatResultSummary(status: ToolCallViewStatus, output: string | undefined, error: string | undefined): string;
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the leading status glyph for a given tool-call status. The
|
|
36
|
+
* `running` case is supplied by the caller because it animates via
|
|
37
|
+
* {@link useToolSpinner}; the static glyphs live here so the row
|
|
38
|
+
* estimator can use them without subscribing to the spinner.
|
|
39
|
+
*/
|
|
40
|
+
export declare function staticGlyphForStatus(status: Exclude<ToolCallViewStatus, "running">): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { ToolCallViewProps, ToolCallViewRenderProps, } from "./ToolCallView";
|
|
2
|
+
export { ToolCallView, ToolCallViewRender } from "./ToolCallView";
|
|
3
|
+
export { TOOL_CALL_ARGS_PREVIEW_LENGTH, TOOL_CALL_ELLIPSIS, TOOL_CALL_ERROR_PREVIEW_LENGTH, TOOL_CALL_GLYPH_COMPLETED, TOOL_CALL_GLYPH_ERROR, } from "./ToolCallView.constants";
|
|
4
|
+
export type { ToolCallViewTheme } from "./ToolCallView.theme";
|
|
5
|
+
export { useToolCallViewTheme } from "./ToolCallView.theme";
|
|
6
|
+
export type { ToolCallViewStatus } from "./ToolCallView.types";
|
|
7
|
+
export { deriveToolCallViewStatus } from "./ToolCallView.types";
|
|
8
|
+
export { formatArgsPreview, formatResultSummary, staticGlyphForStatus, } from "./ToolCallView.utils";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { useMessageListTheme } from "../MessageList.theme";
|
|
3
|
+
export interface UserMessageProps {
|
|
4
|
+
/** The user-typed body of the message. */
|
|
5
|
+
readonly text: string;
|
|
6
|
+
/** Display label for the user (defaults to "you"). */
|
|
7
|
+
readonly label?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Renders a single user-authored message inside a bordered panel.
|
|
11
|
+
*
|
|
12
|
+
* The panel's top border embeds the user label so the sender is visible
|
|
13
|
+
* without consuming an extra row, and the prompt body is rendered inside
|
|
14
|
+
* the panel's body box.
|
|
15
|
+
*/
|
|
16
|
+
export declare function UserMessage({ text, label, }: UserMessageProps): React.ReactElement;
|
|
17
|
+
export interface UserMessageRenderProps {
|
|
18
|
+
/** Resolved MessageList theme styles. */
|
|
19
|
+
readonly theme: ReturnType<typeof useMessageListTheme>;
|
|
20
|
+
/** The user-typed body of the message. */
|
|
21
|
+
readonly text: string;
|
|
22
|
+
/** Display label for the user. */
|
|
23
|
+
readonly label: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function UserMessageRender({ theme, text, label, }: UserMessageRenderProps): React.ReactElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type { AgentMessageProps, AgentMessageRenderProps, } from "./AgentMessage";
|
|
2
|
+
export { AgentMessage, AgentMessageRender } from "./AgentMessage";
|
|
3
|
+
export type { ContextUsageModalPayload, ContextUsageModalRenderProps, } from "./ContextUsageModal";
|
|
4
|
+
export { CONTEXT_USAGE_MODAL_ID, ContextUsageModal, ContextUsageModalRender, } from "./ContextUsageModal";
|
|
5
|
+
export { findSubStrategyName, groupSubStrategyMessages, MessageList, MessageListRender, selectSubStrategyMessages, } from "./MessageList";
|
|
6
|
+
export type { GroupedChatMessage, MessageListProps, MessageListRenderProps, } from "./MessageList.types";
|
|
7
|
+
export type { OutputModalKind, OutputModalPayload, OutputModalRenderProps, } from "./OutputModal";
|
|
8
|
+
export { OUTPUT_MODAL_ID, OutputModal, OutputModalRender, } from "./OutputModal";
|
|
9
|
+
export type { SpawnedStrategyViewProps, SpawnedStrategyViewRenderProps, } from "./SpawnedStrategyView";
|
|
10
|
+
export { SpawnedStrategyView, SpawnedStrategyViewRender, } from "./SpawnedStrategyView";
|
|
11
|
+
export type { SystemMessageProps, SystemMessageRenderProps, } from "./SystemMessage";
|
|
12
|
+
export { SystemMessage, SystemMessageRender } from "./SystemMessage";
|
|
13
|
+
export type { UserMessageProps, UserMessageRenderProps } from "./UserMessage";
|
|
14
|
+
export { UserMessage, UserMessageRender } from "./UserMessage";
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/** Size as absolute columns/rows (number) or a percentage of the terminal. */
|
|
3
|
+
export type ModalSize = number | `${number}%`;
|
|
4
|
+
export interface ModalProps {
|
|
5
|
+
/** Unique identifier that ties this modal to `useModal(id)` controls. */
|
|
6
|
+
readonly modalId: string;
|
|
7
|
+
/** Optional title displayed at the top of the modal. */
|
|
8
|
+
readonly title?: string;
|
|
9
|
+
/** Content rendered inside the modal body. */
|
|
10
|
+
readonly children: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Close the modal when Esc is pressed. Only triggers when this modal is
|
|
13
|
+
* topmost. @default true
|
|
14
|
+
*/
|
|
15
|
+
readonly closeOnEsc?: boolean;
|
|
16
|
+
/** Override the theme's default minHeight on the content box. */
|
|
17
|
+
readonly minHeight?: ModalSize;
|
|
18
|
+
/** Override the theme's default maxHeight on the content box. */
|
|
19
|
+
readonly maxHeight?: ModalSize;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Full-screen overlay modal for the TUI.
|
|
23
|
+
*
|
|
24
|
+
* Renders the modal content box when open. The backdrop dimming and overlay
|
|
25
|
+
* centering are handled externally by {@link AlphaDim} — `Modal` is
|
|
26
|
+
* responsible only for its content box and Esc-to-close behaviour.
|
|
27
|
+
*
|
|
28
|
+
* Visibility is controlled via `useModal(modalId)`. When `closeOnEsc` is
|
|
29
|
+
* true (the default), the modal listens for Esc — but only when it is the
|
|
30
|
+
* topmost open modal, so nested modals don't all dismiss on one keystroke.
|
|
31
|
+
*
|
|
32
|
+
* @param props - Modal configuration and children.
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* const confirm = useModal("confirm");
|
|
36
|
+
*
|
|
37
|
+
* <AlphaDim
|
|
38
|
+
* isActive={confirm.isOpen}
|
|
39
|
+
* background={<AppContent />}
|
|
40
|
+
* overlay={
|
|
41
|
+
* <Modal modalId="confirm" title="Are you sure?" width="60%">
|
|
42
|
+
* <Text>This action cannot be undone.</Text>
|
|
43
|
+
* </Modal>
|
|
44
|
+
* }
|
|
45
|
+
* />
|
|
46
|
+
*
|
|
47
|
+
* // open from anywhere:
|
|
48
|
+
* confirm.open();
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function Modal({ modalId, title, children, closeOnEsc, minHeight, maxHeight, }: ModalProps): React.ReactElement | null;
|
|
52
|
+
export interface ModalRenderProps {
|
|
53
|
+
/** Optional title displayed at the top of the modal. */
|
|
54
|
+
readonly title?: string;
|
|
55
|
+
/** Content rendered inside the modal body. */
|
|
56
|
+
readonly children: React.ReactNode;
|
|
57
|
+
/** Debug render ref to attach to the root Box. */
|
|
58
|
+
readonly debugRef?: React.Ref<import("ink").DOMElement>;
|
|
59
|
+
/** Override the theme's default minHeight on the content box. */
|
|
60
|
+
readonly minHeight?: ModalSize;
|
|
61
|
+
/** Override the theme's default maxHeight on the content box. */
|
|
62
|
+
readonly maxHeight?: ModalSize;
|
|
63
|
+
}
|
|
64
|
+
export declare function ModalRender({ title, children, minHeight, maxHeight, }: ModalRenderProps): React.ReactElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type BoxProps, type ThemeOf } from "../../Theme";
|
|
2
|
+
/**
|
|
3
|
+
* Returns themed style objects for the Modal component.
|
|
4
|
+
* Consumes global tokens via `useTheme()`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useModalTheme: () => {
|
|
7
|
+
overlay: {
|
|
8
|
+
position: "absolute";
|
|
9
|
+
width: string;
|
|
10
|
+
height: string;
|
|
11
|
+
justifyContent: "center";
|
|
12
|
+
alignItems: "center";
|
|
13
|
+
};
|
|
14
|
+
content: {
|
|
15
|
+
flexDirection: "column";
|
|
16
|
+
borderStyle: BoxProps["borderStyle"];
|
|
17
|
+
borderColor: string;
|
|
18
|
+
paddingX: number;
|
|
19
|
+
paddingY: number;
|
|
20
|
+
backgroundColor: string;
|
|
21
|
+
maxHeight: string;
|
|
22
|
+
maxWidth: string;
|
|
23
|
+
};
|
|
24
|
+
title: {
|
|
25
|
+
bold: boolean;
|
|
26
|
+
color: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type ModalTheme = ThemeOf<typeof useModalTheme>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MouseEvent } from "../../hooks/useMouse/useMouse.types";
|
|
2
|
+
/**
|
|
3
|
+
* Function signature for a mouse-event listener registered with
|
|
4
|
+
* {@link MouseContextValue.subscribe}.
|
|
5
|
+
*/
|
|
6
|
+
export type MouseListener = (event: MouseEvent) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Value provided by {@link MouseProvider} via React context.
|
|
9
|
+
*
|
|
10
|
+
* Consumers should not use this directly — prefer the purpose-built hooks
|
|
11
|
+
* {@link useMouseHover} and {@link useMouseClick}.
|
|
12
|
+
*/
|
|
13
|
+
export interface MouseContextValue {
|
|
14
|
+
/**
|
|
15
|
+
* Subscribe to all parsed mouse events. The returned function unsubscribes
|
|
16
|
+
* the listener; call it in a `useEffect` cleanup.
|
|
17
|
+
*
|
|
18
|
+
* @param listener - Called once for every {@link MouseEvent} received.
|
|
19
|
+
* @returns Unsubscribe function.
|
|
20
|
+
*/
|
|
21
|
+
subscribe: (listener: MouseListener) => () => void;
|
|
22
|
+
/**
|
|
23
|
+
* Register a hover consumer. The provider ref-counts these registrations
|
|
24
|
+
* and enables SGR any-event tracking (`?1003h`) while the count is > 0,
|
|
25
|
+
* then disables it again when the count drops back to zero.
|
|
26
|
+
*
|
|
27
|
+
* @returns Unregister function — call it in a `useEffect` cleanup.
|
|
28
|
+
*/
|
|
29
|
+
registerHoverConsumer: () => () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* React context for the global mouse event bus.
|
|
33
|
+
* `null` when no {@link MouseProvider} is mounted — consumer hooks
|
|
34
|
+
* should gracefully degrade (e.g. return a disabled state).
|
|
35
|
+
*/
|
|
36
|
+
export declare const MouseContext: import("react").Context<MouseContextValue | null>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
export interface MouseProviderProps {
|
|
3
|
+
/** Content that will have access to mouse events via context. */
|
|
4
|
+
readonly children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Provides a global mouse-event bus to the subtree.
|
|
8
|
+
*
|
|
9
|
+
* Mount this component once, high in the tree (e.g. inside `Frame`).
|
|
10
|
+
* It:
|
|
11
|
+
* - Subscribes a single `useInput` listener that parses all SGR mouse
|
|
12
|
+
* chunks and fans them out to registered listeners.
|
|
13
|
+
* - Ref-counts hover consumers: the first call to `registerHoverConsumer`
|
|
14
|
+
* writes `\x1b[?1003h` (any-event motion tracking); the last cleanup
|
|
15
|
+
* writes `\x1b[?1003l` to restore the previous mode.
|
|
16
|
+
*
|
|
17
|
+
* Consumer hooks ({@link useMouseHover}, {@link useMouseClick}) use the
|
|
18
|
+
* context provided here rather than subscribing to `useInput` individually.
|
|
19
|
+
*/
|
|
20
|
+
export declare function MouseProvider({ children, }: MouseProviderProps): React.ReactElement;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RequestPermissionMessage } from "@comma-agents/daemon";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
/** Decision option presented to the user. */
|
|
4
|
+
export type PermissionDecision = "allow" | "deny" | "allow-session" | "deny-session";
|
|
5
|
+
export interface PermissionPromptProps {
|
|
6
|
+
/** The daemon's `request_permission` message to display. */
|
|
7
|
+
readonly request: RequestPermissionMessage;
|
|
8
|
+
/** Called when the user makes a decision. */
|
|
9
|
+
readonly onDecide: (decision: PermissionDecision) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface PermissionPromptRenderProps {
|
|
12
|
+
readonly actor: string;
|
|
13
|
+
readonly verb: string;
|
|
14
|
+
readonly resource: string;
|
|
15
|
+
readonly onDecide: (decision: PermissionDecision) => void;
|
|
16
|
+
readonly colors: {
|
|
17
|
+
readonly warning: string;
|
|
18
|
+
readonly secondary: string;
|
|
19
|
+
readonly primary: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Renders a permission-request prompt with a row of tabbable action buttons.
|
|
24
|
+
*
|
|
25
|
+
* Focus starts on "Allow once" when the prompt mounts. Tab / Shift+Tab cycle
|
|
26
|
+
* through all four options; Enter (or a mouse click) confirms the focused
|
|
27
|
+
* choice.
|
|
28
|
+
*
|
|
29
|
+
* The background is provided by the Frame's global flood-fill (driven by
|
|
30
|
+
* `tokens.colors.background`), so no per-component fill is needed here.
|
|
31
|
+
*/
|
|
32
|
+
export declare function PermissionPrompt({ request, onDecide, }: PermissionPromptProps): React.ReactElement;
|
|
33
|
+
export declare function PermissionPromptRender({ actor, verb, resource, onDecide, colors, }: PermissionPromptRenderProps): React.ReactElement;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { QuestionPromptProps, QuestionPromptRenderProps } from "./QuestionPrompt.types";
|
|
3
|
+
export declare function QuestionPrompt({ request, onSubmit, }: QuestionPromptProps): React.ReactElement;
|
|
4
|
+
export declare function QuestionPromptRender({ actor, question, onSubmit, inputValue, onInputValueChange, colors, }: QuestionPromptRenderProps): React.ReactElement;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RequestQuestionMessage } from "@comma-agents/daemon";
|
|
2
|
+
export interface QuestionPromptProps {
|
|
3
|
+
/** The daemon's `request_question` message to display. */
|
|
4
|
+
readonly request: RequestQuestionMessage;
|
|
5
|
+
/** Called when the user submits their answer. */
|
|
6
|
+
readonly onSubmit: (response: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface QuestionPromptRenderProps {
|
|
9
|
+
readonly actor: string;
|
|
10
|
+
readonly question: string;
|
|
11
|
+
readonly onSubmit: (response: string) => void;
|
|
12
|
+
readonly inputValue: string;
|
|
13
|
+
readonly onInputValueChange: (val: string) => void;
|
|
14
|
+
readonly colors: {
|
|
15
|
+
readonly primary: string;
|
|
16
|
+
readonly secondary: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { ScrollableListProps, ScrollableListRenderProps } from "./ScrollableList.types";
|
|
3
|
+
/**
|
|
4
|
+
* Generic single-selection list with arrow-key navigation and a row-aware
|
|
5
|
+
* vertical scrollbar. Built as a thin selection layer over
|
|
6
|
+
* {@link ScrollableView} — measurement, mouse-wheel handling, and the
|
|
7
|
+
* absolute-positioned viewport all live there. This component adds:
|
|
8
|
+
*
|
|
9
|
+
* - Up/Down arrow keys to move the selection (clamped at the edges).
|
|
10
|
+
* - Enter to invoke the optional `onSelected` callback.
|
|
11
|
+
* - `scrollToRow` plumbed to the view so the selected row is always visible.
|
|
12
|
+
*
|
|
13
|
+
* Mouse-wheel ticks scroll the underlying view independently of the
|
|
14
|
+
* selection — familiar GUI behavior.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const [selected, setSelected] = useState(0);
|
|
19
|
+
* <ScrollableList
|
|
20
|
+
* id="my-list"
|
|
21
|
+
* items={commands}
|
|
22
|
+
* getKey={(c) => c.id}
|
|
23
|
+
* selectedIndex={selected}
|
|
24
|
+
* onSelectedIndexChange={setSelected}
|
|
25
|
+
* onSelected={(c) => run(c)}
|
|
26
|
+
* renderItem={(c, isSelected) => (
|
|
27
|
+
* <Text inverse={isSelected}>{c.label}</Text>
|
|
28
|
+
* )}
|
|
29
|
+
* />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function ScrollableList<ItemType>(props: ScrollableListProps<ItemType>): React.ReactElement;
|
|
33
|
+
export declare function ScrollableListRender<ItemType>({ items, getKey, renderItem, clampedSelected, emptyText, }: ScrollableListRenderProps<ItemType>): React.ReactElement;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ThemeOf } from "../../Theme";
|
|
2
|
+
/**
|
|
3
|
+
* Memoized themed style objects for {@link ScrollableList}.
|
|
4
|
+
*
|
|
5
|
+
* The theme intentionally exposes only structural/empty-state styles —
|
|
6
|
+
* row visual treatment is the caller's responsibility (delivered via the
|
|
7
|
+
* `isSelected` flag passed to `renderItem`).
|
|
8
|
+
*/
|
|
9
|
+
export declare const useScrollableListTheme: () => {
|
|
10
|
+
/**
|
|
11
|
+
* Root viewport. `overflow: "hidden"` clips the absolutely-positioned
|
|
12
|
+
* inner content to the measured height, while `flexGrow: 1` lets the
|
|
13
|
+
* viewport claim whatever vertical space the parent layout offers.
|
|
14
|
+
*/
|
|
15
|
+
viewport: {
|
|
16
|
+
flexDirection: "column";
|
|
17
|
+
width: string;
|
|
18
|
+
flexGrow: number;
|
|
19
|
+
overflow: "hidden";
|
|
20
|
+
};
|
|
21
|
+
/** Empty-state container. */
|
|
22
|
+
empty: {
|
|
23
|
+
flexDirection: "column";
|
|
24
|
+
width: string;
|
|
25
|
+
};
|
|
26
|
+
/** Empty-state text style. */
|
|
27
|
+
emptyText: {
|
|
28
|
+
color: string;
|
|
29
|
+
dimColor: boolean;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/** Resolved style shape returned by {@link useScrollableListTheme}. */
|
|
33
|
+
export type ScrollableListTheme = ThemeOf<typeof useScrollableListTheme>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Props for {@link ScrollableList}.
|
|
4
|
+
*
|
|
5
|
+
* `ScrollableList` is a focused, single-selection list with arrow-key
|
|
6
|
+
* navigation, mouse-wheel scrolling, and a row-aware vertical scrollbar.
|
|
7
|
+
* Row heights are measured automatically by the underlying
|
|
8
|
+
* {@link ScrollableView} via Ink's headless layout — multi-line rows
|
|
9
|
+
* (text that wraps on narrow terminals) need no special handling from
|
|
10
|
+
* the caller.
|
|
11
|
+
*/
|
|
12
|
+
export interface ScrollableListProps<ItemType> {
|
|
13
|
+
/** The full list of items to render. */
|
|
14
|
+
readonly items: readonly ItemType[];
|
|
15
|
+
/** Stable key for each item. */
|
|
16
|
+
readonly getKey: (item: ItemType, index: number) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Renders a single row. Receives the item and a flag indicating whether
|
|
19
|
+
* this row is currently selected — the caller is responsible for any
|
|
20
|
+
* visual selection treatment (typically `inverse` text).
|
|
21
|
+
*/
|
|
22
|
+
readonly renderItem: (item: ItemType, isSelected: boolean) => React.ReactNode;
|
|
23
|
+
/** Currently selected index (controlled). Clamped to `[0, items.length-1]`. */
|
|
24
|
+
readonly selectedIndex: number;
|
|
25
|
+
/** Invoked when Up/Down moves the selection. */
|
|
26
|
+
readonly onSelectedIndexChange: (next: number) => void;
|
|
27
|
+
/** Invoked when Enter is pressed on the selected item. */
|
|
28
|
+
readonly onSelected?: (item: ItemType, index: number) => void;
|
|
29
|
+
/** Text shown when `items` is empty. Defaults to "No items." */
|
|
30
|
+
readonly emptyText?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Stable focus ID. When omitted the list still participates in tab order
|
|
33
|
+
* but cannot be focused programmatically by name.
|
|
34
|
+
*/
|
|
35
|
+
readonly id?: string;
|
|
36
|
+
/**
|
|
37
|
+
* External focus override. When provided, the list does NOT register its
|
|
38
|
+
* own focus zone via `useFocus` — the parent owns the focus state and
|
|
39
|
+
* passes `true` to enable arrow-key + mouse-wheel input. This lets a
|
|
40
|
+
* larger surrounding region (e.g. a sidebar) act as a single focus zone
|
|
41
|
+
* containing the list, instead of forcing the user to tab into the list
|
|
42
|
+
* separately.
|
|
43
|
+
*/
|
|
44
|
+
readonly isFocused?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Props for {@link ScrollableListRender}.
|
|
48
|
+
*
|
|
49
|
+
* Pure render props — all hook-derived values are computed by the
|
|
50
|
+
* container and passed down.
|
|
51
|
+
*/
|
|
52
|
+
export interface ScrollableListRenderProps<ItemType> {
|
|
53
|
+
/** The full list of items to render. */
|
|
54
|
+
readonly items: readonly ItemType[];
|
|
55
|
+
/** Stable key for each item. */
|
|
56
|
+
readonly getKey: (item: ItemType, index: number) => string;
|
|
57
|
+
/**
|
|
58
|
+
* Renders a single row. Receives the item and a flag indicating whether
|
|
59
|
+
* this row is currently selected.
|
|
60
|
+
*/
|
|
61
|
+
readonly renderItem: (item: ItemType, isSelected: boolean) => React.ReactNode;
|
|
62
|
+
/** Clamped selected index. */
|
|
63
|
+
readonly clampedSelected: number;
|
|
64
|
+
/** Text shown when `items` is empty. */
|
|
65
|
+
readonly emptyText?: string;
|
|
66
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ScrollableList, ScrollableListRender } from "./ScrollableList";
|
|
2
|
+
export type { ScrollableListTheme } from "./ScrollableList.theme";
|
|
3
|
+
export { useScrollableListTheme } from "./ScrollableList.theme";
|
|
4
|
+
export type { ScrollableListProps, ScrollableListRenderProps, } from "./ScrollableList.types";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import type { ScrollableViewProps, ScrollableViewRenderProps } from "./ScrollableView.types";
|
|
3
|
+
/**
|
|
4
|
+
* Variable-height, virtualized scrollable container.
|
|
5
|
+
*
|
|
6
|
+
* Lays out a list of items inside a measured viewport and clips with
|
|
7
|
+
* `overflow: hidden`. Row heights are measured automatically via Ink's
|
|
8
|
+
* headless `measureLayout` — no callback required from the caller — and
|
|
9
|
+
* cached by `(getKey(item), viewportWidth)`. Only items inside the
|
|
10
|
+
* visible window plus a small overscan are mounted in the live render
|
|
11
|
+
* tree, so a list of thousands of rows still renders cheap.
|
|
12
|
+
*
|
|
13
|
+
* Measurement runs in a `useLayoutEffect` immediately after commit, so
|
|
14
|
+
* the rendered frame the user sees always reflects the post-measurement
|
|
15
|
+
* geometry. The cache survives across renders via `useRef`; when an item
|
|
16
|
+
* reference changes, the previous height is reused until the replacement
|
|
17
|
+
* object is re-measured, keeping streaming chat updates from briefly
|
|
18
|
+
* collapsing the scroll geometry.
|
|
19
|
+
*
|
|
20
|
+
* The view does **not** handle keyboard input. Use {@link ScrollableList}
|
|
21
|
+
* for keyboard-driven single-selection lists.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* <ScrollableView
|
|
26
|
+
* items={messages}
|
|
27
|
+
* getKey={(message) => message.id}
|
|
28
|
+
* renderItem={(message) => <MessageRow message={message} />}
|
|
29
|
+
* stickToBottom
|
|
30
|
+
* />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function ScrollableView<ItemType>(props: ScrollableViewProps<ItemType>): React.ReactElement;
|
|
34
|
+
export declare function ScrollableViewRender<ItemType>({ items, getKey, renderItem, totalCount, viewportHeight, totalRows, rowOffset, topClipRows, renderStart, renderEnd, showScrollbar, emptyText, theme, viewportRef, }: ScrollableViewRenderProps<ItemType>): React.ReactElement;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ThemeOf } from "../../Theme";
|
|
2
|
+
/** Memoized themed style objects for {@link ScrollableView}. */
|
|
3
|
+
export declare const useScrollableViewTheme: () => {
|
|
4
|
+
/**
|
|
5
|
+
* Outer row container — holds the viewport column and the scrollbar
|
|
6
|
+
* column side-by-side.
|
|
7
|
+
*/
|
|
8
|
+
outer: {
|
|
9
|
+
flexDirection: "row";
|
|
10
|
+
width: string;
|
|
11
|
+
flexGrow: number;
|
|
12
|
+
overflow: "hidden";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Viewport column. `overflow: "hidden"` clips the absolutely-positioned
|
|
16
|
+
* inner content; `flexGrow: 1` claims the available width.
|
|
17
|
+
*/
|
|
18
|
+
viewport: {
|
|
19
|
+
flexDirection: "column";
|
|
20
|
+
flexGrow: number;
|
|
21
|
+
overflow: "hidden";
|
|
22
|
+
};
|
|
23
|
+
/** Empty-state container. */
|
|
24
|
+
empty: {
|
|
25
|
+
flexDirection: "column";
|
|
26
|
+
width: string;
|
|
27
|
+
};
|
|
28
|
+
/** Empty-state text. */
|
|
29
|
+
emptyText: {
|
|
30
|
+
color: string;
|
|
31
|
+
dimColor: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export type ScrollableViewTheme = ThemeOf<typeof useScrollableViewTheme>;
|