The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): /history uses the transcript's public projection
Tekniumc84523440ede
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.test.tsx b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.test.tsxindex 0f40345be9f..a1d9e601a65 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.test.tsx@@ -8,6 +8,7 @@ import { dropSessionState } from '@/store/session-states'import { actRender, Harness, type HarnessHandle, RUNTIME_SESSION_ID } from './index-test-utils'import { clearSingleFlightSessionResumeState } from './single-flight-resume'+import { formatHistory } from './slash-desktop-commands'// T11 (#134889): Desktop commands the shared gateway refused as `slash.exec`, or that Desktop never// offered, run on the owner's existing verbs instead.@@ -273,6 +274,22 @@ describe('/history', () => {expect(text).toContain('Hermes: first answer')expect(text).not.toContain('tool noise')})++ it('uses the transcript projection: archived turns shown, hidden rows skipped, display_content preferred', () => {+ const history = formatHistory([+ { role: 'user', content: 'ARCHIVED QUESTION', archived: true, row_id: 1 },+ { role: 'assistant', content: 'ARCHIVED ANSWER', archived: true, row_id: 2 },+ { role: 'user', content: 'MODEL ONLY HEARTBEAT', display_kind: 'hidden', row_id: 3 },+ { role: 'user', content: 'MODEL ONLY SKILL BODY', display_content: '/skill question', row_id: 4 },+ { role: 'assistant', content: 'VISIBLE ANSWER', row_id: 5 }+ ] as never)++ expect(history).toContain('You: ARCHIVED QUESTION')+ expect(history).toContain('Hermes: ARCHIVED ANSWER')+ expect(history).toContain('You: /skill question')+ expect(history).toContain('Hermes: VISIBLE ANSWER')+ expect(history).not.toContain('MODEL ONLY')+ })})describe('/save writes on the Electron side', () => {diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.tsindex 72781d26d72..96992219210 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.ts+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/slash-desktop-commands.ts@@ -1,4 +1,4 @@-import { toChatMessages } from '@/lib/chat-messages'+import { chatMessageText, toChatMessages } from '@/lib/chat-messages'import { isMissingRpcMethod } from '@/lib/gateway-rpc'import { openCommandPalette } from '@/store/command-palette'import { $displayTimestamps } from '@/store/display-timestamps'@@ -213,48 +213,19 @@ function yamlLines(value: unknown, indent = ''): string[] {)}-function contentText(content: unknown): string {- if (typeof content === 'string') {- return content- }-- if (Array.isArray(content)) {- return content- .map(part =>- part && typeof part === 'object' && typeof (part as { text?: unknown }).text === 'string'- ? (part as { text: string }).text- : ''- )- .filter(Boolean)- .join(' ')- }-- return ''-}--interface HistoryRow {- archived?: unknown- content?: unknown- display_kind?: unknown- role?: unknown- text?: unknown-}--export function formatHistory(rows: HistoryRow[]): string {- const turns = rows.flatMap(row => {- if (row.archived || (row.role !== 'user' && row.role !== 'assistant')) {- return []- }-- const text = (contentText(row.content) || (typeof row.text === 'string' ? row.text : '')).trim()+/** `/history` text from the same public projection the transcript renders (archived turns shown,+ * hidden/model-only rows skipped, display_content preferred). */+export function formatHistory(rows: SessionMessage[]): string {+ const turns = toChatMessages(rows).flatMap(message => {+ const text = chatMessageText(message).trim()- if (!text) {+ if (message.hidden || !text || (message.role !== 'user' && message.role !== 'assistant')) {return []}const clipped = text.length > HISTORY_PREVIEW ? `${text.slice(0, HISTORY_PREVIEW)}…` : text- return [`${row.role === 'user' ? 'You' : 'Hermes'}: ${clipped}`]+ return [`${message.role === 'user' ? 'You' : 'Hermes'}: ${clipped}`]})return turns.length ? [`Conversation history (${turns.length} messages):`, ...turns].join('\n') : 'No messages yet.'