Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): resolve local media linked from remote threads #10619

Mergedmaria-rcksmerged 3 commits intomain fromrefs/pull/10619/headmerged by maria-rcks View on GitHub

maria-rckscommented

remote threads try to load desktop images and recordings from the remote server, where the files may not exist. desktop now retries eligible missing absolute media paths against its local server. remote files retain priority; relative paths and authorization failures do not fall back. previews refresh when the local server reconnects.

validation: 74 focused signing/rpc/asset/query tests passed before simplification; 46 focused asset/query tests, client-runtime/web typechecks, and scoped lint passed on this head. github checks pass.

e2e: real linux electron client, two independently authenticated servers, and a seeded remote conversation. filesystem permissions made the media inaccessible to the remote server and readable by the desktop server. image rendering and full-size preview, eight-second video playback, seeking to four seconds, and retry after restoring a missing video passed. checked light/dark appearance and 1100×780 / 1200×1100 viewports. the mac-specific setup remains untested.

before: base client asset wiring, same thread and files.

before: remote thread cannot load local image or video

after: current head, image loaded and video seeked to 0:04.

after: local image and video render in the remote thread

eight seconds of desktop video playback through local fallback

model: gpt-6. harness: codex.

Note

Fix local media resolution for remote threads via local environment fallback

  • Adds direct asset URL issuance for absolute media-file paths in the assetsCreateUrl websocket RPC handler in ws.ts, so absolute media can be served without resolving a workspace for the referenced thread.
  • Updates createAssetEnvironmentAtoms in assets.ts to retry eligible absolute media-file requests against a distinct configured local environment after asset-not-found, asset-inspection, or workspace-context errors, rewriting the result against the local HTTP base URL.
  • Supplies the connected primary Electron environment as the local media fallback in assets.ts, and refreshes media queries when that fallback context changes.
  • Adds integration tests in server.test.ts and parameterized fallback tests in assets.test.ts.
  • Behavioral Change: media URL queries now perform an additional local-environment retry for absolute paths with recognized media extensions when the target environment returns specific workspace-resolution failures; non-media and relative paths are unaffected.
Macroscope summarized 20bd171.

Summary by CodeRabbit

  • Bug Fixes
    • Media assets using absolute paths now generate valid URLs even when no local thread workspace is available.
    • Improved media URL resolution across local, remote, reconnecting, and foreign-thread environments.
    • PNG and MP4 assets now return the expected content types and file data.
    • Relative media paths continue to report clear workspace-context errors when required context is unavailable.
    • Added support for Windows-style absolute media paths and filenames containing literal special characters.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Effect Service Conventions found one blocking issue: packages/client-runtime/src/state/assets.ts imports Effect services directly instead of preserving their module namespaces. An inline review comment includes the expected fix.

      Posted via Macroscope — Effect Service Conventions
    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 20bd171

      Macroscope's review found this PR approvable — This is a narrowly scoped asset-resolution bug fix: remote-thread media failures can retry against the connected local Electron server, while relative paths, authorization failures, and existing successful paths remain unchanged. The production changes reuse the existing signed asset endpoint and are backed by focused fallback, reconnect, and server integration tests.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Path: .coderabbit.yaml

      Review profile: CHILL

      Plan: Team

      Run ID: 7120bb80-5c06-446c-aa67-d7b90cf2ef32

      📥 Commits

      Reviewing files that changed from the base of the PR and between 8616ceff53f343c4dd067ccfcfea9da26560b27d and 20bd171350f2d0026f262ddc8fce4b80ae6c4f67.

      📒 Files selected for processing (4)
      • apps/web/src/state/assets.ts
      • packages/client-runtime/src/state/assets.test.ts
      • packages/client-runtime/src/state/assets.ts
      • packages/client-runtime/src/state/runtime.ts

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


      📝 Walkthrough

      Walkthrough

      The change adds direct server handling for absolute media paths and client fallback through a local media environment. It wires the web state to the primary Electron connection and adds integration and parameterized coverage.

      Changes

      Media asset URL resolution

      Layer / File(s)Summary
      Server absolute-path handling
      apps/server/src/ws.ts, apps/server/src/server.test.ts
      assetsCreateUrl issues URLs directly for absolute media-file paths. Tests cover PNG and MP4 responses, file contents, and relative-path errors.
      Client media fallback
      packages/client-runtime/src/state/runtime.ts, packages/client-runtime/src/state/assets.ts, packages/client-runtime/src/state/assets.test.ts
      Asset URL queries inspect request results, retry eligible media requests through a local environment, and re-evaluate after reconnects. Tests cover environment selection, fallback, and error cases.
      Web local environment wiring
      apps/web/src/state/assets.ts
      The web state derives a local media environment from the primary Electron connection and passes it to asset environment atoms.

      Estimated code review effort: 3 (Moderate) | ~25 minutes

      Merge Risk: ⚪ Minimal · up to 20bd1

      Desktop media previews now retry eligible missing absolute paths through the local server while preserving remote success, relative-path behavior, and authorization failures. No concrete merge-blocking risk remains.

      Sequence Diagram(s)

      sequenceDiagram
        participant Client
        participant RemoteEnvironment
        participant EnvironmentRegistry
        participant LocalEnvironment
        Client->>RemoteEnvironment: Request assetsCreateUrl
        RemoteEnvironment-->>Client: Return URL or workspace error
        Client->>EnvironmentRegistry: Select fallback environment
        EnvironmentRegistry->>LocalEnvironment: Request assetsCreateUrl
        LocalEnvironment-->>Client: Return local-origin URL

      Suggested reviewers: juliusmarminge, stienswout, t3dotgg

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 6 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Title check✅ PassedThe title clearly and concisely describes the primary change: resolving local media for remote threads in the desktop client.
      Description check✅ PassedThe description clearly explains what changed, why it changed, fallback behavior, validation results, UI evidence, and known test limitations. It does not use the template headings or include the chec…
      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Comment `@coderabbitai help` to get the list of available commands.
    5. maria-rcks merged thisa01b227

    6. maria-rcks closed this

Sign in to join this conversation.