feat: add manual/auto conversation compaction and preserve full export history

This commit is contained in:
Xiaohan-Tian
2026-06-01 19:55:59 -07:00
parent 936fb461e3
commit c1d9f4c9fb
23 changed files with 1059 additions and 27 deletions
@@ -287,14 +287,29 @@ describe('processUserMessage slash commands', () => {
expect(result.pseudoAssistantResponse).toContain('chat/hotkeys.md');
});
it('parses /compact and returns manual compaction metadata', async () => {
const result = await processUserMessage('/compact keep the current chord decisions');
expect(result).toMatchObject({
displayUserMessage: false,
sendToLLM: false,
finalMessageForLLM: null,
pseudoAssistantResponse: null,
metadata: {
command: 'compact',
focus: 'keep the current chord decisions',
},
});
});
it('lists the new hotkeys commands for unknown slash commands', async () => {
const result = await processUserMessage('/unknown foo');
expect(storeState.setStatus).toHaveBeenCalledWith(
'Unknown command: /unknown. Available commands: /clear, /welcome, /help, /hotkeys, /hotkey'
'Unknown command: /unknown. Available commands: /clear, /welcome, /help, /hotkeys, /hotkey, /compact'
);
expect(result.pseudoAssistantResponse).toBe(
'Unknown command: /unknown foo.\nAvailable commands: /clear, /welcome, /help, /hotkeys, /hotkey'
'Unknown command: /unknown foo.\nAvailable commands: /clear, /welcome, /help, /hotkeys, /hotkey, /compact'
);
expect(result).toMatchObject({
displayUserMessage: false,
+14 -1
View File
@@ -218,9 +218,22 @@ export async function processUserMessage(originalMessage: string): Promise<UserM
}
}
case '/compact': {
return {
displayUserMessage: false,
sendToLLM: false,
finalMessageForLLM: null,
pseudoAssistantResponse: null,
metadata: {
command: 'compact',
focus: argString.trim() || undefined,
}
};
}
default: {
const { setStatus } = useProjectStore.getState();
const help = 'Available commands: /clear, /welcome, /help, /hotkeys, /hotkey';
const help = 'Available commands: /clear, /welcome, /help, /hotkeys, /hotkey, /compact';
setStatus(`Unknown command: ${command}. ${help}`);
return {
displayUserMessage: false,