Skip to content

fix(dashboard): stop the expanded table row remounting on every poll - #558

Merged
njbrake merged 2 commits into
mainfrom
fix/activity-detail-panel-remount
Aug 11, 2026
Merged

fix(dashboard): stop the expanded table row remounting on every poll#558
njbrake merged 2 commits into
mainfrom
fix/activity-detail-panel-remount

Conversation

@njbrake

@njbrake njbrake commented Aug 11, 2026

Copy link
Copy Markdown
Member

Description

Expanding a row in the Activity pane while a request is running made that row flash and slide open again every couple of seconds.

DataTable puts its inline detail panel in a portal host <tr> inserted next to the target row. The layout effect that does the insertion lists rows in its deps and its cleanup always removed the host, so every re-run built a fresh <tr>/<td> and re-pointed the portal at it. React answers that by unmounting the panel and mounting it into the new node, which replays the 180ms reveal animation and drops the panel's state (including the routing-plan lookup). The activity page polls for in-flight requests every 2s and hands the table a rebuilt rows array each time, so this fired on a timer for as long as a request was running.

The host is now built once and held in a ref, so the portal target survives the effect re-running. The effect only repositions it, and only when it is not already in place: re-inserting an attached node detaches and re-attaches its subtree, which cancels and restarts the animation inside it. Detaching moved out of the effect cleanup into the no-target branch plus a mount-scoped effect, so a vanished target (filtered out, page flipped) still leaves nothing behind.

No change to the in-flight polling itself. I checked whether the 2s rows-array churn was worth stabilizing and it is not: react-aria caches rendered rows on the row object, so a new-but-equal array costs zero cell re-renders and the same wall time as a stable one.

PR Type

  • New Feature
  • Bug Fix
  • Refactor
  • Documentation
  • Infrastructure / CI

Relevant issues

None filed; reported directly.

Checklist

  • I understand the code I am submitting.
  • I have added or updated tests that cover my change (tests/unit, tests/integration).
  • I ran the Definition of Done checks locally (make lint, make typecheck, make test).
  • Documentation was updated where necessary.
  • If the API contract changed, I regenerated the OpenAPI spec (uv run python scripts/generate_openapi.py).

Notes on the checklist: this is a dashboard-only change, so the relevant checks are npm --prefix web run typecheck (clean) and npm --prefix web test (577 passing). Two regression tests were added, both of which fail on main: a unit test in DataTable.test.tsx that a no-op rows rebuild must not remount the panel, and a page-level test in ActivityPage.test.tsx that expands a row with a request in flight and advances past two polls. No user-facing behavior is documented for this, no API contract changed, so no docs or OpenAPI regeneration were needed.

AI Usage

  • No AI was used.
  • AI was used for drafting/refactoring.
  • This is fully AI-generated.

AI Model/Tool used:

Claude Opus 5 (1M context), via the Claude Code CLI.

AI Model/Tool details:

The root cause analysis, the fix, and both regression tests were produced by the model through back-and-forth with @njbrake. The prose here is the model's; the direction and the decisions are his. One suggested extra change (memoizing the in-flight rows to stop the 2s array churn) was measured, found to buy nothing, and dropped at his call, so the diff is only the actual fix.

NOTE:
When responding to reviewer questions, please respond yourself rather than copy/pasting reviewer comments into an AI and pasting back its answer. We want to discuss with you, not your AI :)

  • I am an AI Agent filling out this form (check box if true)

Summary

  • Kept expanded detail panels mounted when table rows update.
  • Removed detail-panel hosts when the target row disappears or the table unmounts.
  • Remounted the panel when users switch to a different row.
  • Added regression tests for row updates and activity polling.

Benefit

Expanded activity panels now keep their state and DOM node during polling.

DataTable positions its inline detail panel in a portal host <tr> inserted
next to the target row. The layout effect that does the insertion lists
`rows` in its deps and its cleanup always removed the host, so every re-run
built a fresh <tr>/<td> and re-pointed the portal at it. React answers that
by unmounting the panel and mounting it into the new node, which replays the
180ms reveal animation and throws away the panel's state, including the
routing-plan lookup.

The activity page polls for in-flight requests every two seconds and hands
the table a rebuilt rows array each time, so an operator who expanded a row
while a request was running watched it flash and slide open again on a timer.

Build the host once and keep it in a ref, so the portal target survives the
effect re-running. The effect now only repositions it, and only when it is
not already in place: re-inserting an attached node detaches and re-attaches
its subtree, which cancels and restarts the animation running inside it.
Detaching moves out of the effect cleanup (which runs on every dependency
change) into the no-target branch plus a mount-scoped effect, so a vanished
target still leaves nothing behind.

Regression tests at both levels: a unit test that a no-op rows rebuild does
not remount the panel, and a page-level test that expands a row with a
request in flight and advances past two polls.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the missing-template PR is missing required template sections label Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 07512f75-9040-4d5d-bc2a-1f61f6b5913e

📥 Commits

Reviewing files that changed from the base of the PR and between 508ecfd and 8db5d11.

📒 Files selected for processing (2)
  • web/src/components/DataTable.test.tsx
  • web/src/components/DataTable.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/components/DataTable.tsx

Walkthrough

DataTable now reuses its detail-row portal host across effect reruns. Portal content remains mounted for the same detail key and remounts when the detail key changes. Regression tests cover copied rows, row changes, and ActivityPage polling.

Changes

Detail panel persistence

Layer / File(s) Summary
Persistent detail-row host lifecycle
web/src/components/DataTable.tsx
DataTable lazily creates and reuses the detail-row host. Cleanup removes it only when needed. The detail container key controls panel remounting.
Detail panel regression coverage
web/src/components/DataTable.test.tsx, web/src/pages/ActivityPage.test.tsx
Tests verify panel preservation during row updates and polling, remounting when the detail key changes, and a single detail row beneath the target row.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: area/dashboard

Suggested reviewers: khaledosman

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the fix Conventional Commit prefix, clearly describes the remounting bug, uses imperative mood, and is 68 characters long.
Description check ✅ Passed The description explains the root cause and fix, identifies the bug-fix type, documents tests and checks, and completes the AI usage section.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/activity-detail-panel-remount
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/activity-detail-panel-remount

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot removed the missing-template PR is missing required template sections label Aug 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/components/DataTable.tsx`:
- Around line 183-205: Rebuild the dashboard after the DataTable changes and
commit the generated output under src/gateway/static/dashboard/. Ensure the
bundled dashboard includes the updated hostRef and ensureHost behavior from
DataTable.tsx.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ac6f0032-e099-4a53-a2e9-336892fec8ca

📥 Commits

Reviewing files that changed from the base of the PR and between d864e05 and 508ecfd.

📒 Files selected for processing (3)
  • web/src/components/DataTable.test.tsx
  • web/src/components/DataTable.tsx
  • web/src/pages/ActivityPage.test.tsx

Comment thread web/src/components/DataTable.tsx
Stabilizing the portal host so a poll cannot remount the panel also stopped
it remounting on a genuine row change: with the container node fixed, React
reconciles the panel across a detailKey jump from one row to the next.

That breaks the Routing page's Examples panel. RouterReadiness seeds its user
picker with `useState(scopedUserId)`, so it only reads the prop at mount, and
the Examples button toggles `expanded` straight from one policy's key to
another with no null in between. The panel then renders the new policy's
header and copy while the warmth numbers still come from the previous
policy's user, and no status is fetched for the user it claims to be showing.
ActivityPage escaped it: RequestDetail holds no state and RoutingPlan already
filters its group lookup by request_group_id.

Key the portal's wrapper by detailKey. A poll leaves detailKey alone, so the
host stays put and the panel stays mounted; only a different row remounts,
which is also what replays the reveal animation under the newly opened row.

Found by independent review of the parent commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@njbrake
njbrake merged commit ee2aadd into main Aug 11, 2026
8 checks passed
@njbrake
njbrake deleted the fix/activity-detail-panel-remount branch August 11, 2026 19: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.

2 participants