Skip to content

Take one session when Claude accounts share their folders by symlink - #351

Closed
fominfo wants to merge 3 commits into
spacesheep-dev:mainfrom
fominfo:claude/ipro/2026-11-26-sessionpipe-linked-homes
Closed

fominfo wants to merge 3 commits into
spacesheep-dev:mainfrom
fominfo:claude/ipro/2026-11-26-sessionpipe-linked-homes

Conversation

@fominfo

@fominfo fominfo commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

What

Fixes #350. On a machine whose Claude accounts link projects/ and sessions/ to one config dir, every account finds the same transcript and the same live record. resolveHome counted each of them live and refused ambiguous_home, so no Claude Code session there could be messaged.

resolveHome now handles the case where every live copy resolves to one file on disk and every live record to one registry file. That is one session in one process, so it takes it, filed under the account whose own projects/ and sessions/ hold it rather than links. Two transcripts, two processes, or nothing live is still refused, so the signed-out-account guess §6.1 warns about stays out. spec/CONTROL.md §6.1 says so in a new paragraph.

Checklist

  • Every commit is signed off (git commit -s, the DCO)
  • Spec and fixture updated together. §6.1 has no conformance vector today. The behaviour is pinned by three cases in packages/core/test/claude-live-record.test.ts; glad to add a vector file if you want one for homes.
  • No telemetry added
  • A changeset is included (sessionpipe-core, patch)
  • The definition of done was checked with a command, and its output is below

Proof

The new cases, then the first one against the old resolveHome:

$ npx vitest run packages/core/test/claude-live-record.test.ts
      Tests  13 passed (13)

$ git checkout packages/core/src && npx vitest run packages/core/test/claude-live-record.test.ts   # source change reverted, tests kept
     × accounts sharing their folders by symlink, one process live: that session, in the account owning the folders
      Tests  1 failed | 12 passed (13)

Lint and types:

$ npx biome check packages/core/src/adapters/claude-code-control.ts packages/core/test/claude-live-record.test.ts
Checked 2 files in 11ms. No fixes applied.
$ npm run typecheck
(exit 0)

The full suite on macOS (Node 22) after npm run build: 4,540 passed and 9 failed, in cli-main, fold and install-layout. The same 8 fail in those files without this change. The 9th was a gemini-cli fold case that ran 79 s, a timeout on this machine.

🤖 Generated with Claude Code

Accounts that link projects/ and sessions/ to one config dir each find the same transcript and the same live record, so resolveHome counted every one of them live and refused ambiguous_home. Where every live copy is one file on disk and every live record one registry file, take that session, filed under the account whose own folders hold it. Two files, two processes, or nothing live still refuses (spec/CONTROL.md section 6.1).

Fixes spacesheep-dev#350

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ilya Fomin <2030645+fominfo@users.noreply.github.com>
@fominfo
fominfo requested a review from micmmakarov as a code owner November 26, 2026 19:13

@micmmakarov micmmakarov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, Ilya. The resolveHome part is right, but the message still won't reach the Session tab.

Blocking: the inbox lane still sees one live record per linked login

inboxLook calls liveRecord(target, this.deps.claudeDirs()) (packages/cli/src/control/daemon.ts:2848), which searches every account. With sessions/ linked, each login reads the same registry file, so liveRecords returns one row per login and liveRecord returns null. I checked this on the PR head (7d7a6fe) with two linked homes:

resolveHome configDir: own
liveRecords across dirs: [ 'a', 'own' ]
liveRecord across dirs: null

So vetInbox refuses with no_record, and the message falls through to a fork. It gets answered in a copy instead of the live window, and later messages follow that copy. With this PR the message stops being refused but still never reaches the Session tab.

Two ways to fix it:

  • Scope the lookup to the account you resolved: liveRecord(target, place.transcript.configDir). That also keeps rec.configDir equal to the transcript's account, which the other_home check needs.
  • Or drop duplicate rows in liveRecords by real path. That also stops cancel() (daemon.ts:2601) from seeing doubled rows; those do no harm there today.

Please add a daemon-level test where a message to linked homes actually goes in place through the inbox. The three new tests only cover resolveHome.

Smaller points

  • If every account is a link (all pointing at a shared folder that isn't itself in claudeDirs), the fallback is live[0], which depends on the order of claudeDirs. That matters a little because machineClass(configDir) reads that account's own settings.json, and settings.json isn't shared. One sentence in §6.1 on this case would help.
  • If the hand-patched copy on the iPro does reach the Session tab, it probably also patches this lookup. That patch belongs in this PR.

The spec paragraph, the refusal cases, the changeset and the before/after proof are all good.

…lane too

The inbox lane looks the live record up across every account, and with
sessions/ linked each account read the same registry file, so liveRecord
found one row per account and returned null: no_record, and the message
went to a fork instead of the live window. liveRecords now keeps one row
per real registry file, named for the account the session was resolved
to, so a second process in another account still refuses and other_home
still compares the right accounts. A daemon test writes through linked
homes into the inbox; spec section 6.1 covers the all-links case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ilya Fomin <2030645+fominfo@users.noreply.github.com>
@fominfo

fominfo commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, that's right. Fixed in fa162ab.

The inbox lane. I went with the second option, dropping duplicate rows in liveRecords, because scoping the lookup to the resolved account would also stop it from seeing a second process in another account, which is what other_home and no_record are for. liveRecords now keeps one row per real registry file. A new optional prefer names the account the session was resolved to, and the kept row is that account's copy, so rec.configDir matches the transcript's account. inboxLook passes place.transcript.configDir. Without links nothing changes, since distinct files have distinct real paths. cancel() stops seeing doubled rows as a side effect.

The daemon test is in control-inbox.test.ts. A linked login is listed before the owner, and it has no settings.json of its own. The message is written once into the inbox and acked delivered with mode: "inbox", and no copy is started. On 7d7a6fe it fails at wrote(1): nothing goes into the inbox and the message forks. There is also a core case for the dedupe and prefer, which checks that a second process in its own account still makes liveRecord null.

§6.1 now covers the all-links case: it takes the first account in the config-dir list, that account's own settings.json sets the machine's class, and a lane counts the shared registry file once.

The iPro. You guessed right that the hand-patched copy didn't fix this lookup. It only deduped transcripts. The message that got through went by the waiter, because a sessionpipe wait was running in that session. The inbox lane would have forked.

Checks: biome and typecheck are clean. The full suite has 4,543 passed and 8 failed, the same 8 in cli-main (Windows hook path) and install-layout that fail here without this change.

… branch

- Add conformance/control-homes.json covering CONTROL.md §6.1 Homes (single,
  missing, one-live, ambiguous, linked-to-owner, all-links fallback, cold
  linked, and linked projects with two live registries), driven by
  packages/core/test/claude-live-record.test.ts.
- Cover the all-links fallback branch in oneThroughLinks and mark the two
  TOCTOU catch fallbacks in realOf/linkedFolder with v8 ignore so 100%
  coverage holds.
- Compare prefer with path.resolve in liveRecords to match vetInbox, and list
  sessionpipe alongside sessionpipe-core in the changeset.

Signed-off-by: kombuchapunk <35040017+kombuchapunk@users.noreply.github.com>
@kombuchapunk

Copy link
Copy Markdown
Collaborator

Superseded by #376 (merged into main with your original commits and DCO attribution preserved, plus rebase and hardening). Thanks @fominfo!

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.

Control: ambiguous_home refuses every message when Claude accounts share their folders by symlink

3 participants