Skip to content

feat(web): group sessions by machine and improve group headers#383

Merged
tiann merged 3 commits intotiann:mainfrom
gaius-codius:feat/session-list-machine-grouping
Apr 1, 2026
Merged

feat(web): group sessions by machine and improve group headers#383
tiann merged 3 commits intotiann:mainfrom
gaius-codius:feat/session-list-machine-grouping

Conversation

@gaius-codius
Copy link
Copy Markdown
Contributor

Summary

Group sessions in the web sidebar by both machine and directory instead of directory alone, and improve the group header UI to make the machine context clearer.

Changes

  • group session list entries by machineId + directory
  • show a machine chip in each session group header
  • resolve machine label from machine display name/host when available
  • fall back to a short machine id when no friendly label is available
  • keep expand/collapse behavior working with the new grouping key
  • update group count logic to reflect machine-aware grouping

Why

When the same repo/path exists on multiple machines, the previous UI could merge those sessions into a single group, which made it unclear where a session was running. This change keeps those groups separate and makes machine context visible at a glance.

Validation

  • verified visually in the local web UI
  • confirmed sessions with the same path on different machines render as separate groups
  • confirmed expand/collapse and session navigation still work
  • ran bun run typecheck:web

via [HAPI](https://hapi.run)

Co-Authored-By: HAPI <noreply@hapi.run>
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Findings

  • [Major] Selected inactive sessions can disappear from the sidebar after this split. web/src/components/SessionList.tsx:375 still auto-collapses any group without an active session. After grouping by machineId + directory, an inactive selected session on machine A no longer stays visible just because another machine has an active session in the same repo.
    Suggested fix:
    const isGroupCollapsed = (group: SessionGroup): boolean => {
        const override = collapseOverrides.get(group.key)
        if (override !== undefined) return override
        const hasSelectedSession = selectedSessionId
            ? group.sessions.some(session => session.id === selectedSessionId)
            : false
        return !group.hasActiveSession && !hasSelectedSession
    }

Summary
Review mode: initial
1 issue found in the current diff.

Testing
Not run (automation). bun is not installed in this runner, so bun run typecheck:web could not be repeated here. Suggested coverage: a SessionList render case with two same-path sessions on different machines where the selected group has no active session and should remain expanded.

HAPI Bot

Prevents the selected session from disappearing when its group
auto-collapses due to the active session being in a different group.

via [HAPI](https://hapi.run)
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Findings

  • [Minor] The sidebar summary now counts (machineId, directory) groups, but the copy still renders that number as projects. One repo opened on two machines will now show up as 2 projects, which misstates what the counter means. Evidence web/src/router.tsx:117, related copy web/src/lib/locales/en.ts:42.
    Suggested fix:
    const sessionGroupCount = new Set(sessions.map(s => {
        const path = s.metadata?.worktree?.basePath ?? s.metadata?.path ?? 'Other'
        const machineId = s.metadata?.machineId ?? '__unknown__'
        return `${machineId}::${path}`
    })).size
    
    {t('sessions.groupCount', { n: sessions.length, m: sessionGroupCount })}

Summary
Review mode: follow-up after new commits
1 issue found in the current diff.

Testing
Not run (automation). bun is not installed in this runner, so bun run typecheck:web could not be repeated here. Not found in repo/docs: existing tests covering machine-aware sidebar grouping or the sessions counter copy.

HAPI Bot

- Clear manual collapse override when navigating into a collapsed group
- Memoize projectCount to avoid recomputing on every render
- Fix projectCount to count unique directories (not machine+dir pairs)
  so "N projects" label remains accurate across machines
- Extract shared UNKNOWN_MACHINE_ID constant to prevent drift
- Replace IIFE with pre-computed variable for todoProgress

via [HAPI](https://hapi.run)
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Findings

  • None.

Summary
Review mode: follow-up after new commits
No actionable issues found on the current head. Residual risk: Not found in repo/docs: automated coverage for machine-aware grouping and selected-session auto-expansion in web/src/components/SessionList.tsx, or for the sidebar counter semantics in web/src/router.tsx.

Testing
Not run (automation). bun is not installed in this runner, so bun run typecheck:web could not be repeated here.

HAPI Bot

@tiann tiann merged commit 845a100 into tiann:main Apr 1, 2026
2 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.

2 participants