Skip to content

feat(native-chat): add Antigravity (AGY) transcript decoder and Native Chat support - #15773

Closed
haoliangli wants to merge 1 commit into
stablyai:mainfrom
haoliangli:feat/native-chat-antigravity
Closed

haoliangli wants to merge 1 commit into
stablyai:mainfrom
haoliangli:feat/native-chat-antigravity

Conversation

@haoliangli

Copy link
Copy Markdown

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.

  • Codex / Claude: Included in NATIVE_CHAT_SUPPORTED_AGENTS. Orca parses their session transcripts, activates Native Chat, and renders mermaid blocks directly into interactive SVG diagrams via Mermaid.js.
  • Antigravity (agy): While Orca already provides hook monitoring (antigravityHookService) and session scanning in AI Vault, antigravity was not yet registered in NATIVE_CHAT_SUPPORTED_AGENTS. Consequently, Orca fell back to displaying AGY inside the raw xterm.js terminal 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

  1. Agent Support & Whitelist (src/shared/native-chat-agent-support.ts):
    • Added 'antigravity' to NativeChatTranscriptAgent and NATIVE_CHAT_SUPPORTED_AGENTS.
    • Updated resolveNativeChatTranscriptAgent to pass through 'antigravity'.
  2. Transcript Line Decoder (src/main/native-chat/transcript-line-decoders-antigravity.ts):
    • Implemented decodeAntigravityTranscriptLine for parsing transcript.jsonl records (USER_INPUT with <USER_REQUEST> unwrapping, PLANNER_RESPONSE with thinking, content, tool_calls, and TOOL_RESULT outputs).
    • Exported decoder in src/main/native-chat/transcript-line-decoders.ts.
  3. Turn Lifecycle Decoder (src/main/native-chat/transcript-turn-lifecycle.ts):
    • Implemented decodeAntigravityTurnLifecycle to track active (working), completed, and interrupted turn states.
  4. Session File Resolution & Tail Reader (src/main/native-chat/session-file-resolver.ts, transcript-reader.ts, transcript-tail-reader.ts):
    • Added Antigravity brain directory transcript resolution (~/.gemini/antigravity-cli/brain/<sessionId>/.system_generated/logs/transcript.jsonl).
    • Wired line decoder and lifecycle decoder into transcript stream and tail readers.
  5. Unit Tests:
    • Added transcript-line-decoders.antigravity.test.ts testing user prompts, responses, thinking, tool calls, and error handling.
    • Added Antigravity test cases to native-chat-agent-support.test.ts and transcript-reader.test.ts.

Testing

  • Ran test suite with 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)

… 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.
Copilot AI lite review requested due to automatic review settings August 21, 2026 12:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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 223a6

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the motivation, changes, and tests, but omits several required template sections, including the linked issue, visual proof, checklist, and review details. Use the full template, add the required issue link and visual-proof statement or attachments, provide platform testing details, and complete the remaining checklist sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 21.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the Antigravity transcript decoder and Native Chat support added by this pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/main/native-chat/transcript-line-decoders-antigravity.ts (1)

30-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove 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

📥 Commits

Reviewing files that changed from the base of the PR and between 59892a2 and 223a694.

📒 Files selected for processing (10)
  • src/main/native-chat/session-file-resolver.ts
  • src/main/native-chat/transcript-line-decoders-antigravity.ts
  • src/main/native-chat/transcript-line-decoders.antigravity.test.ts
  • src/main/native-chat/transcript-line-decoders.ts
  • src/main/native-chat/transcript-reader.test.ts
  • src/main/native-chat/transcript-reader.ts
  • src/main/native-chat/transcript-tail-reader.ts
  • src/main/native-chat/transcript-turn-lifecycle.ts
  • src/shared/native-chat-agent-support.test.ts
  • src/shared/native-chat-agent-support.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment on lines +305 to +313
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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.

Suggested change
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
}

Comment on lines +63 to +64
if (record.source === 'MODEL' && record.type === 'PLANNER_RESPONSE') {
return { state: 'completed', turnId, timestamp }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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 }

@nwparker

Copy link
Copy Markdown
Contributor

Verification against existing local Antigravity transcripts found two blockers in candidate head 223a694acd047733c19dd21e0cee729b82e62a2f.

I compiled this head's decodeAntigravityTranscriptLine and decodeAntigravityTurnLifecycle and executed them against five bounded real transcript samples (500/54/39/70/57 records). The decoder logic was unchanged; imports resolved to the current checkout's shared parsing utilities. Only record schema and aggregate counts are reported here; no conversation contents or private paths are published.

  1. Real tool activity disappears. These samples contain 208/24/18/32/27 MODEL activity records with types such as RUN_COMMAND, VIEW_FILE, LIST_DIRECTORY, GREP_SEARCH, CODE_ACTION, and GENERIC. The candidate returned null for every one: 0 of 309 decoded. Its tool-result branch instead expects SYSTEM/USER/TOOL plus TOOL_RESULT/TOOL_RESPONSE/tool_result. Supporting synthetic tool fixtures does not establish support for the installed transcript format.
  2. Intermediate responses end the turn prematurely. In every sample, an actual consecutive sequence was MODEL/PLANNER_RESPONSE/DONE → MODEL/RUN_COMMAND/DONE (or GENERIC), followed by further activity. The candidate returned completed for the planner response and nothing for the subsequent activity. The first sample alone produces 242 planner-completion events. A completed planner step is not evidence that the user's whole turn ended.

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 401 ACCESS_TOKEN_TYPE_UNSUPPORTED. No PR merged or issue closed.

@nwparker

Copy link
Copy Markdown
Contributor

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.

@nwparker

Copy link
Copy Markdown
Contributor

Review verdict: Do not merge as-is; superseded by #21660 → #21776. Native Chat transcript decoding and command-approval ingestion are now maintained in the stacked Chat PRs with current readiness and Windows Allow/Deny evidence.

nwparker added a commit that referenced this pull request Oct 2, 2026
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]>
nwparker added a commit that referenced this pull request Oct 4, 2026
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.
nwparker added a commit that referenced this pull request Oct 4, 2026
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]>
nwparker added a commit that referenced this pull request Oct 4, 2026
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.
@nwparker

Copy link
Copy Markdown
Contributor

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.

@nwparker nwparker closed this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants