Skip to content

fix(sidebar): select a session row only for its own host's copy of the id - #35

Merged
andrebrait merged 3 commits into
mainfrom
fix/sidebar-selection-host
Nov 27, 2026
Merged

andrebrait merged 3 commits into
mainfrom
fix/sidebar-selection-host

Conversation

@andrebrait

@andrebrait andrebrait commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

A session id can exist on two hosts when a session is copied. The sidebar compared only the id to mark a row selected, so both hosts' rows showed as selected (CodeRabbit on #33, listed as open in #15).

Change

  • The sidebar passes the rows a selectedSessionKey of <hostId>:<id>, built from the selected session's host. Each row compares it with its own sessionRowKey(hostId, id), and the row's React key uses the same helper.
  • The row memo comparator re-renders a parent row when the selection changes, because nested rows render inside its memo boundary. The unread branch already does this.

Tests

  • SessionSidebar.presentation.test.mjs:
    • A ProjectRow with stable sets checks that a row is selected only for its own host's key, nested rows included.
    • A SessionSidebar with the same id listed on this machine and on h1 checks that only h1's row is selected.
    • Mutations caught: comparing the id only; hardcoding local in the sidebar's key; dropping the comparator's nested-row check.
  • The other SessionSidebar*.test.mjs files pass, and so does tsc --noEmit.

Not in this PR

Running, awaiting-input, unread and exited marks are still keyed by the id alone. That belongs to the id-keyed state item of #15.

Review round 1 (full)

  • Adversarial:
    • Comparator skipped nested rows on a selection change (latent, pre-existing): fixed.
    • Test reused fresh Sets and Maps, so the comparator was never exercised: fixed.
    • No sidebar-level test of the host in the key: added.
    • Running and unread marks are keyed by id: deferred to Chat and file tab strip: follow-ups #15's id-keyed state item.
    • Empty-string host id: rejected. Real host ids are never empty.
  • Code review (medium):
    • The sidebar test never rendered this machine's row: fixed. Both projects are expanded, and the test asserts on the row.
    • Every parent row re-renders on a selection change: accepted, and noted in a comment. This matches the unread branch; a per-subtree key set can be added if trees grow large.
    • The key template is repeated: fixed with sessionRowKey.
    • Unread is keyed by id: deferred, as above.
  • Simplification: nothing to cut beyond the shared helper.

Summary by CodeRabbit

  • Bug Fixes
    • Session selection now correctly distinguishes sessions with the same ID on different hosts, including nested sessions. The sidebar highlights the matching host’s session.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Session selection and React row identity now use a host-qualified session key. The sidebar passes this key to project rows, and row selection and memoization compare against it. Presentation tests cover matching host and session IDs, including nested rows and duplicate session IDs across hosts.

Changes: Sidebar session selection

Layer / File(s) Summary
Build and pass host-qualified keys
components/SessionSidebar-rows.tsx, components/SessionSidebar.tsx
The sidebar builds a key from the host ID and session ID. Project and session rows use this key for selection and React identity.
Update selection rendering and tests
components/SessionSidebar-rows.tsx, components/SessionSidebar.presentation.test.mjs
The memo comparator detects changes to keyed selection, including changes that affect parent rows with children. Tests cover selection of top-level and nested rows, including duplicate session IDs on different hosts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • ompweb-dev/tau issue 15 describes copied session IDs across hosts and requests that still identify sessions by ID alone. This PR addresses sidebar selection and row identity, but does not change delete or archive requests.

Possibly related PRs

  • ompweb-dev/tau#33: Both PRs change sidebar row identity to use the host and session ID, so rows with duplicate session IDs on different hosts have distinct keys.

Suggested reviewers: kahme247

Merge Risk: Minimal · up to 1aa7a

Sidebar selection now distinguishes copies of the same session ID on different hosts. The change is small and covered by presentation tests, so merge risk is minimal.

Security architecture risk: Minimal · up to 1aa7a

The sidebar now highlights the selected host’s copy of a session without changing which session row actions target or what those actions can access.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The changed selection result affects row styling and the accessibility current marker. Clicking a row still forwards that row’s session object, not the selection key.

Trust Boundaries and Controls

  • observed — The presentation key is not used for authorization or request targeting. Rename, archive, delete, and transcript requests still derive their targets from the acted-on row’s session ID and host.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: sidebar session selection now matches on the session's host as well as its ID, so a row is selected only for its own host's copy of a session. The raw summary and obje…
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.
Full details: Title check

Explanation

The title names the main change: sidebar session selection now matches on the session's host as well as its ID, so a row is selected only for its own host's copy of a session. The raw summary and objectives confirm this is the core change (host-and-ID selection key, comparator update for nested rows, and tests for same-ID sessions on different hosts). The title uses the conventional fix(sidebar) prefix and is 73 characters long, which is within a reasonable length for a title.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74c957a5-1c81-4b64-aed5-5fd013e99430
Commits

Reviewing files that changed from the base of the PR and between 79244bf and 1aa7a27.

Files selected for processing: 3

  • components/SessionSidebar-rows.tsx
  • components/SessionSidebar.presentation.test.mjs
  • components/SessionSidebar.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@andrebrait
andrebrait merged commit 5f7ddef into main Nov 27, 2026
5 checks passed
@andrebrait
andrebrait deleted the fix/sidebar-selection-host branch November 27, 2026 06:28
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