Skip to content

refactor: resolve the video size of a context in one place - #5359

Merged
aaltat merged 1 commit into
MarketSquare:mainfrom
aaltat:video-size-once
Oct 17, 2026
Merged

aaltat merged 1 commit into
MarketSquare:mainfrom
aaltat:video-size-once

Conversation

@aaltat

@aaltat aaltat commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #5326; the tests from #5358 guard this change.

The video size of a context was worked out twice: _record_video resolves recordVideo["size"] (size given, else viewport, else 1280x720), and then every route worked it out again for the context cache, each in its own way. Now the resolved size is the one that is cached.

 New Context / New Persistent Context / register_adopted_context
-  context_cache.add(id, _video_size(recordVideo, viewport))   # viewport, or None for adopted
+  if recordVideo: context_cache.add(id, recordVideo["size"])  # resolved by _record_video

 _record_video(record_video, viewport)
   size = _video_size(record_video, viewport)                  # the only caller left
  • A context without a video caches no size. Only _embed_video reads the cache, and it returns before reading it when there is no video_path; Node sends video_path: null for a context that does not record.
  • Types: the video dict Node returns ({video_path, contextUuid}) is ContextVideo in data_types.py, next to the other internal TypedDicts; _video_size and _record_video take RecordVideo and ViewportDimensions instead of Mapping[str, Any].

Evidence

  • Before: new_context(viewport=...) without a video caches 800x600 for a context that never embeds a video.
    After: test_context_without_video_caches_no_video_size (written red first): no cache entry for New Context, New Persistent Context or an adopted context without a video.
  • The test: guard the adopted context options and video sizes before unifying them #5358 tests pass unchanged: each route caches 800x600 from its viewport and 640x480 from an explicit size, and the embedded video uses it. utest/test_get_video_size.py passes {} instead of None (the narrower signature); its approved output is unchanged.
  • inv utest: 857 passed. inv atest suites Video, Persistent State, Tracing Groups, 05 JS Tests: all passed.

Merge Danger

Door: two-way

Blast Radius: small

register_adopted_context now reads options["recordVideo"]["size"], which adopted_context_options always fills (its docstring says options come from there). Options built by hand with a recordVideo without size get a KeyError instead of a 1280x720 fallback. The Electron library passes the options of adopted_context_options unchanged.

🤖 Generated with Claude Code

_record_video already resolves recordVideo's size from the size given,
the viewport or 1280x720. New Context, New Persistent Context and
register_adopted_context worked it out again with _video_size for the
context cache, each in its own way. They now cache the resolved size,
and a context without a video caches none, since only an embedded video
reads it.

The video dict that Node returns and _embed_video reads is typed as
ContextVideo, and _video_size and _record_video take RecordVideo and
ViewportDimensions instead of mappings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aaltat
aaltat marked this pull request as ready for review October 17, 2026 18:16
@aaltat
aaltat merged commit 4a14128 into MarketSquare:main Oct 17, 2026
30 checks passed
@aaltat
aaltat deleted the video-size-once branch October 17, 2026 18:49
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