Skip to content

feat(mcp): pad render_timelines viewport and decouple it from the filter range - #1215

Open
Evin009 wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
Evin009:feat/render-timelines-viewport-padding
Open

Evin009 wants to merge 4 commits into
GoogleCloudPlatform:mainfrom
Evin009:feat/render-timelines-viewport-padding

Conversation

@Evin009

@Evin009 Evin009 commented Nov 4, 2026

Copy link
Copy Markdown

Part of #1193 (item 5)

Summary

buildTimelineRenderRequest set ViewStartTimeMs / ViewEndTimeMs to exactly the same timestamps as FilterStartTimeNs / FilterEndTimeNs. Events at startTime / endTime were half-clipped at the left/right edges of the canvas, and narrowing the log filter also narrowed the viewport, hiding the surrounding revision state bars that give before/after context.

This change:

  • Pads the viewport by 5% of the filter time span on both sides (minimum 1s, so a zero-length range still gets a margin). Padding is only applied when both filter.startTime and filter.endTime are set.
  • Adds optional viewStartTime / viewEndTime inputs (RFC3339) to render_timelines. They set the viewport independently of filter.startTime / filter.endTime and are used as-is without padding. Each side falls back to the padded filter boundary when omitted. viewEndTime must be after viewStartTime.
  • Applies the same 5% padding on /render/timeline when no viewport is sent and the page falls back to the inspection log range.

Testing

  • go test ./pkg/server/mcp/...: updated the existing filter case to expect the padded viewport, added an invalid view range case, and added TestBuildTimelineRenderRequest_Viewport covering no range, padded filter range, zero-length range, open-ended range, explicit view range, and partial explicit view range.
  • timeline-render-smart.component.spec.ts: updated fallback viewport expectations (1000s–2000s header range → 950s–2050s).
  • Manually verified on /render/timeline with a synthetic 30-minute audit log: the returned viewport is 10:00 − 90s to 10:30 + 90s, and events at the first/last log timestamps are no longer clipped at the canvas edges.
…ter range

The rendered viewport used the exact filter time range, so events at
startTime/endTime were half-clipped at the canvas edges and a narrow log
filter hid the surrounding revision context.

- Pad the viewport by 5% of the filter span (min 1s) on both sides.
- Add optional viewStartTime/viewEndTime inputs that set the viewport
  independently of filter.startTime/endTime and are used as-is.
- Pad the fallback log range on the render page when no viewport is sent.

Refs GoogleCloudPlatform#1193 (item 5)

@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 viewport padding (defaulting to 5% of the filter range) to prevent edge events from being clipped during timeline rendering, and adds optional viewStartTime and viewEndTime parameters for explicit viewport control. The review feedback highlights a critical Go compilation error where new is incorrectly called with a value instead of a type, recommending a generic ptr helper function instead. Additionally, the reviewer suggests validating the resolved viewport to prevent inverted ranges when only one boundary is explicitly set, and enforcing a minimum 1-second padding in the frontend to align with the backend's behavior.

Comment thread pkg/server/mcp/workbench_render.go Resolved
Comment thread pkg/server/mcp/workbench_render_test.go Resolved
Comment thread pkg/server/mcp/workbench_render.go Resolved
Evin009 and others added 3 commits November 3, 2026 22:40
- Reject a resolved viewport whose end is not after its start, which
  could happen when only one of viewStartTime/viewEndTime is set and the
  other side falls back to the padded filter boundary.
- Apply the 1s minimum padding on the render page fallback range too,
  matching minRenderViewPadding in the backend.
- Use local variables instead of new(expr) for pointer fields to match
  the surrounding code, and a ptr helper in tests.
new(expr) is valid since Go 1.26, so revert the local-variable and ptr
helper workaround introduced for an incorrect review suggestion.
@kyasbal

kyasbal commented Nov 5, 2026

Copy link
Copy Markdown
Member

Thank you for contributing to this repository.
But I need some more time to review this because there are many local stacking changes around MCP. Features around MCP would change largely in the next few weeks. Once we stabilize these feature a little with testing, I can resume the review and consider merge them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants