mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-06 15:39:41 +02:00
fix(response-viewer): populate the viewer for OpenCode/Gemini/Antigravity panes
`GET /api/sessions/:id/last-response` branches to a Codex-specific reader, then falls through to scanning `~/.claude/projects` for a transcript. OpenCode, Gemini and Antigravity render their own TUIs and never write one, so that scan finds nothing and the response viewer is permanently empty for all three modes. For these CLIs the pane IS the transcript, so segment it. `response-viewer-transcript.ts` is a pure, dependency-free parser that splits a terminal buffer into prompt / response / status / tool blocks, keying off the `›` prompt marker, status dividers and `• Calling|Called` tool-activity lines. The route uses it to answer with the LAST response, and to carry the parsed blocks under `?context=full`. Codex keeps its existing branch: it has real rollout files, which are a better source than scraped pane text. The response shape is unchanged for every other mode, and Claude panes are explicitly pinned to the Claude transcript path so a real transcript can never be shadowed by scraped text. Tests: 14 parser cases plus a route suite covering all three modes, the `?context=full` payload, an empty pane, and the Claude regression guard.
This commit is contained in:
@@ -131,6 +131,11 @@ import {
|
||||
toSessionDocker,
|
||||
} from '../../docker-hosts.js';
|
||||
import { LRUMap } from '../../utils/lru-map.js';
|
||||
import {
|
||||
getLastTranscriptResponse,
|
||||
isExternalCliTranscriptMode,
|
||||
parseExternalCliTranscript,
|
||||
} from '../response-viewer-transcript.js';
|
||||
|
||||
// Path to linked-cases registry (same file used by case-routes resolveCasePath)
|
||||
const LINKED_CASES_FILE = dataPath('linked-cases.json');
|
||||
@@ -1898,6 +1903,22 @@ export function registerSessionRoutes(
|
||||
return await readCodexLastResponse(session, codexQuery.context === 'full');
|
||||
}
|
||||
|
||||
// OpenCode / Gemini / Antigravity render their own TUIs and write no Claude
|
||||
// transcript, so the scan below finds nothing and the response viewer renders
|
||||
// permanently empty for them. Segment the terminal buffer instead — the pane
|
||||
// IS the transcript for these CLIs. Codex is already handled above, where a
|
||||
// real rollout file is the better source.
|
||||
if (isExternalCliTranscriptMode(session.mode)) {
|
||||
const externalQuery = req.query as { context?: string };
|
||||
const blocks = parseExternalCliTranscript(session.terminalBuffer, session.mode);
|
||||
return {
|
||||
text: getLastTranscriptResponse(blocks),
|
||||
timestamp: '',
|
||||
hasContext: blocks.length > 0,
|
||||
messages: externalQuery.context === 'full' ? blocks : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
// Scan ~/.claude/projects/*/ for the transcript file
|
||||
const projectsDir = join(process.env.HOME || '/tmp', '.claude', 'projects');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user