Repository navigation
Conversation
…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)
There was a problem hiding this comment.
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.
- 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.
|
Thank you for contributing to this repository. |
Part of #1193 (item 5)
Summary
buildTimelineRenderRequestsetViewStartTimeMs/ViewEndTimeMsto exactly the same timestamps asFilterStartTimeNs/FilterEndTimeNs. Events atstartTime/endTimewere 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:
filter.startTimeandfilter.endTimeare set.viewStartTime/viewEndTimeinputs (RFC3339) torender_timelines. They set the viewport independently offilter.startTime/filter.endTimeand are used as-is without padding. Each side falls back to the padded filter boundary when omitted.viewEndTimemust be afterviewStartTime./render/timelinewhen 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 addedTestBuildTimelineRenderRequest_Viewportcovering 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)./render/timelinewith 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.