@golba98/codexa 1.0.1
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/README.md +320 -0
- package/bin/codexa.js +445 -0
- package/package.json +45 -0
- package/scripts/audit-codexa-capabilities.mjs +466 -0
- package/scripts/smoke-terminal-bench.mjs +35 -0
- package/src/app.tsx +4561 -0
- package/src/appRenderStability.test.ts +131 -0
- package/src/commands/handler.test.ts +643 -0
- package/src/commands/handler.ts +875 -0
- package/src/config/launchArgs.test.ts +158 -0
- package/src/config/launchArgs.ts +186 -0
- package/src/config/layeredConfig.test.ts +143 -0
- package/src/config/layeredConfig.ts +836 -0
- package/src/config/persistence.test.ts +110 -0
- package/src/config/persistence.ts +311 -0
- package/src/config/runtimeConfig.test.ts +218 -0
- package/src/config/runtimeConfig.ts +554 -0
- package/src/config/settings.test.ts +155 -0
- package/src/config/settings.ts +401 -0
- package/src/config/toml-serialize.ts +98 -0
- package/src/config/trustStore.test.ts +29 -0
- package/src/config/trustStore.ts +68 -0
- package/src/core/attachments.test.ts +155 -0
- package/src/core/attachments.ts +71 -0
- package/src/core/auth/codexAuth.test.ts +68 -0
- package/src/core/auth/codexAuth.ts +359 -0
- package/src/core/cleanupFastFail.test.ts +76 -0
- package/src/core/cleanupFastFail.ts +67 -0
- package/src/core/clipboard.ts +24 -0
- package/src/core/codex.ts +124 -0
- package/src/core/codexExecArgs.test.ts +195 -0
- package/src/core/codexExecArgs.ts +152 -0
- package/src/core/codexLaunch.test.ts +205 -0
- package/src/core/codexLaunch.ts +162 -0
- package/src/core/codexPrompt.test.ts +252 -0
- package/src/core/codexPrompt.ts +428 -0
- package/src/core/executables/claudeExecutable.ts +63 -0
- package/src/core/executables/codexExecutable.test.ts +212 -0
- package/src/core/executables/codexExecutable.ts +159 -0
- package/src/core/executables/executableResolver.test.ts +129 -0
- package/src/core/executables/executableResolver.ts +138 -0
- package/src/core/executables/geminiExecutable.test.ts +116 -0
- package/src/core/executables/geminiExecutable.ts +78 -0
- package/src/core/executables/pathSanityScan.test.ts +47 -0
- package/src/core/githubDiagnostics.test.ts +92 -0
- package/src/core/githubDiagnostics.ts +222 -0
- package/src/core/hollowResponseFormat.test.ts +58 -0
- package/src/core/hollowResponseFormat.ts +39 -0
- package/src/core/inputDebug.ts +51 -0
- package/src/core/launchContext.test.ts +157 -0
- package/src/core/launchContext.ts +266 -0
- package/src/core/models/codexCapabilities.test.ts +45 -0
- package/src/core/models/codexCapabilities.ts +95 -0
- package/src/core/models/codexModelCapabilities.test.ts +246 -0
- package/src/core/models/codexModelCapabilities.ts +571 -0
- package/src/core/models/modelSpecs.test.ts +283 -0
- package/src/core/models/modelSpecs.ts +300 -0
- package/src/core/perf/profiler.ts +125 -0
- package/src/core/perf/renderDebug.test.ts +230 -0
- package/src/core/perf/renderDebug.ts +373 -0
- package/src/core/planStorage.test.ts +143 -0
- package/src/core/planStorage.ts +141 -0
- package/src/core/process/CommandRunner.test.ts +105 -0
- package/src/core/process/CommandRunner.ts +269 -0
- package/src/core/process/processValidation.ts +101 -0
- package/src/core/projectInstructions.test.ts +50 -0
- package/src/core/projectInstructions.ts +54 -0
- package/src/core/providerLauncher/launcher.test.ts +238 -0
- package/src/core/providerLauncher/launcher.ts +203 -0
- package/src/core/providerLauncher/registry.test.ts +324 -0
- package/src/core/providerLauncher/registry.ts +253 -0
- package/src/core/providerLauncher/types.ts +84 -0
- package/src/core/providerLauncher/workspaceConfig.test.ts +638 -0
- package/src/core/providerLauncher/workspaceConfig.ts +407 -0
- package/src/core/providerRuntime/anthropic.test.ts +1120 -0
- package/src/core/providerRuntime/anthropic.ts +576 -0
- package/src/core/providerRuntime/capabilityProfile.test.ts +311 -0
- package/src/core/providerRuntime/capabilityProfile.ts +288 -0
- package/src/core/providerRuntime/claudeCodeDiscovery.ts +446 -0
- package/src/core/providerRuntime/contextMetadata.test.ts +468 -0
- package/src/core/providerRuntime/contextMetadata.ts +409 -0
- package/src/core/providerRuntime/gemini.test.ts +437 -0
- package/src/core/providerRuntime/gemini.ts +784 -0
- package/src/core/providerRuntime/lmstudio.test.ts +168 -0
- package/src/core/providerRuntime/lmstudio.ts +118 -0
- package/src/core/providerRuntime/local.test.ts +787 -0
- package/src/core/providerRuntime/local.ts +754 -0
- package/src/core/providerRuntime/models.ts +150 -0
- package/src/core/providerRuntime/reasoning.ts +17 -0
- package/src/core/providerRuntime/registry.test.ts +233 -0
- package/src/core/providerRuntime/registry.ts +203 -0
- package/src/core/providerRuntime/types.ts +103 -0
- package/src/core/providers/codexJsonStream.test.ts +148 -0
- package/src/core/providers/codexJsonStream.ts +305 -0
- package/src/core/providers/codexSubprocess.test.ts +68 -0
- package/src/core/providers/codexSubprocess.ts +372 -0
- package/src/core/providers/codexTranscript.test.ts +284 -0
- package/src/core/providers/codexTranscript.ts +695 -0
- package/src/core/providers/openaiNative.ts +13 -0
- package/src/core/providers/registry.ts +21 -0
- package/src/core/providers/types.ts +59 -0
- package/src/core/terminal/terminalCapabilities.test.ts +93 -0
- package/src/core/terminal/terminalCapabilities.ts +100 -0
- package/src/core/terminal/terminalControl.test.ts +75 -0
- package/src/core/terminal/terminalControl.ts +147 -0
- package/src/core/terminal/terminalSanitize.test.ts +22 -0
- package/src/core/terminal/terminalSanitize.ts +147 -0
- package/src/core/terminal/terminalSelection.test.ts +42 -0
- package/src/core/terminal/terminalSelection.ts +66 -0
- package/src/core/terminal/terminalTitle.test.ts +328 -0
- package/src/core/terminal/terminalTitle.ts +483 -0
- package/src/core/workspaceActivity.test.ts +163 -0
- package/src/core/workspaceActivity.ts +380 -0
- package/src/core/workspaceGuard.test.ts +151 -0
- package/src/core/workspaceGuard.ts +288 -0
- package/src/core/workspaceRoot.test.ts +23 -0
- package/src/core/workspaceRoot.ts +47 -0
- package/src/exec.test.ts +13 -0
- package/src/exec.ts +72 -0
- package/src/headless/execArgs.test.ts +147 -0
- package/src/headless/execArgs.ts +294 -0
- package/src/headless/execRunner.test.ts +434 -0
- package/src/headless/execRunner.ts +304 -0
- package/src/index.test.tsx +618 -0
- package/src/index.tsx +296 -0
- package/src/session/appSession.test.ts +897 -0
- package/src/session/appSession.ts +761 -0
- package/src/session/chatLifecycle.test.ts +64 -0
- package/src/session/chatLifecycle.ts +951 -0
- package/src/session/liveRenderScheduler.test.ts +201 -0
- package/src/session/liveRenderScheduler.ts +214 -0
- package/src/session/planFlow.test.ts +103 -0
- package/src/session/planFlow.ts +149 -0
- package/src/session/planTranscript.test.ts +65 -0
- package/src/session/planTranscript.ts +15 -0
- package/src/session/promptRunSchedule.test.ts +36 -0
- package/src/session/promptRunSchedule.ts +26 -0
- package/src/session/types.ts +228 -0
- package/src/test/runtimeTestUtils.ts +14 -0
- package/src/types/react-dom.d.ts +3 -0
- package/src/ui/ActionRequiredBlock.tsx +38 -0
- package/src/ui/ActivityBars.tsx +68 -0
- package/src/ui/ActivityIndicator.test.tsx +58 -0
- package/src/ui/ActivityIndicator.tsx +58 -0
- package/src/ui/AgentBlock.test.ts +6 -0
- package/src/ui/AgentBlock.tsx +130 -0
- package/src/ui/AnimatedStatusText.test.ts +16 -0
- package/src/ui/AnimatedStatusText.tsx +69 -0
- package/src/ui/AppShell.test.tsx +1739 -0
- package/src/ui/AppShell.tsx +698 -0
- package/src/ui/AttachmentImportPanel.test.tsx +204 -0
- package/src/ui/AttachmentImportPanel.tsx +98 -0
- package/src/ui/AuthPanel.tsx +113 -0
- package/src/ui/BackendPicker.tsx +28 -0
- package/src/ui/BottomComposer.test.ts +674 -0
- package/src/ui/BottomComposer.tsx +1028 -0
- package/src/ui/CodexLogo.tsx +55 -0
- package/src/ui/DashCard.tsx +82 -0
- package/src/ui/Markdown.test.ts +157 -0
- package/src/ui/Markdown.tsx +310 -0
- package/src/ui/ModePicker.tsx +27 -0
- package/src/ui/ModelPicker.tsx +31 -0
- package/src/ui/ModelPickerProviderScope.test.tsx +411 -0
- package/src/ui/ModelPickerScreen.test.tsx +99 -0
- package/src/ui/ModelPickerScreen.tsx +416 -0
- package/src/ui/ModelPickerState.test.tsx +151 -0
- package/src/ui/ModelReasoningPicker.test.tsx +447 -0
- package/src/ui/ModelReasoningPicker.tsx +458 -0
- package/src/ui/Panel.tsx +51 -0
- package/src/ui/PermissionsPanel.tsx +78 -0
- package/src/ui/PlanActionPicker.tsx +119 -0
- package/src/ui/PlanReviewPanel.test.tsx +267 -0
- package/src/ui/PlanReviewPanel.tsx +212 -0
- package/src/ui/PromptCardBorder.test.tsx +161 -0
- package/src/ui/ProviderPicker.test.tsx +289 -0
- package/src/ui/ProviderPicker.tsx +321 -0
- package/src/ui/ProviderShortcut.test.tsx +143 -0
- package/src/ui/ReasoningPicker.tsx +46 -0
- package/src/ui/RunFooter.tsx +65 -0
- package/src/ui/SelectionPanel.tsx +67 -0
- package/src/ui/SettingsPanel.test.tsx +233 -0
- package/src/ui/SettingsPanel.tsx +156 -0
- package/src/ui/Spinner.tsx +25 -0
- package/src/ui/StaticIntroItem.tsx +54 -0
- package/src/ui/StaticTranscriptItem.tsx +56 -0
- package/src/ui/TextEntryPanel.tsx +139 -0
- package/src/ui/ThemePicker.tsx +31 -0
- package/src/ui/ThinkingBlock.tsx +100 -0
- package/src/ui/Timeline.test.ts +2067 -0
- package/src/ui/Timeline.tsx +1472 -0
- package/src/ui/TimelineNavigation.test.tsx +201 -0
- package/src/ui/TopHeader.test.tsx +239 -0
- package/src/ui/TopHeader.tsx +257 -0
- package/src/ui/TurnGroup.test.tsx +365 -0
- package/src/ui/TurnGroup.tsx +657 -0
- package/src/ui/busyStatusAnimation.test.ts +30 -0
- package/src/ui/busyStatusAnimation.ts +11 -0
- package/src/ui/commandNormalize.test.ts +142 -0
- package/src/ui/commandNormalize.ts +66 -0
- package/src/ui/diffRenderer.test.ts +102 -0
- package/src/ui/diffRenderer.ts +116 -0
- package/src/ui/focus.ts +61 -0
- package/src/ui/focusFlow.test.tsx +1098 -0
- package/src/ui/inputBuffer.test.ts +151 -0
- package/src/ui/inputBuffer.ts +203 -0
- package/src/ui/layout.test.ts +145 -0
- package/src/ui/layout.ts +287 -0
- package/src/ui/modeDisplay.test.ts +42 -0
- package/src/ui/modeDisplay.ts +52 -0
- package/src/ui/outputPipeline.ts +64 -0
- package/src/ui/progressEntries.ts +156 -0
- package/src/ui/runActivityView.test.ts +89 -0
- package/src/ui/runActivityView.ts +37 -0
- package/src/ui/runLifecycleView.test.tsx +237 -0
- package/src/ui/slashCommands.ts +41 -0
- package/src/ui/statusRenderIsolation.test.tsx +654 -0
- package/src/ui/terminalAnswerFormat.test.ts +19 -0
- package/src/ui/terminalAnswerFormat.ts +128 -0
- package/src/ui/textLayout.test.ts +18 -0
- package/src/ui/textLayout.ts +338 -0
- package/src/ui/theme.tsx +395 -0
- package/src/ui/themeFlow.test.ts +53 -0
- package/src/ui/themeFlow.ts +41 -0
- package/src/ui/timelineMeasure.ts +3088 -0
- package/src/ui/timelineMeasureCache.test.ts +986 -0
- package/src/ui/useThrottledValue.ts +31 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { startTransition, useEffect, useState } from "react";
|
|
2
|
+
import { Text } from "ink";
|
|
3
|
+
import { useTheme } from "./theme.js";
|
|
4
|
+
|
|
5
|
+
const frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
6
|
+
|
|
7
|
+
export function Spinner({ color }: { color?: string }) {
|
|
8
|
+
const theme = useTheme();
|
|
9
|
+
const [frame, setFrame] = useState(0);
|
|
10
|
+
const activeColor = color ?? theme.DIM;
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const timer = setInterval(() => {
|
|
14
|
+
// startTransition marks this as low-priority so React can coalesce or
|
|
15
|
+
// defer it when a higher-priority streaming render is already pending.
|
|
16
|
+
startTransition(() => {
|
|
17
|
+
setFrame((f) => (f + 1) % frames.length);
|
|
18
|
+
});
|
|
19
|
+
}, 80);
|
|
20
|
+
|
|
21
|
+
return () => clearInterval(timer);
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
return <Text color={activeColor}>{frames[frame]}</Text>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box } from "ink";
|
|
3
|
+
import type { CodexAuthState } from "../core/auth/codexAuth.js";
|
|
4
|
+
import { getShellWidth, type Layout, type StartupHeaderMode } from "./layout.js";
|
|
5
|
+
import { buildIntroRenderItem, TimelineRowView } from "./Timeline.js";
|
|
6
|
+
import type { TimelineRow } from "./timelineMeasure.js";
|
|
7
|
+
import { buildTimelineSnapshot } from "./timelineMeasure.js";
|
|
8
|
+
|
|
9
|
+
interface StaticIntroItemProps {
|
|
10
|
+
authState: CodexAuthState;
|
|
11
|
+
workspaceLabel: string;
|
|
12
|
+
layout: Layout;
|
|
13
|
+
startupHeaderMode?: StartupHeaderMode;
|
|
14
|
+
verboseMode: boolean;
|
|
15
|
+
workspaceRoot: string | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function buildStaticIntroRows({
|
|
19
|
+
authState,
|
|
20
|
+
workspaceLabel,
|
|
21
|
+
layout,
|
|
22
|
+
startupHeaderMode,
|
|
23
|
+
verboseMode,
|
|
24
|
+
workspaceRoot,
|
|
25
|
+
}: StaticIntroItemProps): TimelineRow[] {
|
|
26
|
+
const introItem = buildIntroRenderItem({ authState, workspaceLabel, layout, startupHeaderMode });
|
|
27
|
+
return buildTimelineSnapshot([introItem], {
|
|
28
|
+
totalWidth: getShellWidth(layout.cols),
|
|
29
|
+
verboseMode,
|
|
30
|
+
debugLabel: "static-intro",
|
|
31
|
+
workspaceRoot,
|
|
32
|
+
}).rows;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function StaticIntroItem(props: StaticIntroItemProps) {
|
|
36
|
+
const rows = React.useMemo(() => buildStaticIntroRows(props), [
|
|
37
|
+
props.authState,
|
|
38
|
+
props.workspaceLabel,
|
|
39
|
+
props.layout.cols,
|
|
40
|
+
props.layout.rows,
|
|
41
|
+
props.layout.mode,
|
|
42
|
+
props.startupHeaderMode,
|
|
43
|
+
props.verboseMode,
|
|
44
|
+
props.workspaceRoot,
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Box flexDirection="column">
|
|
49
|
+
{rows.map((row) => (
|
|
50
|
+
<TimelineRowView key={row.key} row={row} />
|
|
51
|
+
))}
|
|
52
|
+
</Box>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Box } from "ink";
|
|
2
|
+
import type { Layout } from "./layout.js";
|
|
3
|
+
import type { TimelineItem } from "./Timeline.js";
|
|
4
|
+
import { TimelineRowView } from "./Timeline.js";
|
|
5
|
+
import { MemoizedTurnGroup, resolveTurnRunPhase } from "./TurnGroup.js";
|
|
6
|
+
import { buildStandaloneEventRows } from "./timelineMeasure.js";
|
|
7
|
+
import type { RenderTimelineItem } from "./Timeline.js";
|
|
8
|
+
|
|
9
|
+
interface StaticTranscriptItemProps {
|
|
10
|
+
item: TimelineItem;
|
|
11
|
+
layout: Layout;
|
|
12
|
+
verboseMode: boolean;
|
|
13
|
+
workspaceRoot: string | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function StaticTranscriptItem({
|
|
17
|
+
item,
|
|
18
|
+
layout,
|
|
19
|
+
verboseMode,
|
|
20
|
+
workspaceRoot,
|
|
21
|
+
}: StaticTranscriptItemProps) {
|
|
22
|
+
if (item.type === "turn") {
|
|
23
|
+
if (!item.user) return null;
|
|
24
|
+
return (
|
|
25
|
+
<MemoizedTurnGroup
|
|
26
|
+
cols={layout.cols}
|
|
27
|
+
turnIndex={item.turnIndex}
|
|
28
|
+
user={item.user}
|
|
29
|
+
run={item.run}
|
|
30
|
+
assistant={item.assistant}
|
|
31
|
+
opacity="active"
|
|
32
|
+
question={null}
|
|
33
|
+
runPhase={resolveTurnRunPhase(item.run, item.assistant, { kind: "IDLE" }, item.turnId)}
|
|
34
|
+
streamPreviewRows={0}
|
|
35
|
+
streamMode="assistant-first"
|
|
36
|
+
verboseMode={verboseMode}
|
|
37
|
+
workspaceRoot={workspaceRoot}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const renderItem: Extract<RenderTimelineItem, { type: "event" }> = {
|
|
43
|
+
key: `static-event-${item.event.id}`,
|
|
44
|
+
type: "event",
|
|
45
|
+
padded: false,
|
|
46
|
+
event: item.event,
|
|
47
|
+
};
|
|
48
|
+
const rows = buildStandaloneEventRows(renderItem, layout.cols);
|
|
49
|
+
return (
|
|
50
|
+
<Box flexDirection="column">
|
|
51
|
+
{rows.map((row) => (
|
|
52
|
+
<TimelineRowView key={row.key} row={row} />
|
|
53
|
+
))}
|
|
54
|
+
</Box>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React, { useMemo, useState } from "react";
|
|
2
|
+
import { Box, Text, useFocus, useInput } from "ink";
|
|
3
|
+
import type { FocusTargetId } from "./focus.js";
|
|
4
|
+
import { useTheme } from "./theme.js";
|
|
5
|
+
import { stripMouseEscapes } from "./inputBuffer.js";
|
|
6
|
+
|
|
7
|
+
interface TextEntryPanelProps {
|
|
8
|
+
focusId: FocusTargetId;
|
|
9
|
+
title: string;
|
|
10
|
+
subtitle: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
initialValue?: string;
|
|
13
|
+
inputLabel?: string;
|
|
14
|
+
footerHint?: string;
|
|
15
|
+
onSubmit: (value: string) => void;
|
|
16
|
+
onCancel: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function insertAt(value: string, index: number, text: string): string {
|
|
20
|
+
return value.slice(0, index) + text + value.slice(index);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function TextEntryPanel({
|
|
24
|
+
focusId,
|
|
25
|
+
title,
|
|
26
|
+
subtitle,
|
|
27
|
+
placeholder = "",
|
|
28
|
+
initialValue = "",
|
|
29
|
+
inputLabel = "Input",
|
|
30
|
+
footerHint = "Enter submit Esc cancel Backspace delete",
|
|
31
|
+
onSubmit,
|
|
32
|
+
onCancel,
|
|
33
|
+
}: TextEntryPanelProps) {
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
const { isFocused } = useFocus({ id: focusId, autoFocus: true });
|
|
36
|
+
const [value, setValue] = useState(initialValue);
|
|
37
|
+
const [cursor, setCursor] = useState(initialValue.length);
|
|
38
|
+
|
|
39
|
+
useInput((input, key) => {
|
|
40
|
+
if (key.escape) {
|
|
41
|
+
onCancel();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (key.return) {
|
|
46
|
+
onSubmit(value.trim());
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (key.leftArrow) {
|
|
51
|
+
setCursor((current) => Math.max(0, current - 1));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (key.rightArrow) {
|
|
56
|
+
setCursor((current) => Math.min(value.length, current + 1));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (key.backspace || key.delete) {
|
|
61
|
+
if (cursor === 0) return;
|
|
62
|
+
setValue((current) => current.slice(0, cursor - 1) + current.slice(cursor));
|
|
63
|
+
setCursor((current) => Math.max(0, current - 1));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (!input || key.ctrl || key.meta) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const filtered = stripMouseEscapes(input);
|
|
72
|
+
if (!filtered) return;
|
|
73
|
+
setValue((current) => insertAt(current, cursor, filtered));
|
|
74
|
+
setCursor((current) => current + filtered.length);
|
|
75
|
+
}, { isActive: isFocused });
|
|
76
|
+
|
|
77
|
+
const display = useMemo(() => {
|
|
78
|
+
if (!value) {
|
|
79
|
+
return {
|
|
80
|
+
before: "",
|
|
81
|
+
current: placeholder || " ",
|
|
82
|
+
after: "",
|
|
83
|
+
isPlaceholder: true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const safeCursor = Math.max(0, Math.min(cursor, value.length));
|
|
88
|
+
return {
|
|
89
|
+
before: value.slice(0, safeCursor),
|
|
90
|
+
current: value[safeCursor] ?? " ",
|
|
91
|
+
after: value.slice(safeCursor + (safeCursor < value.length ? 1 : 0)),
|
|
92
|
+
isPlaceholder: false,
|
|
93
|
+
};
|
|
94
|
+
}, [cursor, placeholder, value]);
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<Box flexDirection="column" width="100%" marginTop={1}>
|
|
98
|
+
<Box
|
|
99
|
+
borderStyle="round"
|
|
100
|
+
borderColor={theme.BORDER_SUBTLE}
|
|
101
|
+
paddingX={2}
|
|
102
|
+
paddingY={1}
|
|
103
|
+
width="100%"
|
|
104
|
+
>
|
|
105
|
+
<Text color={theme.ACCENT} bold>{title} </Text>
|
|
106
|
+
<Text color={theme.MUTED}>{subtitle}</Text>
|
|
107
|
+
</Box>
|
|
108
|
+
|
|
109
|
+
<Box
|
|
110
|
+
borderStyle="round"
|
|
111
|
+
borderColor={theme.BORDER_ACTIVE}
|
|
112
|
+
paddingX={2}
|
|
113
|
+
paddingY={1}
|
|
114
|
+
marginTop={1}
|
|
115
|
+
width="100%"
|
|
116
|
+
flexDirection="column"
|
|
117
|
+
>
|
|
118
|
+
<Box>
|
|
119
|
+
<Text color={theme.TEXT}>{inputLabel}: </Text>
|
|
120
|
+
<Text color={display.isPlaceholder ? theme.DIM : theme.TEXT}>{display.before}</Text>
|
|
121
|
+
<Text
|
|
122
|
+
backgroundColor={theme.TEXT}
|
|
123
|
+
color={theme.PANEL}
|
|
124
|
+
>
|
|
125
|
+
{display.current}
|
|
126
|
+
</Text>
|
|
127
|
+
<Text color={display.isPlaceholder ? theme.DIM : theme.TEXT}>{display.after}</Text>
|
|
128
|
+
</Box>
|
|
129
|
+
<Box marginTop={1}>
|
|
130
|
+
<Text color={theme.DIM}>{footerHint}</Text>
|
|
131
|
+
</Box>
|
|
132
|
+
</Box>
|
|
133
|
+
</Box>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function measureTextEntryPanelRows(): number {
|
|
138
|
+
return 13;
|
|
139
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { AVAILABLE_THEMES, formatThemeLabel } from "../config/settings.js";
|
|
3
|
+
import { FOCUS_IDS } from "./focus.js";
|
|
4
|
+
import { SelectionPanel } from "./SelectionPanel.js";
|
|
5
|
+
|
|
6
|
+
interface ThemePickerProps {
|
|
7
|
+
currentTheme: string;
|
|
8
|
+
onSelect: (themeId: string) => void;
|
|
9
|
+
onHighlight?: (themeId: string) => void;
|
|
10
|
+
onCancel: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function ThemePicker({ currentTheme, onSelect, onHighlight, onCancel }: ThemePickerProps) {
|
|
14
|
+
const items = AVAILABLE_THEMES.map((theme) => ({
|
|
15
|
+
label: theme.id === currentTheme ? `${formatThemeLabel(theme.id)} ✓` : formatThemeLabel(theme.id),
|
|
16
|
+
value: theme.id,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<SelectionPanel
|
|
21
|
+
focusId={FOCUS_IDS.themePicker}
|
|
22
|
+
title="Select visual theme"
|
|
23
|
+
subtitle="Use arrow keys and Enter to switch. Esc closes the panel."
|
|
24
|
+
items={items}
|
|
25
|
+
limit={8}
|
|
26
|
+
onSelect={onSelect}
|
|
27
|
+
onHighlight={onHighlight}
|
|
28
|
+
onCancel={onCancel}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box, Text } from "ink";
|
|
3
|
+
import type { RunEvent } from "../session/types.js";
|
|
4
|
+
import { clampVisualText, getUsableShellWidth } from "./layout.js";
|
|
5
|
+
import { useTheme } from "./theme.js";
|
|
6
|
+
import { DashCard } from "./DashCard.js";
|
|
7
|
+
import {
|
|
8
|
+
formatProgressBlockBodyLines,
|
|
9
|
+
getProgressUpdateCount,
|
|
10
|
+
selectVisibleProgressBlocks,
|
|
11
|
+
type VisibleProgressBlock,
|
|
12
|
+
} from "./progressEntries.js";
|
|
13
|
+
|
|
14
|
+
export const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] as const;
|
|
15
|
+
|
|
16
|
+
const MAX_VISIBLE_PROGRESS_ENTRIES = 3;
|
|
17
|
+
|
|
18
|
+
interface ThinkingBlockProps {
|
|
19
|
+
cols: number;
|
|
20
|
+
run: RunEvent;
|
|
21
|
+
turnIndex: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getBlockMarker(isLive: boolean): string {
|
|
25
|
+
return isLive ? "▸" : "•";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function ThinkingBlock({ cols, run }: ThinkingBlockProps) {
|
|
29
|
+
const theme = useTheme();
|
|
30
|
+
const {
|
|
31
|
+
blocks,
|
|
32
|
+
hiddenCount,
|
|
33
|
+
totalCount,
|
|
34
|
+
latestBlock,
|
|
35
|
+
latestActiveBlock,
|
|
36
|
+
} = selectVisibleProgressBlocks(run.progressEntries ?? [], MAX_VISIBLE_PROGRESS_ENTRIES);
|
|
37
|
+
const contentWidth = Math.max(1, getUsableShellWidth(cols, 8));
|
|
38
|
+
const updateCount = totalCount || getProgressUpdateCount(run.progressEntries ?? []);
|
|
39
|
+
const currentBlock = latestActiveBlock ?? latestBlock;
|
|
40
|
+
const currentText = currentBlock
|
|
41
|
+
? clampVisualText(currentBlock.headline.replace(/^Current:\s*/i, ""), Math.max(1, contentWidth - 9))
|
|
42
|
+
: null;
|
|
43
|
+
const rightBadge = run.status === "running"
|
|
44
|
+
? "active"
|
|
45
|
+
: `${updateCount} update${updateCount === 1 ? "" : "s"}`;
|
|
46
|
+
|
|
47
|
+
if (blocks.length === 0 && run.status === "running") {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<DashCard
|
|
53
|
+
cols={cols}
|
|
54
|
+
title="Processing"
|
|
55
|
+
rightBadge={rightBadge}
|
|
56
|
+
borderColor={run.status === "running" ? theme.BORDER_ACTIVE : theme.BORDER_SUBTLE}
|
|
57
|
+
>
|
|
58
|
+
{blocks.length === 0 ? (
|
|
59
|
+
<Text color={theme.DIM}>No processing updates</Text>
|
|
60
|
+
) : (
|
|
61
|
+
<Box flexDirection="column" width="100%">
|
|
62
|
+
{currentText && run.status === "running" && (
|
|
63
|
+
<Box width="100%">
|
|
64
|
+
<Text color={theme.INFO} bold>Current: </Text>
|
|
65
|
+
<Text color={theme.TEXT}>{currentText}</Text>
|
|
66
|
+
</Box>
|
|
67
|
+
)}
|
|
68
|
+
{hiddenCount > 0 && (
|
|
69
|
+
<Box marginTop={currentText && run.status === "running" ? 1 : 0}>
|
|
70
|
+
<Text color={theme.DIM}>{`... ${hiddenCount} earlier update${hiddenCount === 1 ? "" : "s"}`}</Text>
|
|
71
|
+
</Box>
|
|
72
|
+
)}
|
|
73
|
+
{blocks.map((block, blockIndex) => {
|
|
74
|
+
const isLive = run.status === "running" && block.isActive;
|
|
75
|
+
return (
|
|
76
|
+
<Box
|
|
77
|
+
key={block.key}
|
|
78
|
+
flexDirection="column"
|
|
79
|
+
width="100%"
|
|
80
|
+
marginTop={blockIndex === 0 && hiddenCount === 0 && !(currentText && run.status === "running") ? 0 : 1}
|
|
81
|
+
>
|
|
82
|
+
<Text color={isLive ? theme.ACCENT : theme.INFO} bold={isLive}>
|
|
83
|
+
{`${getBlockMarker(isLive)} ${isLive ? "Live" : block.label}`}
|
|
84
|
+
</Text>
|
|
85
|
+
{formatProgressBlockBodyLines(block.text, contentWidth).map((line, lineIndex) => (
|
|
86
|
+
<Text key={`${block.key}-${lineIndex}`} color={theme.MUTED}>
|
|
87
|
+
{line ? `${isLive ? " | " : " "}${line}` : " "}
|
|
88
|
+
</Text>
|
|
89
|
+
))}
|
|
90
|
+
{isLive && (
|
|
91
|
+
<Text color={theme.ACCENT}> | ▌</Text>
|
|
92
|
+
)}
|
|
93
|
+
</Box>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
96
|
+
</Box>
|
|
97
|
+
)}
|
|
98
|
+
</DashCard>
|
|
99
|
+
);
|
|
100
|
+
}
|