Skip to content

bug: workspace canvas panel flickers + charts broken in update_panel #707

Closed

Description

@vybe

Summary

The workspace canvas panel (/agents/:name/workspace) has two related rendering bugs: (1) panel content switches back to the empty/placeholder state mid-session (flickering), and (2) charts rendered via `update_panel` HTML are visually broken or invisible.

Context

Shipped in issue #699 (VOICE-008). The Corbin workspace reference implementation (/Users/eugene/Dropbox/Agents/Corbin20/.claude/skills/agent-workspace/workspace.html) handles both of these correctly and can be used as a reference for fixes.

Root Causes

Bug 1 — Panel flicker / content switching back to default

`fetchPanel()` in `AgentWorkspace.vue` unconditionally overwrites `panelState.value = r.data` on every 300ms poll, even when content has not changed. This causes:

  • Vue re-renders the entire panel on every tick, causing visual flicker.
  • When the voice session ends (or is tearing down), the backend returns the "empty" state (by design — the /panel endpoint returns empty instead of 404 for missing sessions). This empties the panel immediately after the session ends rather than preserving the last agent-written content.
  • For HTML panels that contain Chart.js code, re-rendering on every poll destroys and re-creates chart instances 3x per second.

Fix approach: Track a content version or hash on the frontend; skip re-render if content hasn't changed. Stop the panel poll on session end but preserve the last-rendered content in state (don't reset to empty). See _panelVersion + version-gated renderPanel() in the Corbin reference.

Bug 2 — Charts broken in update_panel HTML

Three compounding issues:

  1. DOMPurify strips <script> tags — sanitizedHtml computed runs DOMPurify.sanitize(content) with default config, which strips all <script> tags. Any Chart.js initialization script is silently removed before Vue injects the HTML via v-html.

  2. v-html doesn't execute scripts — Even if DOMPurify were permissive, Vue's v-html binding does not execute <script> tags found in the HTML. They need to be cloned and re-inserted as live DOM nodes (see _execScripts() in the Corbin reference).

  3. Chart.js not pre-loaded — If the agent includes a CDN <script src> for Chart.js in the HTML string, the _execScripts() approach creates a race condition where the new Chart(...) call fires before the CDN script finishes loading. The fix is to pre-load Chart.js once in the page (as the Corbin reference does via <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script>), then the agent's panel code can call new Chart(...) directly without importing it.

Fix approach:

  • Replace the sanitizedHtml computed + v-html pattern for HTML panels with a method that uses DOMPurify.sanitize(content, { ADD_TAGS: ['script'], ... }) followed by _execScripts(el) to clone and re-inject scripts as live DOM nodes.
  • Pre-load Chart.js once in AgentWorkspace.vue (either in a <script> tag in the <head> equivalent, or injected on mount).
  • Update the WORKSPACE_PANEL_INSTRUCTIONS in services/gemini_voice.py to document that Chart.js 4 is pre-loaded and agents should NOT add CDN script tags.

Acceptance Criteria

  • Panel content does not flicker or reset to placeholder during an active voice session
  • Panel preserves the last agent-written content after the session ends (does not revert to empty placeholder)
  • Chart.js charts rendered via update_panel display correctly without visual artifacts
  • update_panel HTML with <script> tags containing new Chart(...) works correctly
  • Panel only re-renders when content actually changes (version/hash tracking)
  • WORKSPACE_PANEL_INSTRUCTIONS updated to document Chart.js pre-loading rule

Technical Notes

Key files:

  • src/frontend/src/views/AgentWorkspace.vue — fetchPanel(), sanitizedHtml computed, HTML panel rendering
  • src/backend/services/gemini_voice.py — WORKSPACE_PANEL_INSTRUCTIONS constant

Reference implementation: /Users/eugene/Dropbox/Agents/Corbin20/.claude/skills/agent-workspace/workspace.html

  • _panelVersion + version-gated renderPanel() — prevents redundant re-renders
  • _execScripts(container) — re-executes scripts after HTML injection
  • stopPanelPoll() called on session end but content preserved in state
  • Chart.js loaded once at page level; system prompt documents "never add CDN script tag"

Backend note: The /panel endpoint correctly returns empty state (not 404) for missing sessions. No backend changes needed — the fix is entirely frontend.

Complexity: 3 — multi-file frontend fix, no new DB/API surface needed.

Activity

  1. added
    priority-p1
    type-bug
    on May 7, 2026
  2. vybe commented on May 7, 2026

    @vybe
    ContributorAuthor

    /claim

  3. added
    status-in-progress
    on May 7, 2026
  4. github-actions commented on May 7, 2026

    @github-actions

    Claimed by @vybe. Label status-in-progress added.

    Next steps:

    1. Create branch: feature/707-<short-slug>
    2. Implement the feature
    3. Open a PR with Fixes #707
  5. added
    status-in-dev
    and removed
    status-in-progress
    on May 7, 2026
  6. vybe commented on Jun 1, 2026

    @vybe
    ContributorAuthor

    Shipped in v0.6.0 (released via #998).

  7. added
    complexity-low
    theme-ui-ux
    and removed
    status-in-dev
    on Jun 1, 2026
  8. added a commit that references this issue on Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-lowpriority-p1theme-ui-uxtype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions