Repository navigation
Description
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
/panelendpoint 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:
-
DOMPurify strips
<script>tags —sanitizedHtmlcomputed runsDOMPurify.sanitize(content)with default config, which strips all<script>tags. Any Chart.js initialization script is silently removed before Vue injects the HTML viav-html. -
v-htmldoesn't execute scripts — Even if DOMPurify were permissive, Vue'sv-htmlbinding 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). -
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 thenew 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 callnew Chart(...)directly without importing it.
Fix approach:
- Replace the
sanitizedHtmlcomputed +v-htmlpattern for HTML panels with a method that usesDOMPurify.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_INSTRUCTIONSinservices/gemini_voice.pyto 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_paneldisplay correctly without visual artifacts -
update_panelHTML with<script>tags containingnew Chart(...)works correctly - Panel only re-renders when content actually changes (version/hash tracking)
-
WORKSPACE_PANEL_INSTRUCTIONSupdated to document Chart.js pre-loading rule
Technical Notes
Key files:
src/frontend/src/views/AgentWorkspace.vue—fetchPanel(),sanitizedHtmlcomputed, HTML panel renderingsrc/backend/services/gemini_voice.py—WORKSPACE_PANEL_INSTRUCTIONSconstant
Reference implementation: /Users/eugene/Dropbox/Agents/Corbin20/.claude/skills/agent-workspace/workspace.html
_panelVersion+ version-gatedrenderPanel()— prevents redundant re-renders_execScripts(container)— re-executes scripts after HTML injectionstopPanelPoll()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
vybe commentedon May 7, 2026
/claim
github-actions commentedon May 7, 2026
Claimed by @vybe. Label
status-in-progressadded.Next steps:
feature/707-<short-slug>Fixes #707fix(voice): workspace panel flicker + Chart.js rendering in update_pa…
vybe commentedon Jun 1, 2026
Shipped in v0.6.0 (released via #998).
Release: v0.6.1 (#1171)
feat(git-sync): persist pull health; renumber to 0080_pull_sync; docs…
feat(sync-health): sync health on fleet health, the fleet audit over …
feat(git-sync): the container pulls origin on its own (trinity-enterp…