Skip to content

Commit 3ac5f18

Browse files
committed
feat(cli): add status bar configuration command
Add a new interactive `statusbar` command that allows users to configure which status bar features are displayed. The command provides a multi-select prompt for toggling model name, token count, git status, memory usage, and context size display options. Also improve Ctrl+C handling to exit the application when input is empty, and update chat history rendering to use the Static component for better performance.
1 parent f75a013 commit 3ac5f18

4 files changed

Lines changed: 100 additions & 9 deletions

File tree

src/commands/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { createMCPCommand } from "./mcp";
1010
import { createGitCommand } from "./git";
1111
import { Command } from "commander";
1212

13+
import { createStatusBarCommand } from "./statusbar";
14+
1315
export function registerCommands(program: Command) {
1416
// Register all commands
1517
program.addCommand(createMCPCommand());
@@ -23,4 +25,5 @@ export function registerCommands(program: Command) {
2325
program.addCommand(createProviderCommand());
2426
program.addCommand(createIndexCommand());
2527
program.addCommand(createRepositoryCommand());
28+
program.addCommand(createStatusBarCommand());
2629
}

src/commands/statusbar.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { getSettingsManager } from "../utils/settings-manager";
2+
import { Command } from "commander";
3+
import { prompt } from "enquirer";
4+
5+
export function createStatusBarCommand(): Command {
6+
const command = new Command("statusbar");
7+
8+
command.description("Configure status bar settings").action(async () => {
9+
const manager = getSettingsManager();
10+
const settings = manager.loadUserSettings();
11+
const currentConfig = settings.ui.statusbar_config || {
12+
show_model: true,
13+
show_tokens: true,
14+
show_git_status: true,
15+
show_memory: false,
16+
show_context: false,
17+
};
18+
19+
try {
20+
const response = await prompt<{
21+
features: string[];
22+
}>({
23+
type: "multiselect",
24+
name: "features",
25+
message: "Select status bar features to display:",
26+
choices: [
27+
{
28+
name: "show_model",
29+
message: "Model Name",
30+
value: "show_model",
31+
enabled: currentConfig.show_model,
32+
},
33+
{
34+
name: "show_tokens",
35+
message: "Token Count",
36+
value: "show_tokens",
37+
enabled: currentConfig.show_tokens,
38+
},
39+
{
40+
name: "show_git_status",
41+
message: "Git Status",
42+
value: "show_git_status",
43+
enabled: currentConfig.show_git_status,
44+
},
45+
{
46+
name: "show_memory",
47+
message: "Memory Usage",
48+
value: "show_memory",
49+
enabled: currentConfig.show_memory,
50+
},
51+
{
52+
name: "show_context",
53+
message: "Context Size",
54+
value: "show_context",
55+
enabled: currentConfig.show_context,
56+
},
57+
],
58+
});
59+
60+
// Convert array of selected features back to config object
61+
const newConfig = {
62+
show_model: response.features.includes("show_model"),
63+
show_tokens: response.features.includes("show_tokens"),
64+
show_git_status: response.features.includes("show_git_status"),
65+
show_memory: response.features.includes("show_memory"),
66+
show_context: response.features.includes("show_context"),
67+
};
68+
69+
manager.saveUserSettings({
70+
ui: {
71+
...settings.ui,
72+
statusbar_config: newConfig,
73+
},
74+
});
75+
76+
console.log("✓ Status bar configuration updated");
77+
} catch (error) {
78+
console.error("Failed to update status bar configuration:", error);
79+
}
80+
});
81+
82+
return command;
83+
}

src/hooks/use-enhanced-input.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,14 @@ export function useEnhancedInput({
124124
return;
125125
}
126126

127-
// Handle Ctrl+C - clear input
127+
// Handle Ctrl+C
128128
if (
129129
(key.ctrl && (inputChar === "c" || inputChar === "C")) ||
130130
inputChar === "\x03"
131131
) {
132+
if (input.length === 0) {
133+
process.exit(0);
134+
}
132135
setInputState("");
133136
setCursorPositionState(0);
134137
setOriginalInput("");

src/ui/components/chat-history.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { MarkdownRenderer } from "../utils/markdown-renderer";
22
import { ChatEntry } from "../../agent/super-agent";
33
import { DiffRenderer } from "./diff-renderer";
4-
import { Box, Text } from "ink";
4+
import { Box, Static, Text } from "ink";
55
import React from "react";
66

77
interface ChatHistoryProps {
@@ -225,13 +225,15 @@ export function ChatHistory({
225225

226226
return (
227227
<Box flexDirection="column">
228-
{filteredEntries.slice(-50).map((entry, index) => (
229-
<MemoizedChatEntry
230-
key={`${entry.timestamp.getTime()}-${index}`}
231-
entry={entry}
232-
index={index}
233-
/>
234-
))}
228+
<Static items={filteredEntries}>
229+
{(entry, index) => (
230+
<MemoizedChatEntry
231+
key={`${entry.timestamp.getTime()}-${index}`}
232+
entry={entry}
233+
index={index}
234+
/>
235+
)}
236+
</Static>
235237
</Box>
236238
);
237239
}

0 commit comments

Comments
 (0)