Skip to content

MCP: Enhance render_timelines for agent-authored incident explanation documents #1193

Open

Description

@kyasbal

Background

render_timelines renders KHI resource timelines via headless Chromium (/session/render-timeline) and returns inline mcpsdk.ImageContent (image/png) along with a Markdown summary. While this enables AI agents to visually inspect timelines in their own context window, several capabilities are missing when an agent uses render_timelines to author polished, self-contained incident explanation documents or RCA reports for end users.

Checklist of Enhancements

  • 1. Issue a short-lived HTTP GET URL for rendered timeline PNGs (analogous to request_file_upload / uploadurl) (feat(mcp): issue short-lived HTTP GET URLs for rendered timeline PNGs #1198, interactive scene URL added in feat(mcp): wire stateful scenes, annotations, and dual URLs into render_timelines #1241 / feat(mcp,web): add annotated timeline scenes to render_timelines #1253)

    • Problem: handleRenderTimelines (pkg/server/mcp/workbench_render.go) only returns mcpsdk.ImageContent (Data: pngBytes) and text metadata. MCP clients do not expose the inline base64 payload to the agent's shell or file tools, so the agent cannot embed the rendered image in Markdown (![](...)), save it alongside a report, or upload it to external documents.
    • Proposed Design:
      • Follow the same pattern as request_file_upload (pkg/server/uploadurl): store rendered PNG bytes in an in-memory TTL store and expose a short-lived HTTP GET endpoint (e.g., GET /api/v1/rendered-timelines/<token>.png, with Content-Type: image/png and a 30-minute TTL).
      • Include ImageURL and ExpiresAt in renderTimelinesTemplateData and render them in pkg/server/mcp/templates/render_timelines.md.tmpl so agents can directly embed the URL in Markdown or fetch it via curl.
    • Affected Files:
      • pkg/server/mcp/workbench_render.go, pkg/server/mcp/server.go, pkg/core/init/default/mcp.go
      • pkg/server/mcp/templates/render_timelines.md.tmpl, pkg/server/mcp/testdata/render_timelines.golden.md
  • 2. Support visual annotations, highlights, and time markers (highlightLogIds, highlightTimelineIds, cursorTime, activeTimeRange) (feat(mcp): add timeline scene spec types and named palette registry #1220–feat(web): add row highlight, connector, callout, and deck scene ViewModel #1224, feat(mcp): add multi-window search and structured log excerpt slicer #1231–test(mcp): add stateful scene patch, branch, and CDP overlay integration tests #1242, fix(web): route multi-row evidence deck tethers behind upper cards #1250, feat(mcp,web): add annotated timeline scenes to render_timelines #1253)

    • Problem: TimelineRenderSmartComponent (web/src/app/pages/timeline-render/timeline-render-smart.component.ts) binds empty defaults ([timelineHighlights]="{}", [selectedLogIndex]="-1", [highlightedLogIndexBitset], [timelineChartItemHighlights]="{}", [cursorTimeMS]="undefined", [activeTimeRangeMs]="undefined"). Even when an agent has identified the exact causal log IDs, timelines, and trigger timestamps via get_timeline_logs / get_resource_revisions, it cannot highlight those rows, events, or time ranges in the rendered screenshot.
    • Proposed Design:
      • Extend RenderTimelinesInput and TimelineRenderRequest to accept optional highlight/annotation parameters:
        • highlightTimelineIds ([]string): highlight specific timeline rows (timelineHighlights).
        • highlightLogIds ([]string): highlight specific log events / revisions on the chart (timelineChartItemHighlights / highlightedLogIndexBitset).
        • cursorTime (string, RFC3339): draw a vertical time marker line at a key timestamp (cursorTimeMS).
        • activeTimeRange (startTime / endTime, RFC3339): shade a specific incident window (activeTimeRangeMs).
        • Optional callout/overlay labels for highlighted logs (timelineHoverOverlayRequest).
    • Affected Files:
      • pkg/server/mcp/workbench_render.go
      • web/src/app/pages/timeline-render/timeline-render-smart.component.ts, timeline-render-smart.component.html
      • web/src/app/timeline/components/timeline-frame.component.ts
  • 3. Render a static legend for revision states and event log types / severities

    • Problem: timeline-render-smart.component.html hardcodes [showLegend]="false". Furthermore, TimelineLegendComponent (web/src/app/timeline/components/timeline-legend.component.ts) only displays the legend for a single interactively selected timeline row. In a static PNG without mouse hover, readers cannot tell what revision bar colors/stripes (e.g., PodPhase Ready vs. Pending vs. Terminating, deletion status) or event diamond colors (top half = severity, bottom half = log type) represent.
    • Proposed Design:
      • Add a static, aggregate legend bar (enabled by default or via a showLegend option) to /session/render-timeline that summarizes all revision states, log types, and severities present across the rendered timelines.
    • Affected Files:
      • web/src/app/pages/timeline-render/timeline-render-smart.component.html, timeline-render-smart.component.ts
      • web/src/app/timeline/components/timeline-legend.component.ts
  • 4. Auto-fit left index pane width and hide interactive-only UI controls in static renders (index pane auto-fit in feat(mcp,web): render timeline screenshots at Retina 2x resolution and fit stage dimensions to content #1219 / feat(mcp,web): add annotated timeline scenes to render_timelines #1253; hiding controls open in feat(web): hide interactive-only index controls in timeline renders #1243)

    • Problem:
      • TimelineRenderSmartComponent.INDEX_PANE_WIDTH is hardcoded to 300px (timeline-render-smart.component.ts), and .row-name uses text-overflow: ellipsis (timeline-index.component.scss), truncating long Kubernetes Pod/Node names or replica hash suffixes (...) so readers cannot distinguish instances in the image alone.
      • Interactive-only controls (more_vert context menu button .menu-button and expand/collapse chevrons .expand-button) remain visible in static screenshots, consuming horizontal space in the index pane.
    • Proposed Design:
      • Compute the left index pane width dynamically from the longest rendered resource label (or allow configuring indexPaneWidth), and hide interactive-only buttons (.menu-button, .expand-button) when rendering in /session/render-timeline.
    • Affected Files:
      • web/src/app/pages/timeline-render/timeline-render-smart.component.ts, timeline-render-smart.component.scss
      • web/src/app/timeline/components/timeline-index.component.html, timeline-index.component.scss
  • 5. Add horizontal viewport time padding and decouple viewport range from log filter range

    • Problem: buildTimelineRenderRequest (pkg/server/mcp/workbench_render.go) sets ViewStartTimeMs / ViewEndTimeMs to the exact same timestamps as FilterStartTimeNs / FilterEndTimeNs with zero horizontal margin. Events right at startTime or endTime are half-clipped at the left/right edges of the WebGL canvas, and filtering logs to a narrow window prevents showing surrounding revision state bars for before/after context.
    • Proposed Design:
      • Add automatic horizontal time padding (e.g., 3–5% of the time span on both sides) to ViewStartTimeMs / ViewEndTimeMs, and optionally allow specifying viewStartTime / viewEndTime independently from filter.startTime / filter.endTime.
    • Affected Files:
      • pkg/server/mcp/workbench_render.go
  • 6. Render at high DPI (deviceScaleFactor: 2) for crisp text and WebGL shapes (feat(mcp,web): render timeline screenshots at Retina 2x resolution and fit stage dimensions to content #1219, feat(mcp,web): add annotated timeline scenes to render_timelines #1253)

    • Problem: chromiumTimelineRenderer.RenderPNG (pkg/server/mcp/timeline_renderer.go) calls page.SetViewportSize(width, height) with the default 1.0 scale factor, producing 1x resolution images where small ruler timestamps, chip labels, and WebGL event diamonds appear blurry on high-DPI displays and in slides/documents.
    • Proposed Design:
      • Configure Playwright's DeviceScaleFactor (defaulting to 2.0 or configurable via RenderTimelinesInput) when creating the browser context / page for timeline rendering.
    • Affected Files:
      • pkg/server/mcp/timeline_renderer.go
      • pkg/server/mcp/workbench_render.go

Activity

  1. added
    type:feature
    area:backend-core
    area:frontend
    on Oct 29, 2026
  2. Evin009 commented on Nov 4, 2026

    @Evin009

    hi @kyasbal this PR covers item 5 of #1193 (viewport padding for render_timelines).

    • Pads the rendered viewport by 5% of the filter span (min 1s) so edge events are no longer clipped
    • Adds optional viewStartTime / viewEndTime to set the viewport independently of the log filter
    • Applies the same padding on /render/timeline when no viewport is given
  3. Evin009 commented on Nov 5, 2026

    @Evin009

    I'd like to take item 4 (auto-fit index pane width and hide interactive-only controls in static renders) next, if no one's on it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backend-corearea:frontendtype:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions