Repository navigation
feat(pi-lsp): share Server Instances across sessions in one Pi process - #475
Merged
Merged
Conversation
Sessions in one Pi process that resolve the same Server Definition configuration and workspace root now lease one language-server process from a pi-lsp-private pool on globalThis, instead of each starting its own. Leases are taken on first use and released at shutdown, on disable, or when the instance stops; the last release stops it. Stop and restart act for every leaseholder, failure state is shared, server-initiated edits are previewed only for a sole leaseholder, and stderr files belong to the instance. Status counts other leaseholders. Closes #465
…out of failure state - stopServer releases the session's lease even when the Server Definition is gone, instead of dropping it while it kept the instance alive. - A startup a Stop or the last release aborts is no longer recorded as a startup error, so a request waiting on it reports the instance stopped rather than unavailable with the abort error. - The pooled start closure captures only the instance's configuration and the start function, not the manager, so a shut-down session is not retained by a startup it triggered. - Declare the server edit handler once and derive LspServerStartInput from LspPooledStartInput; derive every lease accessor from one state cascade. - Cover the pool-owned stderr modes and the server's applyEdit replies; correct ADR-0005 on key ordering and same-version copies. Refs #465
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Each Pi session built its own
LspServerManager, so every Minimal Subagents child (and Advisor session) that touched code cold-started its owntsc --lsp(about 8–10 CPU-s, 650–900 MB RSS) and oxlint for the same workspace root as its parent. Now the sessions in one Pi process share Server Instances through a pi-lsp-private pool, and each session holds a Server Instance Lease on the instances it uses.Decisions: ADR-0005. Glossary: Server Instance redefined, Server Instance Lease added, and the behavior boundary updated. A session that holds no lease shows an instance as
stopped, even while other sessions run it.Closes #465
Evidence
Before: two pi-lsp sessions in one process with the same cwd and settings → 2 launches of the fake server for each Server Definition and root.
After:
test/lsp-shared-server-instances.test.ts(two extension instances, fake server logging launches):Independent two-axis review (standards and spec): the possible bugs, test gaps and cleanups it found are fixed in
54f353b.pnpm --filter @ian-pascoe/pi-lsp test: 523 passed.pnpm test:root: 15 passed.pnpm verifypasses.Merge Danger
Door: two-way
The pool lives in process memory and no persisted format changes. Reverting restores one manager per session.
Blast Radius: lsp-lifecycle
/lsp stopandlsp_restartnow affect every session using the instance, and a crash in one session's request makes the instance unavailable in all of them.