Skip to content

fix(chat): chat-debug right-dock self-feedback (peer-only claim reads)#359

Merged
blove merged 1 commit into
mainfrom
claude/chat-debug-right-dock-self-claim-fix
May 16, 2026
Merged

fix(chat): chat-debug right-dock self-feedback (peer-only claim reads)#359
blove merged 1 commit into
mainfrom
claude/chat-debug-right-dock-self-claim-fix

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 16, 2026

Summary

Fixes a regression I introduced in PR #346: when chat-debug docks right, the panel offsets itself by its own width (420px) instead of anchoring at `right: 0`. The right-docked debug panel floats in the middle of the viewport whenever no sidebar is open — visible in any consumer of @ngaf/chat@0.0.32 that uses `` in its default right-dock state.

Root cause

The edge-claim primitive in PR #346 set both write and read on the same aggregate var:

```css
:root[data-ngaf-chat-debug="right"] {
--ngaf-chat-occupy-right: 420px; /* debug WRITES /
}
.panel--right {
right: var(--ngaf-chat-occupy-right, 0); /
debug READS — self-feedback! */
}
```

When debug docked right, it pushed itself 420px off the right edge.

Fix

Split the primitive into two layers:

  1. Per-component claim vars — only the OWNER writes, only PEERS read:

    • `--ngaf-chat-sidebar-claim-right` (chat-sidebar writes, chat-debug reads)
    • `--ngaf-chat-debug-claim-{top,right,bottom,left}` (chat-debug writes, chat-sidebar reads)
  2. Aggregate `--ngaf-chat-occupy-*` stays as a convenience read for external consumers ("is anything on this edge?"), but internal lib panels reference peer-specific claims.

Verified live

State `panel--right` `right` Result
chat-debug right-dock, no sidebar `var(--ngaf-chat-sidebar-claim-right, 0)` = `0px` ✅ Anchored flush right
chat-debug right-dock, sidebar open `28rem` ✅ Stacked left of sidebar
chat-debug auto-dock-to-bottom in sidebar mode n/a (different selector) ✅ Bottom dock unchanged

Test plan

  • `vitest run libs/chat` — 745 passed (12 new cases lock per-component claim vars + attribute mappings)
  • `npx nx build chat` — green
  • api-docs unchanged (no public API additions)
  • Manual live verification on http://localhost:4200 (embed + sidebar modes)
  • CI green

Notes

  • Known follow-up (out of scope): chat-debug top-right launcher overlaps the sidebar region when sidebar is open. Functional (higher z-index) but visually cramped. Worth a separate fix to read `--ngaf-chat-sidebar-claim-right` and offset.

🤖 Generated with Claude Code

PR #346's edge-claim primitive had a self-feedback bug: when
chat-debug docked right, it wrote --ngaf-chat-occupy-right AND read
--ngaf-chat-occupy-right, so the panel offset itself by its own width
(420px) instead of anchoring at right: 0. The result was a broken
right-docked debug panel floating in the middle of the viewport
whenever no sidebar was open.

Fix: split the edge-claim primitive into two layers.

  1. Per-component claim vars — only the OWNER writes them, only
     PEERS read them. Eliminates self-feedback by construction:
       --ngaf-chat-sidebar-claim-right   (chat-sidebar writes,
                                          chat-debug reads)
       --ngaf-chat-debug-claim-{top,right,bottom,left}
                                         (chat-debug writes,
                                          chat-sidebar reads)

  2. Aggregate --ngaf-chat-occupy-* vars stay as a convenience read
     for external consumers ("is anything on this edge?") but
     internal lib panels reference the peer-specific claims instead.

Consumer-side changes:
  - chat-sidebar.__panel + .__launcher now read --ngaf-chat-debug-
    claim-bottom (was: --ngaf-chat-occupy-bottom)
  - chat-debug.panel--right + .panel--bottom now read --ngaf-chat-
    sidebar-claim-right (was: --ngaf-chat-occupy-right)

Tests: 12 new cases in chat-tokens.spec lock the per-component vars
and attribute mappings. Existing component specs updated to assert
the peer-specific reads (catches the regression directly).

Verified live: right-dock anchors at right: 0 with no sidebar
present; auto-dock to bottom still works when chat-sidebar exists;
manual right-dock-over-sidebar correctly stacks at right: 28rem.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment May 16, 2026 3:23pm

Request Review

@blove blove merged commit a5bc73d into main May 16, 2026
16 checks passed
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