Skip to content

feat(mcp,web): render timeline screenshots at Retina 2x resolution and fit stage dimensions to content - #1219

Merged
kyasbal merged 5 commits into
epic/mcp-annotated-timelinefrom
push-smnyokqtuvnn
Nov 5, 2026
Merged

kyasbal merged 5 commits into
epic/mcp-annotated-timelinefrom
push-smnyokqtuvnn

Conversation

@kyasbal

@kyasbal kyasbal commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Background

Screenshots rendered via render_timelines previously used a 1x device scale factor, accepted a caller-supplied width parameter, included internal image dimension metadata in tool responses, and did not await web font readiness before measuring hierarchy labels or capturing frames. This resulted in soft typography on HiDPI displays, truncated resource labels when fixed viewport widths did not fit rendered content, fallback font rendering races, and unnecessary metadata noise for MCP clients.

Approach

  • Retina 2x rendering with 8192px backing-store fallback: Configures headless Chromium capture with deviceScaleFactor: 2 by default, automatically falling back to 1x when either physical dimension would exceed SwiftShader's 8192px WebGL2/Canvas2D backing-store limit, and synchronizes TimelineRulerComponent's canvas backing store with window.devicePixelRatio during TimelineFrameComponent.syncViewportAndInvalidate().
  • Content-fitted stage sizing & width parameter removal: Removes width from render_timelines and render request schemas, and sizes the CSS stage horizontally and vertically to fit rendered timeline rows (timeline-render-sizing.ts and clampNumber in math-util.ts), expanding the left index pane between 300px and 1200px alongside at least a 1280px chart viewport (capped at 4096px CSS width).
  • Web font readiness in CDP bridge: Awaits document.fonts.ready inside window.__khiCDPBridge.timelineRenderer (applyAndMeasure and waitForStableFrame) before measuring text widths or capturing frames.
  • Client-focused tool output: Drops internal image dimension and scale factor metadata from render_timelines.md.tmpl and TimelineRenderResult.

Follow-ups

@kyasbal kyasbal added type:feature New feature or request area:backend-core Core backend frameworks, DAG task runner, and server API labels Nov 4, 2026
@kyasbal
kyasbal requested a review from renamoo as a code owner November 4, 2026 05:28
@kyasbal kyasbal added the area:frontend Web frontend application and UI components label Nov 4, 2026
@kyasbal
kyasbal requested a review from K53 as a code owner November 4, 2026 05:28

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces high-DPI (Retina) rendering support for timeline views. It updates the CDP client to accept a dynamic device scale factor, defaulting to 2x and falling back to 1x for oversized layouts to stay within WebGL limits. The backend rendering pipeline, templates, and tests have been updated to handle and display this scale factor. On the frontend, the timeline ruler component now properly synchronizes its canvas size. There are no review comments provided, so I have no additional feedback to offer.

Comment thread pkg/server/mcp/workbench_render.go Resolved
@kyasbal
kyasbal removed this pull request from stack #1225 November 4, 2026 07:23
@kyasbal
kyasbal added this pull request to stack #1226 November 4, 2026 07:24
Comment thread pkg/server/mcp/timeline_renderer.go Resolved
@kyasbal
kyasbal removed this pull request from stack #1226 November 5, 2026 02:10
@kyasbal
kyasbal added this pull request to stack #1228 November 5, 2026 02:10
Base automatically changed from push-nluysxvwkvtm to epic/mcp-annotated-timeline November 5, 2026 04:18
Comment thread pkg/server/cdp/cdp_test.go Resolved
@kyasbal kyasbal changed the title feat(mcp): render timeline screenshots at Retina 2x resolution Nov 5, 2026
@kyasbal
kyasbal removed this pull request from stack #1228 November 5, 2026 06:07
@kyasbal
kyasbal added this pull request to stack #1245 November 5, 2026 06:08
@kyasbal

kyasbal commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

LGTM

@kyasbal kyasbal added the review:done Maintainer review is complete (LGTM) label Nov 5, 2026
@kyasbal
kyasbal merged commit 0701eb1 into epic/mcp-annotated-timeline Nov 5, 2026
10 of 11 checks passed
@kyasbal
kyasbal deleted the push-smnyokqtuvnn branch November 5, 2026 07:02
Ackberry pushed a commit to Ackberry/khi that referenced this pull request Nov 10, 2026
…gleCloudPlatform#1253)

* feat(khifile): add ResolveStructStringField to read struct fields without unwrap (GoogleCloudPlatform#1227)

* feat(khifile): add ResolveStructStringField to read struct fields without unwrap

* perf(khifile): avoid IndexByte scan in matchFieldKeySegments

* feat(workbench): strip managedFields by default and expose log query metadata (GoogleCloudPlatform#1218)

* feat(workbench): strip managedFields by default and expose log query metadata

* refactor(workbench): return named structs for revision bounds and log query metadata

* test(workbench): use raw string literals for multiline test fixtures

* feat(mcp,web): render timeline screenshots at Retina 2x resolution and fit stage dimensions to content (GoogleCloudPlatform#1219)

* feat(mcp): render timeline screenshots at Retina 2x resolution

* fix(mcp,web): remove width input and size timeline renders to fit content

* fix(mcp,web): drop render image metadata and generalize font loading

* refactor(web): rely directly on document.fonts.ready in timeline renderer

* fix(web): wait for document.fonts.ready in CDP bridge functions

* refactor(mcp,web): extract dedicated MCP timeline render smart component (GoogleCloudPlatform#1244)

* feat(mcp): add timeline scene spec types and named palette registry (GoogleCloudPlatform#1220)

* feat(mcp): add timeline scene spec types and named palette registry

* perf(mcp): replace JSON round-trip with slice cloning in cloneAnnotations

* refactor(mcp): simplify scene spec types and use integer IDs and enums

* fix(mcp): remove width field from timeline scene spec and document

* feat(mcp): add in-memory timeline scene store and patch merging (GoogleCloudPlatform#1221)

* feat(mcp): add in-memory timeline scene store and patch merging

* refactor(mcp): adapt scene store to updated scene spec types

* fix(mcp): drop width merging from timeline scene store

* refactor(mcp): remove unnecessary Stored.clone and cloneDocument

* feat(web): add timeline scene overlay schema and session jump URL opener (GoogleCloudPlatform#1222)

* feat(web): add timeline scene overlay schema and session jump URL opener

* refactor(web): document palette color tokens and unify excerpt line kinds

* refactor(web): promote session URL sync to core service and drop redundant checks

* refactor(web): simplify selection query parameter sync

* feat(web): add marker and span scene ViewModel (GoogleCloudPlatform#1223)

* feat(web): add marker and span scene ViewModel

* fix(web): compute timeline scene stage width from fitted index pane

* refactor(web): split timeline scene ViewModel builders into tested helpers

* refactor(web): split timeline scene types from ViewModel builders and use math-util

* feat(web): add row highlight, connector, callout, and deck scene ViewModel (GoogleCloudPlatform#1224)

* feat(web): add row highlight, connector, callout, and deck scene ViewModel

* test(web): use TimelineExcerptLineKind.CONTEXT in deck scene spec

* feat(web): expand timeline stage width for role badges and evidence deck cards

* refactor(web): extract switch-based connector SVG path builders

* feat(mcp): add multi-window search and structured log excerpt slicer (GoogleCloudPlatform#1231)

* feat(mcp): add multi-window search and structured log excerpt slicer

* fix(mcp): guard rune boundary check and ignore YAML comment lines

* feat(mcp): add unified diff excerpt slicer (GoogleCloudPlatform#1232)

* feat(mcp): add unified diff excerpt slicer

* fix(mcp): render mixed unchanged and skipped diff hunk gaps

* test(mcp): use raw string literals in slice diff tests

* feat(mcp): add timeline anchor and subtree scope resolution (GoogleCloudPlatform#1233)

* feat(mcp): add timeline anchor and subtree scope resolution

* fix(mcp): check search index readiness and auto-include scoped subtrees

* fix(mcp): replace anchor field count with direct boolean check

* test(mcp): use whole-struct want in TestResolveAnchor

* feat(mcp): add marker, span, row highlight, connector, and callout resolver (GoogleCloudPlatform#1234)

* feat(mcp): add marker, span, row highlight, connector, and callout resolver

* test(mcp): update resolve error tests for anchor precedence

* test(mcp): use raw string literals in resolver tests

* feat(mcp): add excerpt card resolver and co-anchor palette inheritance (GoogleCloudPlatform#1235)

* feat(mcp): add excerpt card resolver and co-anchor palette inheritance

* fix(mcp): hoist search index lookup out of log excerpt loop

* feat(web): add timeline scene overlay component (GoogleCloudPlatform#1236)

* feat(web): add timeline scene overlay component

* fix(web): enable hover on non-navigable markers and clean up span borders

* refactor(web): simplify scene overlay class bindings and capture scene with @let

* test(web): add unit tests and Storybook stories for timeline scene overlay (GoogleCloudPlatform#1237)

* test(web): add unit tests and Storybook stories for timeline scene overlay

* refactor(web): import buildTimelineSceneViewModel from scene builder in overlay specs

* feat(web): add timeline evidence deck component (GoogleCloudPlatform#1238)

* feat(web): add timeline evidence deck component

* fix(web): use idiomatic class bindings, direct property access in spec, and update builder imports

* feat(web): add Storybook stories for timeline evidence deck

* refactor(web): capture deck with @let in evidence deck template

* feat(web): add timeline render layout component and Storybook stories (GoogleCloudPlatform#1239)

* feat(web): add timeline render layout component and Storybook stories

* fix(web): bind stage width directly, guard frame readiness, and update builder imports

* refactor(web): capture scene with @let in render layout template

* feat(web): integrate scene overlays and interactive mode into TimelineRenderSmartComponent (GoogleCloudPlatform#1240)

* feat(web): integrate scene overlays and interactive mode into TimelineRenderSmartComponent

* fix(web): extract session ID dynamically, guard destroyed state, and update builder imports

* feat(mcp): wire stateful scenes, annotations, and dual URLs into render_timelines (GoogleCloudPlatform#1241)

* feat(mcp): wire stateful scenes, annotations, and dual URLs into render_timelines

* fix(mcp): return structured ErrorResult on scene store and template failures

* fix(mcp): update interactive URL to /render/mcp-timeline

* test(mcp): add stateful scene patch, branch, and CDP overlay integration tests (GoogleCloudPlatform#1242)

* test(mcp): use whole-struct want in TestResolve_AllLayersAndAutoInclude (GoogleCloudPlatform#1247)

* test(mcp,workbench): use raw string literals for multiline test fixtures (GoogleCloudPlatform#1249)

* fix(web): route multi-row evidence deck tethers behind upper cards (GoogleCloudPlatform#1250)

* fix(web): route multi-row evidence deck tethers behind upper cards

* perf(web): avoid forced layout reads on every render in evidence deck

* test(web): isolate fetch retry tests from leaked background requests (GoogleCloudPlatform#1251)

* test: stabilize flaky Chrome, indexing, and workbench tests (GoogleCloudPlatform#1252)

* test(core): disable Chrome launch in TestDefaultInitializers_Resolution

* test(mcp): scope timeouts per subtest in TestChromeTimelineImageRenderer

* test(api/v1): wait for async indexManager before TempDir cleanup

* test(mcp): ensure deterministic loading state in TestWorkbenchHandler_AcquireWorkbench
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-core Core backend frameworks, DAG task runner, and server API area:frontend Web frontend application and UI components review:done Maintainer review is complete (LGTM) type:feature New feature or request

1 participant