Skip to content

fix(media): isolate outputs by run generation#36

Merged
kitlangton merged 1 commit into
mainfrom
fix/run-scoped-media
Jul 19, 2026
Merged

fix(media): isolate outputs by run generation#36
kitlangton merged 1 commit into
mainfrom
fix/run-scoped-media

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Isolate screenshots and recordings beneath a persistent run and restart-generation namespace:

<media-root>/<run-id>/generation-0/result.png
<media-root>/<run-id>/generation-1/result.png

Named outputs can no longer overwrite media from another run or from an earlier restart of the same run.

Before / After

Before: Every instance received the same media root. Two runs writing result.png targeted the same file. Restarting a scripted run also reused that path, silently replacing the earlier screenshot. Artifact IDs used only six UUID characters, so persistent output directories could eventually collide even if they were used as namespaces.

After: Artifact directories use full UUIDs. Each instance derives a media directory from that run ID, and each restart advances to a fresh generation directory. The selected path is injected when each OpenCode process is spawned, so servers and TUIs in one generation agree while later generations cannot overwrite earlier media. Runs that produce no media leave no empty output directory.

How

  • Derive media roots from the canonical artifact root and full artifact run ID.
  • Track the current media generation inside OpenCodeInstance and advance it atomically during restart.
  • Bind OPENCODE_DRIVE_MEDIA_DIR per process spawn instead of freezing it in the base environment.
  • Cover concurrent instances writing the same screenshot name and scripted restarts writing the same name across generations.
  • Document the new output layout and include a minor Changeset.

Scope

  • Artifact cleanup remains unchanged; completed media remains available after run artifacts are pruned.
  • This changes only generated media paths. Capture frame artifacts and catalog output are unaffected.
  • It does not add media retention or garbage-collection policy.

Testing

  • bun run check
  • bun run test: 158 Effect tests, 52 CLI integration tests, and 28 catalog tests passed.
  • Focused start, recording, concurrent-instance, manual-TUI, restart, and interrupted-finalization tests passed.
  • bun pm pack --dry-run: 94 expected package files.
  • Live multi-tool probe passed against OpenCode v2 at f05d2ab551; real screenshots were created under <run-id>/generation-0/.

Flow

sequenceDiagram
  participant Drive
  participant Gen0 as OpenCode generation 0
  participant Gen1 as OpenCode generation 1
  participant Media

  Drive->>Gen0: spawn with run-id/generation-0
  Gen0->>Media: write result.png
  Drive->>Gen0: stop for restart
  Drive->>Gen1: spawn with run-id/generation-1
  Gen1->>Media: write result.png
  Note over Media: both files remain independently addressable
Loading

@kitlangton
kitlangton merged commit 4e0c002 into main Jul 19, 2026
1 check passed
@kitlangton
kitlangton deleted the fix/run-scoped-media branch July 19, 2026 18:54
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.

1 participant