Repository navigation
feat(native-chat): add Antigravity (AGY) transcript decoder and Native Chat support - #15773
haoliangli wants to merge 1 commit into
Conversation
… support Add transcript line decoder, turn lifecycle decoding, and session file resolver for Antigravity (AGY). This enables Native Chat rendering parity (including Mermaid diagrams, tool calls, and thinking blocks) with Codex and Claude.
📝 WalkthroughWalkthroughThe change adds Antigravity as a supported native chat transcript agent. It resolves transcripts from the Antigravity brain directory, decodes JSONL user, assistant, and tool records, and handles transcript tail reading. It also derives Antigravity turn lifecycle states. Tests cover agent support, transcript resolution, message decoding, tool errors, invalid records, and integrated transcript reading. Merge Risk: 🟠 High · up to The Antigravity integration can currently read transcript files outside its intended session directory and may show a turn as finished while tool execution is still in progress, which can expose unrelated data and produce incorrect chat state. These issues should be fixed before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/main/native-chat/transcript-line-decoders-antigravity.ts (1)
30-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove code-walkthrough comments.
These headings restate the adjacent branches and block construction. Keep comments only for non-obvious constraints or compatibility behavior.
As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior or walk through code.”
Also applies to: 49-65, 94-94
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: d27461fc-d419-4969-9c14-d306bf8c8944
📒 Files selected for processing (10)
src/main/native-chat/session-file-resolver.tssrc/main/native-chat/transcript-line-decoders-antigravity.tssrc/main/native-chat/transcript-line-decoders.antigravity.test.tssrc/main/native-chat/transcript-line-decoders.tssrc/main/native-chat/transcript-reader.test.tssrc/main/native-chat/transcript-reader.tssrc/main/native-chat/transcript-tail-reader.tssrc/main/native-chat/transcript-turn-lifecycle.tssrc/shared/native-chat-agent-support.test.tssrc/shared/native-chat-agent-support.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| async function resolveAntigravitySessionFile( | ||
| sessionId: string, | ||
| brainDir: string, | ||
| signal?: AbortSignal | ||
| ): Promise<string | null> { | ||
| const directPath = join(brainDir, sessionId, '.system_generated', 'logs', 'transcript.jsonl') | ||
| signal?.throwIfAborted() | ||
| const readable = await toHostReadableTranscriptPath(directPath, { signal }) | ||
| return readable ?? null |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
Keep sessionId inside the Antigravity brain root.
Line 310 combines brainDir with an unvalidated sessionId. A value containing .. can escape the configured brain root before this code reads transcript.jsonl. Resolve the session directory and reject it unless it remains below the resolved brain root. Add tests for traversal and platform separators.
Proposed fix
-import { basename, extname, join } from 'node:path'
+import { basename, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'
async function resolveAntigravitySessionFile(
sessionId: string,
brainDir: string,
signal?: AbortSignal
): Promise<string | null> {
- const directPath = join(brainDir, sessionId, '.system_generated', 'logs', 'transcript.jsonl')
+ const root = resolve(brainDir)
+ const sessionDir = resolve(root, sessionId)
+ const relativeSessionDir = relative(root, sessionDir)
+ if (
+ !relativeSessionDir ||
+ relativeSessionDir === '..' ||
+ relativeSessionDir.startsWith(`..${sep}`) ||
+ isAbsolute(relativeSessionDir)
+ ) {
+ return null
+ }
+ const directPath = join(sessionDir, '.system_generated', 'logs', 'transcript.jsonl')
signal?.throwIfAborted()
const readable = await toHostReadableTranscriptPath(directPath, { signal })
return readable ?? null
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| async function resolveAntigravitySessionFile( | |
| sessionId: string, | |
| brainDir: string, | |
| signal?: AbortSignal | |
| ): Promise<string | null> { | |
| const directPath = join(brainDir, sessionId, '.system_generated', 'logs', 'transcript.jsonl') | |
| signal?.throwIfAborted() | |
| const readable = await toHostReadableTranscriptPath(directPath, { signal }) | |
| return readable ?? null | |
| import { basename, extname, isAbsolute, join, relative, resolve, sep } from 'node:path' | |
| async function resolveAntigravitySessionFile( | |
| sessionId: string, | |
| brainDir: string, | |
| signal?: AbortSignal | |
| ): Promise<string | null> { | |
| const root = resolve(brainDir) | |
| const sessionDir = resolve(root, sessionId) | |
| const relativeSessionDir = relative(root, sessionDir) | |
| if ( | |
| !relativeSessionDir || | |
| relativeSessionDir === '..' || | |
| relativeSessionDir.startsWith(`..${sep}`) || | |
| isAbsolute(relativeSessionDir) | |
| ) { | |
| return null | |
| } | |
| const directPath = join(sessionDir, '.system_generated', 'logs', 'transcript.jsonl') | |
| signal?.throwIfAborted() | |
| const readable = await toHostReadableTranscriptPath(directPath, { signal }) | |
| return readable ?? null | |
| } |
| if (record.source === 'MODEL' && record.type === 'PLANNER_RESPONSE') { | ||
| return { state: 'completed', turnId, timestamp } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Do not complete a turn that has tool calls.
Line 63 marks every PLANNER_RESPONSE as completed. The Antigravity decoder emits tool-call blocks from the same record, and the integration fixture then emits a tool result. The tail lifecycle can therefore report completion before tool execution ends.
Return working when the planner response contains tool calls. Return completed only for a terminal planner response. Add lifecycle tests for both paths.
Proposed fix
if (record.source === 'MODEL' && record.type === 'PLANNER_RESPONSE') {
- return { state: 'completed', turnId, timestamp }
+ const hasToolCalls =
+ Array.isArray(record.tool_calls) &&
+ record.tool_calls.some((call) => asRecord(call) !== null)
+ return { state: hasToolCalls ? 'working' : 'completed', turnId, timestamp }
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (record.source === 'MODEL' && record.type === 'PLANNER_RESPONSE') { | |
| return { state: 'completed', turnId, timestamp } | |
| if (record.source === 'MODEL' && record.type === 'PLANNER_RESPONSE') { | |
| const hasToolCalls = | |
| Array.isArray(record.tool_calls) && | |
| record.tool_calls.some((call) => asRecord(call) !== null) | |
| return { state: hasToolCalls ? 'working' : 'completed', turnId, timestamp } |
|
Verification against existing local Antigravity transcripts found two blockers in candidate head I compiled this head's
ELI5: the proposed chat can hide the agent's tool work and say it finished while that work continues. I am not enabling it or adopting this head yet. A takeover needs captured-schema coverage for these real activity records, a supported turn-end signal (or explicitly unknown lifecycle where the transcript cannot prove one), and verification of the live read/send path before adding Antigravity to the supported-agent list. Existing source utilities should be reused. The execution host's canonical status store remains the owner of status; adding a renderer-side guess would not fix this. These were offline decoder checks against real saved transcripts, not a new successful model turn or a rendered native-chat test. Current live agy generation on this machine still returns |
|
Takeover draft: #21660 (stacked on #21657), with the original candidate author credited. ELI5: Antigravity can now use the experimental chat view while the same agy terminal continues to run underneath it. The revised parser preserves the actual tool activity and arguments instead of hiding them, and does not mistake a finished planner step for a finished user turn. Verification: all 309 activity records in the five bounded real samples now decode; 139 focused tests, full typecheck, changed-code quality, and Electron/Vite build pass. In a hidden macOS app with agy 1.2.7, a real saved conversation rendered and a prompt sent through the chat composer was persisted by agy. The PR includes actual-input screenshots and a separately labeled sanitized tool-rendering fixture. Hooks were disabled in the isolated validation profile, so pane/session metadata was supplied as a fixture. Actual hook delivery/status transitions and successful generation remain unverified; generation still returns 401 ACCESS_TOKEN_TYPE_UNSUPPORTED. Windows/Linux/WSL/SSH, paired-host execution, and permission questions need live checks. This adds terminal-backed Antigravity chat, not Cursor or a structured-session provider. Keeping the PR draft and this issue open. |
Recover scoped transcript, terminal approvals, and WSL support on current main. Keep hook-server authority, captured-grid rules, quiescence, and current journals. Negotiate Antigravity reads and subscriptions on desktop, web, and mobile. Credits #15773, #21660, #21776, and #24141. Co-authored-by: haoliangli <[email protected]> Co-authored-by: sojiro-o <[email protected]>
Preserves accepted Antigravity Chat source from @haoliangli (#15773) and @sojiro-o (#24141). Carries runtime-owned Chat association and authoritative ruled-screen publication onto fixed main 752871b.
Antigravity records first turns at whole seconds, leaving a millisecond composer echo visible below later turns. Publish optional source precision and use it when matching local sends and seeded launch prompts; retain strict transcript boundaries and exact matching when precision is absent. Credits @sojiro-o/#25117 for the first-send diagnosis and proposed regression. Retains the Antigravity Chat contributions from @haoliangli/#15773 and @sojiro-o/#24141 without changing accepted readiness or capture assets. Co-authored-by: sojiro-o <[email protected]>
Compose main 2b3b692 with the complete Chat feature and ed05 source-clock repair. Preserve provider step order and incoming split-reasoning order; remove a duplicated import introduced by the automatic merge and test the combined ordering contract. Retains credits for @sojiro-o/#25117 and #24141 and @haoliangli/#15773; original author objects and measured coauthor trailers remain unchanged.
|
Thank you for this, @haoliangli. Antigravity chat support shipped through #21776 and the managed ACP chat, so this transcript decoder is superseded and I'm closing it. Your work helped shape the approach. |
Summary
This PR adds Native Chat transcript decoding and session integration for Antigravity (
agy), enabling rich message rendering (including interactive Mermaid diagrams, markdown formatting, tool calls, and thinking blocks) parity with existing supported agents like Codex, Claude, Grok, and OMP.Motivation & Problem Statement
Orca provides rich markdown features such as interactive Mermaid diagram rendering (
MermaidBlock) inside the Native Chat component pipeline.NATIVE_CHAT_SUPPORTED_AGENTS. Orca parses their session transcripts, activates Native Chat, and rendersmermaidblocks directly into interactive SVG diagrams via Mermaid.js.agy): While Orca already provides hook monitoring (antigravityHookService) and session scanning in AI Vault,antigravitywas not yet registered inNATIVE_CHAT_SUPPORTED_AGENTS. Consequently, Orca fell back to displaying AGY inside the rawxterm.jsterminal emulator pane. Terminal emulators process plain ANSI text/character streams and cannot mount React components or render SVG diagrams, leaving all Mermaid diagrams as raw code blocks.Key Changes
src/shared/native-chat-agent-support.ts):'antigravity'toNativeChatTranscriptAgentandNATIVE_CHAT_SUPPORTED_AGENTS.resolveNativeChatTranscriptAgentto pass through'antigravity'.src/main/native-chat/transcript-line-decoders-antigravity.ts):decodeAntigravityTranscriptLinefor parsingtranscript.jsonlrecords (USER_INPUTwith<USER_REQUEST>unwrapping,PLANNER_RESPONSEwiththinking,content,tool_calls, andTOOL_RESULToutputs).src/main/native-chat/transcript-line-decoders.ts.src/main/native-chat/transcript-turn-lifecycle.ts):decodeAntigravityTurnLifecycleto track active (working), completed, and interrupted turn states.src/main/native-chat/session-file-resolver.ts,transcript-reader.ts,transcript-tail-reader.ts):~/.gemini/antigravity-cli/brain/<sessionId>/.system_generated/logs/transcript.jsonl).transcript-line-decoders.antigravity.test.tstesting user prompts, responses, thinking, tool calls, and error handling.native-chat-agent-support.test.tsandtranscript-reader.test.ts.Testing
bun test:src/shared/native-chat-agent-support.test.ts(All pass)src/main/native-chat/transcript-line-decoders.antigravity.test.ts(All pass)src/main/native-chat/transcript-reader.test.ts(All pass)