Skip to content

fix(remote): keep host project groups collapsible and their rows in the group - #2382

Merged
vastsa merged 8 commits into
vastsa:mainfrom
koeria:fix/issue-2370-remote-project-groups
Nov 16, 2026
Merged

vastsa merged 8 commits into
vastsa:mainfrom
koeria:fix/issue-2370-remote-project-groups

Conversation

@koeria

@koeria koeria commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the three sidebar defects for host (remote) project groups in issue #2370:

  1. Host project groups could not collapse. RemoteProjectGroups now renders the same header, disclosure chevron, and sidebar-session-group-body project fold as local project groups. Collapse state persists through setProjectCollapsed under a remote::-prefixed key (remoteProjectCollapseKey), so the fold survives a restart. The group title toggles the fold like a local one; the New-chat affordance still opens the project.
  2. The Remote source tag stacked vertically. .thread-item-source had no CSS rule at all; it is now a non-shrinking, non-wrapping badge (flex: 0 0 auto, white-space: nowrap), so a narrow sidebar truncates the title instead of wrapping the tag.
  3. Opening a remote conversation removed the row from its group. createHostSessionPort.get returned the raw host record, so attach.session / attach.snapshot.session carried no projectId; the renderer replaces its cached summary with that snapshot and can no longer place the row under its group. The port now decorates summaries via a shared withSessionProjectIds helper (the same projects-table decoration session/list applies), so the id survives attach. pi-host's session catalog reuses the same helper.

Test

  • packages/host-runtime vitest: new port test — get resolves projectId from the project path, omits it for an orphaned path, and skips projects.list when there is no path. Full package suite: 188 pass.
  • apps/desktop node tests: remote-project-session.test.mjs extended — host groups keep their rows keyed by the remote project id and collapse keys never collide with local paths. remote-project-session + app-store-sidebar + sidebar-project-runs: 31 pass.
  • tsc --noEmit for apps/desktop, apps/pi-host, and packages/host-runtime builds: clean.

Note: an earlier PR (#2371) addresses the same issue and currently has CHANGES_REQUESTED; this is an independent implementation on current main.

Fixes #2370

…he group

Three sidebar defects once a host project group exists (issue vastsa#2370):

1. Host project groups had no disclosure chevron or foldable body. The
   remote group renderer now uses the same header, chevron, and
   `sidebar-session-group-body project` fold as local project groups,
   with the collapse state persisted under a `remote::`-prefixed key so
   the fold survives a restart. The group title toggles the fold; the
   New-chat affordance still opens the project.
2. The `Remote` source tag had no CSS of its own, so in a narrow sidebar
   it shrank and wrapped into stacked words. `.thread-item-source` is
   now a non-shrinking, non-wrapping badge; the title truncates instead.
3. Opening a remote conversation dropped its row into the top-level
   Sessions list. `createHostSessionPort.get` returned the raw host
   record, so the attach summary carried no `projectId`; the renderer
   replaces its cached summary with that snapshot and can no longer
   place the row under its group. The port now resolves the project id
   from the projects table through a shared `withSessionProjectIds`
   helper (the same decoration `session/list` already applies), so
   `attach.session` and `attach.snapshot.session` keep the id.

Fixes vastsa#2370

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Independent execution of production withSessionProjectIds on 87068f4 reproduces project identity loss: record {id:"s", projectId:"authoritative-id", projectPath:"/p"} plus projects.list row {id:7,path:"/p"} returns projectId:"7". toSessionSummary preserves the explicit ID, then the new helper overwrites it. This is the same precedence defect already corrected in #2371. Please preserve each nonempty explicit projectId and resolve by path only for records missing an ID; skip projects.list when all records already have IDs. Add mixed-batch, explicit-ID-only, orphaned-path and list/get parity coverage. Keep workspaceIdentity and returned projectId consistent with the authoritative record. The original missing-ID/grouping defect is established by the prior #2371 baseline review, but this independent implementation reintroduces this blocker. Please also provide matching-revision paired-host list → attach → group retention and collapse persistence/order E2E before landing; this review has not run that native integration journey.

…test-asserted CSS formatting

- withSessionProjectIds no longer throws when the host rejects
  projects.list (older hosts / reduced-RPC connections); summaries are
  returned undecorated instead, so prompt admission cannot wedge, and
  records that already carry a projectId skip the lookup entirely.
- keep sidebar CSS and RemoteProjectGroups formatting single-line where
  sidebar tests assert exact source shapes (they were prettier-wrapped
  by the reformat).

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Rechecked the latest a80b9ab with the production helper. Skipping lookup for an all-explicit batch is useful, but the original per-record precedence bug remains for a mixed batch: [{id:'explicit',projectId:'authoritative-id',projectPath:'/p'},{id:'missing',projectPath:'/p'}] with projects.list [{id:7,path:'/p'}] returns projectId:'7' for BOTH records. The first record loses its authoritative ID. Please return the existing summary for each record with a nonempty projectId before applying byPath fallback, and add a mixed-batch regression. The best-effort lookup fallback does not resolve this identity blocker. Matching-revision paired-host acceptance requested in the earlier review is still outstanding.

…ration

withSessionProjectIds applied the byPath fallback to every record sharing
a project path, overwriting records that already carry an authoritative
projectId. Records with a non-empty projectId now keep their existing
summary untouched; only records missing an id are decorated from
projects.list.

Also adds regression coverage: a mixed explicit+missing batch keeps the
explicit 'authoritative-id' while decorating the missing record with '7',
and an acceptance case pairing createHostSessionPort.get with the
session/list decoration to prove both yield the same project id.

Fixes maintainer review feedback on vastsa#2382.

vastsa commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Rechecked 5b7af69: the per-record guard now preserves the authoritative ID in mixed batches, resolving the reproduced precedence blocker. Executed production host-ports.test.ts: 8/8 pass, including mixed-batch and list/get parity. This does not yet establish the requested paired-host list → attach → project-group retention, collapse persistence and ordering acceptance. Please provide/run that matching-revision integration journey; the current port-level test uses a controlled RPC response and cannot prove the renderer/Host boundary. No merge yet; latest main also needs incorporating before final integration validation.

…ptance

Real binary + real RACP journey: host-core projects.create/session.create
mixed-batch keeps per-record project identity through
withSessionProjectIds, attach round-trips, then the full paired-host
journey (pi-host loopback, exchangePairingToken, createRemoteHostsBoot,
sessions list, attach, subscribe) verifies one exclusive sorted group per
project with unique remote:: collapse keys whose fold persists through the
real Main sidebar-preferences store. No RPC mocks: 23/23 checks PASS.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for adding the paired-host journey. Reviewed the new script; two acceptance gaps remain before it can establish the previously requested boundary regression:

  1. finish(code) counts failed records but prints PASS and exits 0 whenever its caller passes 0 (the normal final line). Independently executed the exact record/finish functions extracted from this file with record("forced-regression", false); finish(0): output is FAIL forced-regression, then ACCEPTANCE PASS: 0/1 checks, exit 0. Derive the final exit status from both the requested code and failed.length; add a negative control proving failed identity/group assertions fail the process.

  2. Lines 391–405 call readHistory (production implementation only requests session/history) and subscribeSession (only registers a local envelope listener, and the assertion even accepts null). Neither executes session/attach or applies attach.session / attach.snapshot.session to the renderer store. The grouping assertion then reuses the original pre-attach sessions array. Thus the exact original regression — replacing a cached summary with an attach snapshot missing projectId — can still pass this journey. Exercise the production attach/store reconciliation path and assert project identity and exclusive group membership after applying the returned snapshot. A negative control removing the get-side decoration should fail that assertion. Also drive collapse via the store action and verify restored state is used by the rendered group; direct backup write/read alone proves serialization, not the UI journey.

No full paired-host run claimed this round: the new acceptance gate itself permits false success and does not yet traverse the defective attach boundary. Existing port-level 8/8 evidence remains valid, but does not replace this integration proof. Latest main now includes #2381 and must be incorporated for the final candidate.

…and fail closed on any failed check

- finish() now derives the exit status from both the requested code and the
  failed-check count; a self-check subprocess proves record(false) + finish(0)
  still exits non-zero.
- Phase B attaches through createRemoteHistory (session/attach with
  includeSnapshot, the IPC.invoke.sessionGet production path) over a second
  real RACP client, reconciles the returned SessionDetail into the renderer
  session list like the production selectSession remote branch, and asserts
  project identity plus exclusive group membership on the post-attach state.
- Negative control: stripping the get-side remoteProjectId decoration must
  break the grouping contract.
- The fold is driven by the real setProjectCollapsed store action and the
  rendered groups must consume the restored collapse state.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

已独立验证,本轮先前阻塞已解决:候选源码构建 pi-host/host-runtime 及 sidecar 后,真实 Rust Host + loopback RACP 配对验收 28/28 PASS(使用 PI_SCRATCH_DIR=/tmp 避免 macOS 默认临时目录导致 Unix socket 路径过长)。覆盖真实 attach snapshot、替换后分组、混合批次权威 project ID、排序、真实折叠 store action/持久化,以及两个负向控制。Host ports 8/8、remote project session 10/10 PASS。另运行真实 Electron 的生产 RemoteProjectGroups + app-store 检查:点击折叠/展开、另一项目独立、aria-hidden/inert、恢复折叠状态 PASS。折叠保留 DOM 并通过 region 状态/CSS 实现,初始诊断误以为卸载 DOM,修正诊断后通过。此 UI 检查是受控 IPC 边界组件验收,非全应用启动或截图验收;配对 Host 流程独立真实运行。5 项当前 CI SUCCESS;最新 main 已包含于 head,实际 merge ref tree 9c7a9e1b 与已测 head 一致。修复保持在项目身份补齐、分组与折叠交互范围,可合入。

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.

Remote host project groups cannot collapse, stack their source tag, and lose rows after opening a conversation

2 participants