Skip to content

feat(droid): open Droid sessions from Session History in a chat - #50162

Merged
AmoabaKelvin merged 1 commit into
mainfrom
open-droid-sessions-in-chat
Nov 27, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
open-droid-sessions-in-chat

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

Droid conversations you started outside Orca, in a droid terminal or the Factory app, already showed up in Session History, but you could only reopen them in a terminal. Now you can open them as a chat: the old messages show up, and you keep talking to the same Droid session.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​108 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​108
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​273 $\color{#cf222e}{\Huge{\mathbf{−}}}$​77 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​196

What Changed

Before: a Droid row in Session History had no "Resume in New Chat". A running Droid terminal also couldn't "Continue in chat". The host would have refused anyway, because Droid had no transcript importer.

After: both actions work for Droid, the same way they do for Claude, Codex, Pi, OMP, Grok, Hermes and Antigravity. The chat shows the conversation's prompts, replies and tool runs. Droid's hook runs, notices and injected system reminders are left out, the same way Droid's own UI hides them. The chat then reopens the session over ACP, so new turns land in the same .jsonl.

How:

  • DROID_TRANSCRIPT_IMPORT finds <id>.jsonl under <account home>/.factory/sessions. It tries the workspace's own encoded folder first, then the workspace's sub-folders, then every other folder by name.
  • decodeDroidTranscriptLine turns Droid's records into chat messages:
    • It reuses the Claude-style content-block parser, since Droid writes the same text/tool_use/tool_result shapes.
    • It drops user_only and llm_only records and reasoning.
    • It strips the [Process exited with code N] line from Execute output, the same way the live Droid dialect does.
  • Adoption reads Droid's session_start record for the session id and cwd. A conversation from another folder is refused, and one from a sub-folder opens in that sub-folder.
  • Antigravity and Droid now share one record-id import helper. The isFile helper that Hermes and Antigravity each carried a copy of now lives in one place.

Why

Droid's ACP session/load only reopens a session from the folder it was saved in. Loading from any other folder fails with "Folder is not trusted". That's why the folder check reads session_start.cwd and launches the chat there, instead of always using the workspace root.

Importing the transcript, as every other adopting agent does, beats relying on Droid's session/load replay. The chat history then goes through the same journal import, retention bounds and identity checks as everyone else's, and no Droid-specific replay handling is needed.

Linked Issue

Fixes #49905

Visual Proof

Before, the Droid row's menu had Resume in Worktree, Copy Resume Command and Hand off to agent, but no "Resume in New Chat" (see the issue).

After, the Droid row offers "Resume in New Chat":

droid-resume-in-new-chat-menu.png

A terminal-started Droid session opened as a chat. Its earlier turns are shown, including the pwd tool run, and the new message continued the same session:

droid-adopted-chat-continues.png

A session saved in ws/sub, opened from the ws workspace. Asked to run a tool, Droid's pwd printed /private/tmp/droid49905/ws/sub, so it resumed in its own folder:

droid-subfolder-chat-runs-in-subfolder.png

Testing

macOS only, droid 1.21.1.

  • Real Droid sessions, no model spend: a custom model in an isolated FACTORY_HOME_OVERRIDE pointed at a local fake chat-completions server, so Droid wrote genuine session files, with text turns and an Execute tool call.
  • Hidden dev build (ORCA_BACKGROUND_LAUNCH=1, isolated profile) driven over CDP:
    • Session History listed the rows, and "Resume in New Chat" opened the chat with its history.
    • A new message continued the same .jsonl; no new session was created.
    • The sub-folder session resumed in its sub-folder.
  • Probed Droid's ACP directly:
    • session/load from the recorded folder works, including through the /tmp → /private/tmp alias.
    • session/load from the parent folder is refused.
  • Import checks against the real files: a wrong folder and a mismatched session id are refused, and the import does one JSON parse per line.
  • pnpm check:changed passes.

Not run: Linux, Windows, SSH. Session History's resume-in-chat is local and runtime-host only; SSH and WSL rows are blocked by the existing eligibility check.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below
  • Every added test fails without this change and avoids the test anti-patterns

One decoder test, built from real Droid record shapes. It fails if the hidden-record filter is removed, which would put Droid's injected system reminders into the chat.

Performance

None on any hot path. All of this runs only when someone opens a Droid conversation as a chat, or on a usage-limit recovery read:

  • Lookup is one stat when the session is in the workspace's own folder. Otherwise it's one listing of ~/.factory/sessions, then one stat per folder until it hits.
  • The import parses each line once.

Nothing runs per hook event or per mounted row.

Risk

Level: Low

The risky part is the folder check: if it picked the wrong folder, Droid would refuse to load and the chat would fail to open. It is covered for the workspace root, a sub-folder, and a symlink alias.

A new client paired with an older remote host still shows "Continue in chat" for a Droid terminal, because the host capability isn't per agent. The older host then refuses after the terminal closes. Hermes and Antigravity have the same gap today. A plain revert removes the feature, and chats already opened keep working as normal Droid chats.

AI Disclosure

Review

Reviewed in three rounds by two independent reviewers and a perf pass. Fixed from that review:

  • Folder lookup now tries the workspace's own folder first.
  • The import parses each line once.
  • An over-long encoded folder name falls back to the scan.

Left as follow-ups because they live in the shared adoption path, not in Droid's part:

  • The import reads the whole file before trimming to the newest history.
  • An abort doesn't stop a pending read.
  • The ownership check on reservation scans every saved conversation.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • Security: the session id is checked against a strict pattern before it goes into a path, and every result is admitted against the store's real path.
  • Windows: folder names are matched by name with a full-scan fallback, so a different cwd encoding is still found.
  • Mobile: no mobile code or wire change.
  • Older Droid versions that wrote to ~/.factory/projects aren't searched. Droid 1.21.1 writes only to sessions.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change adds Droid transcript discovery and decoding, connects transcript import to journal adoption, and enables Droid conversations in the adoption and resume paths. It also adds a shared transcript-file check for Antigravity and Hermes and moves Antigravity record-ID imports to shared processing.

Merge Risk: Low · up to 64ce7

Resuming a Droid session in chat can fail to find the session if an unrelated folder in the Droid session store is unreadable. The impact is limited to this edge case and has a simple fix. The rest of the change looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat(droid): open Droid sessions from Session History in a chat" matches the main change. The PR adds a "Resume in New Chat" action for Droid Session History rows and a "Continue in chat" a…
Description check Passed The description follows the repository template. It has an ELI5 section, a What Changed section with before and after behavior and the mechanism, a Why section explaining the folder-check and transcri…
Linked Issues check Passed Directly linked issue #49905 has three coding objectives. The PR implements each one.

1. Offer "Resume in chat" for externally started Droid sessions: droid: ['droid'] is added to `CLI_CONVERSATION…
Out of Scope Changes check Passed Each changed file supports the Droid import, its adoption, or a shared helper that the Droid path needs.

- droidShellResult (droid-dialect.ts): the export and rename let the Droid import strip the …
Full details: Title check

Explanation

The title "feat(droid): open Droid sessions from Session History in a chat" matches the main change. The PR adds a "Resume in New Chat" action for Droid Session History rows and a "Continue in chat" action for running Droid terminals, backed by a Droid transcript importer and record-ID import helper. The title is concise, specific, and follows a conventional commit style.

Full details: Description check

Explanation

The description follows the repository template. It has an ELI5 section, a What Changed section with before and after behavior and the mechanism, a Why section explaining the folder-check and transcript-import choices, a Linked Issue (Fixes #49905), Visual Proof with screenshots, a Testing section with manual steps and platforms, a Performance section, a Risk section with level and revert path, Notes, and a Checklist. The AI Disclosure section is empty, and the final lint/typecheck/test/build checklist item is unchecked. Those gaps are minor for a mostly complete description.

Full details: Linked Issues check

Explanation

Directly linked issue #49905 has three coding objectives. The PR implements each one.

  1. Offer "Resume in chat" for externally started Droid sessions: droid: ['droid'] is added to CLI_CONVERSATION_ADOPTING_AGENTS (structured-agent-cli-conversation-adoption.ts). aiVaultSessionResumeInChatWorkspaceMatters treats Droid as workspace-dependent. DROID_LAUNCH_SPEC uses DROID_TRANSCRIPT_IMPORT instead of null, which removes the host refusal the issue describes.

  2. Render prior turns: DROID_TRANSCRIPT_IMPORT finds &lt;id&gt;.jsonl under .factory/sessions. decodeDroidTranscriptLine maps text, tool_use, and tool_result records to chat messages. It drops user_only and llm_only records and reasoning. prepareDroidImport and prepareRecordIdTranscriptImport feed these messages into the journal import. A decoder test covers these record shapes.

  3. Continue the same session: adoption reads session_start for the session id and cwd, then reopens the chat over ACP. The author reports manual testing with real Droid 1.21.1 files. New turns appended to the same .jsonl, and no new session was created.

The issue also asks that the chat keep the fresh-chat permission mode and model behavior. The summary does not show a permission-mode check. The reopen path reuses the existing Droid launch spec, and the summary shows no change there beyond the transcript import. This review did not inspect that path, so this detail is not separately verified. It does not show a gap. Automated coverage is one decoder test. Folder lookup, adoption refusal, and the session-id check are verified by the author's manual and probe tests, not by committed tests.

Full details: Out of Scope Changes check

Explanation

Each changed file supports the Droid import, its adoption, or a shared helper that the Droid path needs.

  • droidShellResult (droid-dialect.ts): the export and rename let the Droid import strip the [Process exited with code N] line. Parsing is unchanged.
  • DROID_LAUNCH_SPEC (droid-acp-launch-spec.ts): one-line change that enables the import. This is the core of the feature.
  • DROID_TRANSCRIPT_IMPORT (droid-transcript-import.ts): folder lookup and session-id pattern check. Both are needed for the Droid path.
  • isTranscriptFile (transcript-file-presence.ts): replaces the duplicated isFile helpers in Hermes and Antigravity. This is a refactor with no new behavior for those agents.
  • prepareRecordIdTranscriptImport (journal-record-id-import.ts): shared record-ID import flow. Antigravity now delegates to it. This changes Antigravity internals. The author states the intended behavior is unchanged. This review did not read the Antigravity diff line by line, so that claim rests on the summary.
  • adopted-transcript-source.ts: adds Droid session_start identity parsing and folder-checked transcript agent status. Droid is included in the existing folder validation.
  • journal-legacy-import.ts, journal-droid-import.ts: route droid to the new import path.
  • ai-vault-session-resume-in-chat.ts: adds a comment and Droid to the workspace-dependent check.

No unrelated feature or agent behavior was found in the summary. The shared-helper changes are disclosed in the PR description and are listed as follow-ups where they touch the shared adoption path.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f5f34a6d-0070-4fde-b3b0-ae1955399f2f
Commits

Reviewing files that changed from the base of the PR and between aac82ec and 64ce714.

Files selected for processing: 3

  • src/main/native-chat/agent-session-journal/history-import/adopted-transcript-source.ts
  • src/main/native-chat/agent-session-journal/history-import/journal-droid-import.ts
  • src/main/native-chat/agent-session-journal/history-import/journal-legacy-import.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@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: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3973b0d5-b722-4452-bcce-b30db9eea36c
Commits

Reviewing files that changed from the base of the PR and between 8ea596d and 910fad9.

Files selected for processing: 15

  • src/main/acp/acp-dialects/droid-dialect.ts
  • src/main/antigravity/antigravity-transcript-import.ts
  • src/main/droid/droid-acp-launch-spec.ts
  • src/main/droid/droid-transcript-import.ts
  • src/main/hermes/hermes-transcript-import.ts
  • src/main/native-chat/agent-session-journal/history-import/adopted-transcript-source.ts
  • src/main/native-chat/agent-session-journal/history-import/journal-antigravity-import.ts
  • src/main/native-chat/agent-session-journal/history-import/journal-droid-import.ts
  • src/main/native-chat/agent-session-journal/history-import/journal-legacy-import.ts
  • src/main/native-chat/agent-session-journal/history-import/journal-record-id-import.ts
  • src/main/native-chat/transcript-decoding/transcript-line-decoders-droid.test.ts
  • src/main/native-chat/transcript-decoding/transcript-line-decoders-droid.ts
  • src/main/native-chat/transcript-discovery/transcript-file-presence.ts
  • src/renderer/src/components/right-sidebar/ai-vault/session-actions/ai-vault-session-resume-in-chat.ts
  • src/shared/agent-session/view/structured-agent-cli-conversation-adoption.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

folders.sort((a, b) => rank(a.name) - rank(b.name))
for (const folder of folders) {
const path = join(store, folder.name, file)
if (folder.isDirectory() && folder.name !== encoded && (await isTranscriptFile(path))) {

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.

Minor · Functional Correctness · Quick win

Skip unreadable unrelated folders during the Droid transcript scan.

When the workspace-folder shortcut misses, the scan calls isTranscriptFile on every other folder in .factory/sessions. isTranscriptFile rethrows any error except ENOENT and ENOTDIR. If an unrelated folder is unreadable, for example with EACCES, the scan stops at that folder. A readable session in a later folder is then not found. Recovery treats this as "could not locate" and does not reopen the chat. Adoption propagates the rejection unless the caller has an explicit matched transcript path. The shortcut at line 25 already tolerates this error. Apply the same per-candidate tolerance to the scan so an unrelated folder cannot abort the lookup. Keep the handling of a missing store unchanged.

Suggested fix

--- "a/src/main/droid/droid-transcript-import.ts"
+++ "b/src/main/droid/droid-transcript-import.ts"
@@ -38,7 +38,11 @@
     folders.sort((a, b) => rank(a.name) - rank(b.name))
     for (const folder of folders) {
       const path = join(store, folder.name, file)
-      if (folder.isDirectory() && folder.name !== encoded && (await isTranscriptFile(path))) {
+      if (
+        folder.isDirectory() &&
+        folder.name !== encoded &&
+        (await isTranscriptFile(path).catch(() => false))
+      ) {
         return path
       }
     }
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
if (folder.isDirectory() && folder.name !== encoded && (await isTranscriptFile(path))) {
if (
folder.isDirectory() &&
folder.name !== encoded &&
(await isTranscriptFile(path).catch(() => false))
) {

@AmoabaKelvin
AmoabaKelvin force-pushed the open-droid-sessions-in-chat branch from aac82ec to 64ce714 Compare November 27, 2026 21:38
@AmoabaKelvin
AmoabaKelvin merged commit 22e63d5 into main Nov 27, 2026
57 checks passed
@AmoabaKelvin
AmoabaKelvin deleted the open-droid-sessions-in-chat branch November 27, 2026 22:07
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.

[Feature]: Open existing Droid sessions in a chat from Session History

1 participant