feat(cli): add /history slash command to TUI
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful

Adds /history (alias /hist) as a local TUI command that fetches the
current conversation's messages via GET /api/conversations/:id/messages
and displays message counts, user/assistant breakdown, estimated token
usage (~4 chars/token heuristic), and context window percentage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 15:40:06 -05:00
parent 1d14ddcfe7
commit 04c634cb80
5 changed files with 109 additions and 1 deletions

View File

@@ -361,6 +361,31 @@ export async function deleteMission(
}
}
// ── Conversation Message types ──
export interface ConversationMessage {
id: string;
role: 'user' | 'assistant' | 'system' | 'tool';
content: string;
createdAt: string;
}
// ── Conversation Message endpoints ──
export async function fetchConversationMessages(
gatewayUrl: string,
sessionCookie: string,
conversationId: string,
): Promise<ConversationMessage[]> {
const res = await fetch(
`${gatewayUrl}/api/conversations/${encodeURIComponent(conversationId)}/messages`,
{
headers: headers(sessionCookie, gatewayUrl),
},
);
return handleResponse<ConversationMessage[]>(res, 'Failed to fetch conversation messages');
}
// ── Mission Task endpoints ──
export async function fetchMissionTasks(