Skip to content

Commit e64e776

Browse files
committed
WIP
1 parent 198d1c5 commit e64e776

File tree

4 files changed

+42
-11
lines changed

4 files changed

+42
-11
lines changed

src/agent/state.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ type AppActions = {
3939
startAgent: (input: string) => Promise<void>;
4040
_runAgentLogic: (retryCount?: number) => Promise<void>;
4141
toggleHelpMenu: () => void;
42-
clearHistory: () => void;
42+
clearOutput: () => void;
43+
clearCommandHistory: () => void;
4344
addCommandToHistory: (command: string) => void;
4445
getPreviousCommand: () => string | null;
4546
getNextCommand: () => string | null;
@@ -77,8 +78,11 @@ export const useStore = create<AppState & AppActions>((set, get) => ({
7778
toggleHelpMenu: () => {
7879
set((state) => ({ helpMenuOpen: !state.helpMenuOpen }));
7980
},
80-
clearHistory: () => {
81-
set({ history: [], commandHistory: [], commandHistoryIndex: 0 });
81+
clearOutput: () => {
82+
set({ history: [] });
83+
},
84+
clearCommandHistory: () => {
85+
set({ commandHistory: [], commandHistoryIndex: 0 });
8286
try {
8387
fs.writeFileSync(HISTORY_PATH, "");
8488
} catch (err) {

src/ui/HelpMenu.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ const commands = [
88
},
99
{
1010
command: "/clear",
11-
description: "Clear the history",
11+
description: "Clear the conversation output",
12+
},
13+
{
14+
command: "/clearHistory",
15+
description: "Clear the command history",
1216
},
1317
{
1418
command: "/quit",

src/ui/HistoryItemDisplay.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,17 @@ export function HistoryItemDisplay({ message }: { message: Message }) {
6464
case "user":
6565
return <UserMessageContent content={message.content} />;
6666
case "assistant":
67-
return <AssistantMessageContent content={message.content as AssistantContent} />;
67+
return (
68+
<Box borderStyle="round" borderColor="green" paddingX={1}>
69+
<AssistantMessageContent content={message.content as AssistantContent} />
70+
</Box>
71+
);
6872
case "tool":
69-
return <ToolMessageContent content={message.content as ToolContent} />;
73+
return (
74+
<Box borderStyle="round" borderColor="yellow" paddingX={1}>
75+
<ToolMessageContent content={message.content as ToolContent} />
76+
</Box>
77+
);
7078
default:
7179
return null;
7280
}

src/ui/UserInput.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export function UserInput() {
1111
startAgent,
1212
mode,
1313
toggleHelpMenu,
14-
clearHistory,
14+
clearOutput,
15+
clearCommandHistory,
1516
getPreviousCommand,
1617
getNextCommand,
1718
setSystemPrompt,
@@ -22,7 +23,8 @@ export function UserInput() {
2223
startAgent: s.actions.startAgent,
2324
mode: s.mode,
2425
toggleHelpMenu: s.actions.toggleHelpMenu,
25-
clearHistory: s.actions.clearHistory,
26+
clearOutput: s.actions.clearOutput,
27+
clearCommandHistory: s.actions.clearCommandHistory,
2628
getPreviousCommand: s.actions.getPreviousCommand,
2729
getNextCommand: s.actions.getNextCommand,
2830
setSystemPrompt: s.actions.setSystemPrompt,
@@ -45,7 +47,7 @@ export function UserInput() {
4547
const nextCommand = getNextCommand();
4648
setInputValue(nextCommand ?? "");
4749
} else if (key.ctrl && input === "l") {
48-
clearHistory();
50+
clearOutput();
4951
}
5052
}
5153
});
@@ -62,7 +64,10 @@ export function UserInput() {
6264
toggleHelpMenu();
6365
break;
6466
case "clear":
65-
clearHistory();
67+
clearOutput();
68+
break;
69+
case "clearHistory":
70+
clearCommandHistory();
6671
break;
6772
case "quit":
6873
exit();
@@ -78,7 +83,17 @@ export function UserInput() {
7883
break;
7984
}
8085
} else {
81-
startAgent(value);
86+
switch (value) {
87+
case "clear":
88+
clearOutput();
89+
break;
90+
case "clear history":
91+
clearCommandHistory();
92+
break;
93+
default:
94+
startAgent(value);
95+
break;
96+
}
8297
}
8398
setInputValue("");
8499
}

0 commit comments

Comments
 (0)