Skip to content

Open terminal file taps in mobile preview - #6529

Open
MeCKodo wants to merge 4 commits into
stablyai:mainfrom
MeCKodo:codex/mobile-artifact-preview
Open

MeCKodo wants to merge 4 commits into
stablyai:mainfrom
MeCKodo:codex/mobile-artifact-preview

Conversation

@MeCKodo

@MeCKodo MeCKodo commented Jun 28, 2026 •

Copy link
Copy Markdown

Closes #6539

Summary

  • Open resolved terminal file taps directly in the mobile file preview screen.
  • Preserve the existing HTML browser behavior when the host returns an absolute file URL.
  • Add a pure target-selection helper with coverage for source files, images, HTML, ignored paths, and Windows/UNC HTML paths.
  • Extend the mobile mock desktop fixture so terminal output includes artifacts/screenshot.png, and the mock server resolves/serves that image through files.resolveTerminalPath + files.readPreview.

Screenshots

No screenshot attached: this is a mobile routing change and local iOS/Android simulator tooling is unavailable on this machine. Manual-ish protocol validation is listed below.

AI Review Report

Addressed CodeRabbit inline feedback by:

  • Routing HTML terminal taps through handleCreateBrowserRef.current?.(...) to avoid stale browser opener closures.
  • Replacing manual file://${absolutePath} construction with the shared filesystemPathToFileUri helper.
  • Adding Windows drive and UNC path fixtures around HTML file URL formatting.

Security Audit

  • The mobile app still asks the host to resolve terminal paths before opening anything.
  • Host-side files.resolveTerminalPath remains the worktree-boundary gate; this PR does not expand file read permissions.
  • Image/text previews continue to use existing files.readPreview / files.read RPCs.
  • HTML paths are normalized as file URLs through the shared path helper instead of string concatenation.

Test plan

  • cd mobile && pnpm test -- src/session/mobile-terminal-file-tap-target.test.ts src/session/mobile-mock-file-preview-data.test.ts src/files/mobile-file-preview-request.test.ts src/files/mobile-file-preview-navigation.test.ts src/terminal/terminal-path-tap.test.ts
  • cd mobile && pnpm format:check
  • cd mobile && pnpm lint
  • cd mobile && pnpm exec tsc --noEmit
  • pnpm exec vitest run --config config/vitest.config.ts src/main/runtime/rpc/methods/files.test.ts
  • git diff --check

Manual-ish validation

  • Started the mock desktop server on PORT=7678 pnpm mock-server.
  • Connected with a real encrypted WebSocket handshake using the mock server public key and mock-device-token.
  • Sent files.resolveTerminalPath for artifacts/screenshot.png and verified it resolved to a worktree-relative file.
  • Sent files.readPreview for the resolved path and verified it returned a PNG image preview payload.

Notes

  • Local iOS Simulator testing was not possible on this machine because only Xcode Command Line Tools are installed (xcrun simctl is unavailable). Android emulator tooling is also not installed.
  • I also tried pnpm test -- src/main/runtime/rpc/methods/files.test.ts, but the root script expanded to the full suite and timed out in unrelated src/shared/feature-interactions.test.ts; the narrower file RPC command above passed.

ELI5

On mobile, tapping a file path in the terminal opens it in the mobile file preview (images, source, etc.) instead of only handling special HTML cases.

@MeCKodo
MeCKodo marked this pull request as ready for review June 28, 2026 03:30
@coderabbitai

coderabbitai Bot commented Jun 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

A new MobileTerminalFileTapTarget union type and getMobileTerminalFileTapTarget helper classify mobile terminal file taps as ignore, browser, or preview targets. handleFileTap now uses that helper and routes browser targets to a file:// URL and preview targets to mobile file preview navigation. The mock file-preview RPC data now resolves terminal paths, supports an additional screenshot asset, and the related mock fixture and tests were updated to cover screenshot creation and preview behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: opening terminal file taps in the mobile preview flow.
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.
Description check ✅ Passed The description covers the required sections with a clear summary, tests, security, and notes; only minor template-format gaps remain.

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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e81cbec7-42c1-456c-876b-4c7923c57ef1

📥 Commits

Reviewing files that changed from the base of the PR and between c16aa89 and c3502b0.

📒 Files selected for processing (3)
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/src/session/mobile-terminal-file-tap-target.test.ts
  • mobile/src/session/mobile-terminal-file-tap-target.ts

@AmethystLiang

Copy link
Copy Markdown
Contributor

thx for the PR
will get it in ASAP

@AmethystLiang
AmethystLiang requested review from Jinwoo-H and removed request for AmethystLiang June 28, 2026 19:01
@MeCKodo

MeCKodo commented Jul 4, 2026

Copy link
Copy Markdown
Author

Hey @Jinwoo-H @AmethystLiang 👋

It's been 6 days since this PR was opened and marked ready for review. Just checking in — is there anything blocking the review, or any feedback I should address to help move this forward?

Also noting CodeRabbit flagged two items:

  1. Docstring coverage is at 60% (threshold is 80%) — happy to add those if that's a blocker
  2. Testing section format — let me know if you want me to restructure it

Let me know how I can help get this merged!

@AmethystLiang AmethystLiang assigned OrcaWin and unassigned Jinwoo-H Jul 20, 2026
@AmethystLiang
AmethystLiang requested review from OrcaWin and removed request for Jinwoo-H July 20, 2026 18:43
@nwparker nwparker added the enhancement New feature or request label Jul 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow Orca Mobile to preview agent-generated files from terminal output

5 participants