Repository navigation
Join the profile this process already holds on a repeated session_start - #258
Conversation
|
The pending check is GitHub's fork-approval gate, not a failure: the Evidence in the meantime — the same commit's full Locally it is also |
T3 Code runs many Pi sessions in one process and replaces the session under the running extension. session_start then reaches an instance whose profile is already open, and openProfile took the lock again: holdProfile meets this process's own socket, readOwner answers with our own description, and ProfileBusyError takes the session down, because outside the TUI it is rethrown. Keep the open activation when the requested name is the one already active, and re-apply the profile's main model as a fresh open would. test/reopen.test.ts emits a second session_start into the same instance; on main it fails with "Profile already running: … · PID <own pid> · …".
92297a5 to
165f746
Compare
|
Thanks for this, and for the clear write-up! The bug is real. I reproduced it with The cause turned out to be slightly different from a reload, though. Pi's RPC mode binds extensions twice for the same session after The old-lock part doesn't hold up: when you switch to a session bound to another profile, Pi sends On top of your commit I pushed:
Merging once CI is green. Thanks again! |
What changed
src/index.ts: whensession_startasks for the profile this process already holds, keep the openactivation instead of taking the lock again.
restoreMainis called so the second start still re-applies the profile's pinnedmainmodel, exactlyas the normal open path does.
Why
A host that replaces the session under a running extension (T3 Code does this; it runs one Pi process
for its threads and passes
--mode rpc --session <file>) sends a secondsession_startinto aninstance that already has the profile open.
openProfilethen callsholdProfile, which meets its ownlock socket:
lockProfilegetsEADDRINUSE,readOwneranswers with this process's own description(
<profile> · PID <own pid> · …), andProfileBusyErroris raised.For the failure the crash is not a menu: in
session_start's catch,an RPC host rethrows,
faultis set, and the host's session start fails. The TUI path instead shows the"open in another window" menu, which is why this only bites non-interactive hosts.
Test
test/reopen.test.tsstarts a fixture session, then emits a secondsession_start(reason: 'reload')into the same extension instance and asserts that no busy/missing-profile note is reported and that the
profile is still usable afterwards.
main: fails withProfile already running: fixture · PID <own pid> · …Checked with
npm run check(tsc, clean) andnpm test: 364 tests, 363 pass, 1 skipped, 0 fail.Scope
Only the "same process, same profile" case changes; any other profile name (a real second window, a
/optchat profileswitch) still goes throughholdProfileand the existing menus. A profile switch inone process still leaves the previous activation's lock in place, which this change does not touch — say
if you want that handled too and I will send it separately.