Skip to content

feat(coc): Agents canvas follow-ups — hide toggle without sub-agents + fix overlay scroll#328

Merged
plusplusoneplusplus merged 3 commits into
mainfrom
coc/agents-canvas-followups
Jun 14, 2026
Merged

feat(coc): Agents canvas follow-ups — hide toggle without sub-agents + fix overlay scroll#328
plusplusoneplusplus merged 3 commits into
mainfrom
coc/agents-canvas-followups

Conversation

@plusplusoneplusplus

Copy link
Copy Markdown
Owner

Two follow-up improvements to the Agents canvas (the spatial sub-agent run tree shipped in #326).

1. Hide the Thread/Agents toggle until the chat has sub-agents

feat(coc): hide Thread/Agents toggle until the chat has sub-agents

The Agents canvas is only meaningful once a chat has actually spawned sub-agents, so showing the Thread | Agents toggle on a plain chat was noise. ChatDetail now derives hasSubAgents from the agent-run tree and:

  • hides the toggle when there are no sub-agents (on top of the existing loading/pending/floating guards), and
  • renders from a new effectiveView (= view only when sub-agents exist, otherwise thread). This means a stale ?view=agents deep-link on a chat without sub-agents can't strand the user on an empty canvas with no toggle to escape — it falls back to the thread and "waits", revealing the canvas the moment the first sub-agent appears.

The thread-only flow cards (Ralph start, Implement-plan) also key off effectiveView, so they still show on the thread fallback.

2. Don't zoom the canvas when scrolling inside an overlay

fix(coc): don't zoom the canvas when scrolling inside an overlay

The wheel-to-zoom handler in the shared useZoomPan hook fired for any wheel event bubbling up to the canvas container — and the AgentInspector panel renders inside that container. So scrolling the inspector's content zoomed the canvas instead of scrolling the panel.

The wheel handler now bails when the event originates inside a [data-no-drag] region — the same opt-out the pan-drag handler already honored. The inspector already carries data-no-drag on its overflow-y: auto element, so its content now scrolls natively while the canvas surface still zooms as before. As a bonus, the toolbar/legend (and the DAG charts' zoom controls, which also use data-no-drag) no longer trigger an accidental zoom when scrolled over.

Testing

  • New: ChatDetail-agents-toggle.test.ts — static-analysis test for the toggle/effectiveView wiring (matching the repo's existing ChatDetail source-test convention; the component is too hook/context/SSE-heavy to render).
  • New: real-DOM wheel cases in useZoomPan.test.ts — the existing tests poke a mock ref and never attach the native wheel listener; the new ones cover zoom-over-surface (with preventDefault) and no-zoom-inside-[data-no-drag]-overlay.
  • Reran the agent-canvas suite and both useZoomPan consumers' suites (WorkflowDAGChart ×2, all DAG tests) — all green.
  • npm run build:client clean; eslint reports 0 errors on changed files.

Reviewer notes

  • Touches the shared useZoomPan hook. The change is additive (only affects elements that opt in with [data-no-drag]); behavior for the WorkflowDAG consumers is unchanged except that scrolling directly over their already-data-no-drag zoom controls no longer zooms — a strict improvement.
  • coc-knowledge dashboard-spa.md reference updated for both behaviors.

🤖 Generated with Claude Code

plusplusoneplusplus and others added 2 commits June 13, 2026 21:50
The Agents canvas is only meaningful once a chat has actually spawned
sub-agents. ChatDetail now derives `hasSubAgents` from the agent-run tree
and:
- hides the Thread/Agents toggle when there are none, and
- renders from `effectiveView` (= `view` only when sub-agents exist,
  otherwise `thread`) so a stale `?view=agents` deep-link can't strand the
  user on an empty canvas with no toggle to escape — it instead "waits",
  revealing the canvas the moment the first sub-agent appears.

The thread-only flow cards (Ralph start, Implement-plan) also key off
`effectiveView`, so they still show on the thread fallback.

Adds a static-analysis test for the gating wiring (mirroring the other
ChatDetail source tests in that folder) and updates the coc-knowledge
dashboard-spa reference. The data contract this relies on (no `Task` calls
⇒ no children) is already covered in agent-canvas-data.test.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The agents-canvas wheel-to-zoom handler in the shared `useZoomPan` hook
ran for any wheel event bubbling to the canvas container, including ones
from inside the open AgentInspector panel — so scrolling the panel zoomed
the canvas instead of scrolling the panel's content.

The wheel handler now skips events whose target is inside a `[data-no-drag]`
region — the same opt-out the pan-drag handler already honors. The inspector
(and the toolbar/legend, and the DAG charts' zoom controls) already carry
`data-no-drag`, so their content scrolls natively while the canvas surface
still zooms as before.

Adds real-DOM wheel tests to useZoomPan.test.ts (the existing tests poke a
mock ref and never attach the native wheel listener) covering both the
zoom-over-surface and no-zoom-inside-overlay cases, and notes the opt-out in
the coc-knowledge dashboard-spa reference.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@plusplusoneplusplus plusplusoneplusplus enabled auto-merge (squash) June 14, 2026 05:52
The pre-save `data-unsaved === 'true'` check read the attribute synchronously
right after the title edit, while the post-save check already used `waitFor`.
`hasUnsavedChanges` reaches the (mocked) chat lens a render-tick after the edit
re-renders the panel, so under CI load the bare read caught a stale 'false'
(observed on the macos-latest shard 1 of coc-test). Poll for it with `waitFor`,
matching the post-save assertion.

Test-only; unrelated to the agents-canvas changes in this PR — the chat stack
is fully mocked here, so it surfaced purely as CI flake on this PR's run.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@plusplusoneplusplus plusplusoneplusplus merged commit 41be250 into main Jun 14, 2026
36 checks passed
@plusplusoneplusplus plusplusoneplusplus deleted the coc/agents-canvas-followups branch June 14, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant