Skip to content

feat(mobile): open Chat artifact paths and share supported media - #25882

Open
suharvest wants to merge 23 commits into
stablyai:mainfrom
suharvest:split/mobile-files
Open

suharvest wants to merge 23 commits into
stablyai:mainfrom
suharvest:split/mobile-files

Conversation

@suharvest

@suharvest suharvest commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Paths in Chat open the phone file viewer. Chat artifacts, text/image/HTML previews, main-player media previews, and supported external media use the file path authorized by the host. External media is downloaded to the app cache and handed to the system share sheet.

What Changed

  • Recognize generated artifact extensions and reuse the mobile preview routes.
  • Render supported text, image and HTML previews through existing host file RPCs.
  • Download supported PDF/audio/video media for system sharing, with workspace-scoped cache names and unmount cancellation.
  • Validate canonical base64, decoded byte counts, request bounds and EOF; compare file size, modification time and available change time before and after downloading. Share only a complete, unchanged file.
  • Reset the download state when switching files and ignore progress, errors and completion from cancelled attempts.
  • Keep the lockfile change to the [email protected] package addition required by the feature.

Why

Reuse the file viewer, main-player route, chat-artifact route, and host authorization instead of introducing separate readers. The system share sheet handles media that needs another app. This builds on OS handoff work from #21839 by @dudupii.

Linked Issue

Fixes #25871.

Visual Proof

BEFORE/AFTER

Captured on an Android emulator with a fixed local RPC fixture; BEFORE/AFTER are successive states in this workflow.

BEFORE: the native Android Files chat with the file list expanded, then the media preview before invoking share.

Files chat before opening a file Media preview before sharing

AFTER: the native Android text preview, image preview and system share chooser after the file actions.

Source composite for this historical UI evidence: e263d278b47dd6943f3f7f78d5b79cec5cbcb93e.

Text file preview after opening it Image file preview after opening it System share chooser after selecting media

Evidence: debug APK SHA-256 d607ae55d0c0dfc0a19d76ce60e88ff4898c863db416039f9d225437170c5604, source composite e263d278b47dd6943f3f7f78d5b79cec5cbcb93e, emulator emulator-5566.

Recorded media playback and system handoff

Recorded media playback and system handoff evidence from source 1a9bcb624876360782350fd18df66f80ab306911 and debug APK SHA-256 d607ae55d0c0dfc0a19d76ce60e88ff4898c863db416039f9d225437170c5604:

WAV player at 0:01 of 0:01 with the external-open footer visible Native WAV system share chooser

Android PDF share evidence recorded at da8e98d8df77333edb83472bf6d2b53acb89a9a6: the system chooser opened for a cached 592-byte PDF 1.4, one page, with SHA-256 d82eb405dcd4a53f4272fd4f1c25023453e5ef0a9648a85b36ce690a3192b3aa matching the fixture. Runtime: cold Metro bundle from da8e98d8df77333edb83472bf6d2b53acb89a9a6; existing debug-shell APK SHA-256 d607ae55d0c0dfc0a19d76ce60e88ff4898c863db416039f9d225437170c5604 and source composite.

Android system share chooser for the verified PDF fixture

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Validated after merging main 398cb846ff16a5abfb9350309842c16a3fe8148a; current head 4d77656d19bc1529e4c2be42f120261961d664db.

  • External media handoff, file-switch cancellation, preview navigation and retry: 44 tests across 4 files, passed. Download validation checks EOF, decoded bytes and size/mtime/ctime before sharing.
  • Mobile production typecheck, mobile test-typecheck ratchet and root pnpm tc:node: exit 0.
  • Changed-code quality since the merged main: zero new findings. Max-lines and runtime-electron ratchets: exit 0.

Independent review checked the scope cleanup and merge resolution.

AI Disclosure

Codex assisted with implementation, review and validation, including GPT-6 family/Codex and GPT-5.6-Luna workers.

Review

Independent review checked file-state validation, cache ownership, cancellation boundaries, identity changes and existing player compatibility.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

This change does not copy or mechanically translate upstream skill-installer material.

Notes

  • Security: previews and media downloads continue through host file RPC authorization; cache names are workspace-scoped and unmount cancellation is retained.
  • Cross-platform support (Linux, Windows, Mac): mobile typecheck, changed-code quality and the required test gates cover the shared file-preview implementation.
  • Remote SSH: previews and media handoff use host file RPC authorization.
  • Mobile: focused regression results and versioned Android interaction evidence are listed above.
  • General backwards compatibility: existing preview routes and host authorization are reused; the lockfile adds only [email protected] relative to base.
  • Performance: media handoff uses workspace-scoped cache cleanup and unmount cancellation.

Author

X: @SuHarvest

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)
  • 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)

Local validation commands, test results and Android screenshots are listed above.

@suharvest
suharvest marked this pull request as ready for review October 7, 2026 00:32
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a06f705-9dad-4db2-b57e-baefac06450b



📥 Commits

Reviewing files that changed from the base of the PR and between da8e98d and 4cddd2a.




⛔ Files ignored due to path filters (1)
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml



📒 Files selected for processing (6)
  • mobile/src/files/MobileFileMediaHandoff.test.tsx
  • mobile/src/files/MobileFileMediaHandoff.tsx
  • mobile/src/files/file-preview-reply-schema.ts
  • mobile/src/files/mobile-file-media-handoff.test.ts
  • mobile/src/files/mobile-file-media-handoff.ts
  • mobile/src/files/mobile-file-preview-operations.ts



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





📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

Mobile artifact detection and preview eligibility now include supported image, log, PDF, audio, and video paths. The mobile app downloads supported worktree media in validated chunks to a cache file and shares it through the system share sheet. The preview UI handles connection, progress, cancellation, and download errors. Several unrelated source and test edits only change formatting.





Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 4cddd

Mobile Chat can now open artifact paths and share PDF, audio, and video files through the system share sheet. Downloads are validated, size-bounded, and cancellable. No outstanding issues block merging.

Pre-merge checks | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check Warning The mobile changes support [#25871]. The whole-PR summary also identifies formatting-only changes with no behavior change in `src/main/native-chat/agent-session-wire/structured-agent-session-queued-mu… Remove the unrelated formatting-only changes from the pull request, or provide a concrete implementation connection to [#25871] for each file.
Docstring Coverage Warning Docstring coverage is 25.93% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 27 functions across 23 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check Passed The PR satisfies the coding requirements in [#25871]. It adds artifact-path detection for image, text, PDF, audio, and video files. It reuses the existing mobile preview routes and host file RPCs for …
Title check Passed The title clearly and concisely describes the main change: opening Chat artifact paths on mobile and sharing supported media.
Description check Passed The description is complete and follows the repository template. It explains the user impact, implementation, rationale, linked issue, visual proof, testing, AI disclosure, compatibility consideration…

Full details: Out of Scope Changes check

Explanation

The mobile changes support [#25871]. The whole-PR summary also identifies formatting-only changes with no behavior change in src/main/native-chat/agent-session-wire/structured-agent-session-queued-mutations.ts, src/relay/agent-exec-disposal.test.ts, src/renderer/src/components/native-chat/NativeChatComposer.tsx, src/renderer/src/components/native-chat/NativeChatInterruptedContinue.test.tsx, and src/main/runtime/structured-agent-launch-support.ts. These changes have no concrete connection to artifact previews or media handoff.


  • Fix all pre-merge checks with AI
  • Autopilot · 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

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


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4e56e076-22cd-4efb-9c5e-af49766e9a25
📥 Commits

Reviewing files that changed from the base of the PR and between 7faa9f7 and 5216130.

⛔ Files ignored due to path filters (1)
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (16)
  • mobile/package.json
  • mobile/src/components/markdown-file-path-artifact-extensions.test.ts
  • mobile/src/components/markdown-file-path-detection.ts
  • mobile/src/files/MobileFileMediaHandoff.test.tsx
  • mobile/src/files/MobileFileMediaHandoff.tsx
  • mobile/src/files/MobileFilePreviewScreen.tsx
  • mobile/src/files/file-preview-reply-schema.ts
  • mobile/src/files/mobile-file-explorer-row.tsx
  • mobile/src/files/mobile-file-media-handoff-device.ts
  • mobile/src/files/mobile-file-media-handoff.test.ts
  • mobile/src/files/mobile-file-media-handoff.ts
  • mobile/src/files/mobile-file-preview-navigation.test.ts
  • mobile/src/files/mobile-file-preview-navigation.ts
  • mobile/src/files/mobile-file-preview-operations.ts
  • mobile/src/files/mobile-file-preview-retry.test.tsx
  • mobile/src/session/mobile-artifact-kind.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 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.

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

🟡 Minor · Reject a zero-byte EOF after a continued chunk. · mobile-file-media-handoff.ts:121-147

mobile/src/files/mobile-file-media-handoff.ts:121-147
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Reject a zero-byte EOF after a continued chunk.

files.readChunk can return a non-empty chunk with eof: false, then return zero bytes with eof: true after the source shrinks. The downloader treats the zero-byte reply as successful completion, calls sink.release(attempt), and makes the truncated file available for sharing.

Track whether a previous chunk required continuation and discard the transfer when this contradictory terminal sequence occurs.

Suggested fix
+  let sawNonEofChunk = false
+
   ...
       if (chunk.bytesRead === 0) {
+        if (sawNonEofChunk && chunk.eof) {
+          throw new Error('File changed during download')
+        }
         break
       }
       ...
       if (chunk.eof) {
         break
       }
+      sawNonEofChunk = true
🟡 Minor · Reset handoff state when the preview identity changes. · MobileFileMediaHandoff.tsx:42-97

mobile/src/files/MobileFileMediaHandoff.tsx:42-97
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reset handoff state when the preview identity changes.

When relativePath changes on the mounted native preview, the cleanup cancels the old files.readChunk attempt but leaves downloading set. The new handoff therefore renders no Open button, and open returns until the old request settles. Guard stale callbacks before allowing them to change the new file's state.

Suggested fix
   useEffect(() => {
     return () => {
       activeAttempt.current?.cancel()
       activeAttempt.current = null
+      if (mounted.current) {
+        setDownloading(false)
+      }
     }
   }, [client, relativePath, worktreeId])
 
@@
         attempt
       )
@@
         (bytes) => {
-          if (mounted.current) {
+          if (mounted.current && activeAttempt.current === attempt && !attempt.cancelled) {
             setProgressBytes(bytes)
           }
         },
@@
     } catch (error) {
-      if (mounted.current) {
+      if (mounted.current && activeAttempt.current === attempt && !attempt.cancelled) {
         setMessage(error instanceof Error ? error.message : 'Unable to open file')
       }
     } finally {
       if (activeAttempt.current === attempt) {
         activeAttempt.current = null
-      }
-      if (mounted.current) {
-        setDownloading(false)
+        if (mounted.current) {
+          setDownloading(false)
+        }
       }
     }

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 115ae0c8-d3db-4a08-a194-b8ffb344f6ec
📥 Commits

Reviewing files that changed from the base of the PR and between 1a9bcb6 and da8e98d.

⛔ Files ignored due to path filters (1)
  • mobile/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • src/main/runtime/structured-agent-launch-support.ts
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx
  • src/renderer/src/components/native-chat/NativeChatInterruptedContinue.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/native-chat/NativeChatComposer.tsx

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

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Open mobile Chat artifacts and share supported media with the system

1 participant