feat: remember stopOnExit:false processes so skip and restart apply across OpenCode restarts - #2
Merged
Merged
Conversation
…cross OpenCode restarts
There was a problem hiding this comment.
🟡 Changes recommended
The new runQuery output cap is implemented using string length rather than bytes, which can exceed the intended resource limit and should be corrected before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces a “durable” subsystem that records stopOnExit: false processes to disk so subsequent OpenCode restarts can re-adopt (or restart) those processes instead of launching duplicates, and bumps the package to 1.2.0 with updated release/docs/tests to match.
Changes:
- Add durable registry + lock + per-platform process identity probing to enable cross-restart process re-adoption.
- Wire durable dependencies into the server/runtime and extend logging with durable-related events/causes.
- Update packaging, versioned documentation, and tests (including integration coverage) for the new behavior and the
1.2.0release.
File summaries
| File | Description |
|---|---|
| tests/workflows.test.ts | Asserts durable tests don’t narrow the existing workflow matrix/suite. |
| tests/server.test.ts | Adds coverage for durable wiring, hashing, and dependency gating. |
| tests/release-package.test.ts | Updates release manifest expectations and packaged file list. |
| tests/release-draft.test.ts | Updates release environment/tag expectations for 1.2.0. |
| tests/readme.test.ts | Enforces new README section/content for durable behavior and migration. |
| tests/process-identity.test.ts | New unit tests for process identity tokens/probing across OSes. |
| tests/manifest.test.ts | Updates manifest expectations (version/homepage). |
| tests/logger.test.ts | Adds durable event formatting + durable-unavailable skip coverage. |
| tests/helpers/core-fixtures.ts | New shared fixtures (registry/identity/process fakes) for core tests. |
| tests/fixtures/durable-child.mjs | New long-lived child fixture for durable integration tests. |
| tests/durable-registry.test.ts | New tests for registry root resolution, validation, and locking. |
| tests/durable-integration.test.ts | New integration tests covering re-adoption/restart with real OS processes. |
| tests/core.test.ts | Refactors to use shared fixtures. |
| tests/community-files.test.ts | Updates bug template placeholder version. |
| src/server.ts | Instantiates identity + durable registry and passes them into server deps. |
| src/server-internal.ts | Builds/threads durable run options (owner identity + project hash) into core. |
| src/process-tree.ts | Switches error-code extraction to shared helper. |
| src/process-identity.ts | New per-platform process identity + probe controller implementation. |
| src/logger.ts | Adds durable event types and formatting. |
| src/error-code.ts | New shared getErrorCode helper. |
| src/durable-registry.ts | New durable registry (read/write/quarantine + hashing + state root). |
| src/durable-lock.ts | New cross-process lock with guarded reclaim logic. |
| scripts/release-package.mjs | Updates package version and required release paths. |
| README.md | Documents cross-restart durability, registry storage, and upgrade steps. |
| package.json | Bumps version/homepage to 1.2.0. |
| .gitignore | Ignores local agent workspace directories. |
| .github/ISSUE_TEMPLATE/bug_report.yml | Updates plugin version placeholder to 1.2.0. |
| dist/server.js.map | Rebuilt artifact for server changes. |
| dist/server.js | Rebuilt artifact for server changes. |
| dist/server.d.ts.map | Rebuilt artifact for server type changes. |
| dist/server-internal.js.map | Rebuilt artifact for server-internal changes. |
| dist/server-internal.js | Rebuilt artifact for server-internal changes. |
| dist/server-internal.d.ts.map | Rebuilt artifact for server-internal type changes. |
| dist/server-internal.d.ts | Rebuilt artifact for server-internal type changes. |
| dist/process-tree.js | Rebuilt artifact for process-tree changes. |
| dist/process-tree.d.ts.map | Rebuilt artifact for process-tree type changes. |
| dist/process-identity.js.map | New built artifact for process identity. |
| dist/process-identity.js | New built artifact for process identity. |
| dist/process-identity.d.ts.map | New built artifact for process identity types. |
| dist/process-identity.d.ts | New built artifact for process identity types. |
| dist/logger.js | Rebuilt artifact for logger changes. |
| dist/logger.d.ts.map | Rebuilt artifact for logger type changes. |
| dist/logger.d.ts | Rebuilt artifact for logger type changes. |
| dist/error-code.js.map | New built artifact for error-code helper. |
| dist/error-code.js | New built artifact for error-code helper. |
| dist/error-code.d.ts.map | New built artifact for error-code helper types. |
| dist/error-code.d.ts | New built artifact for error-code helper types. |
| dist/durable-registry.js.map | New built artifact for durable registry. |
| dist/durable-registry.js | New built artifact for durable registry. |
| dist/durable-registry.d.ts.map | New built artifact for durable registry types. |
| dist/durable-registry.d.ts | New built artifact for durable registry types. |
| dist/durable-lock.js.map | New built artifact for durable lock. |
| dist/durable-lock.js | New built artifact for durable lock. |
| dist/durable-lock.d.ts.map | New built artifact for durable lock types. |
| dist/durable-lock.d.ts | New built artifact for durable lock types. |
| dist/core.d.ts.map | Rebuilt artifact for core type changes (durable options/types). |
| dist/core.d.ts | Rebuilt artifact for core type changes (durable options/types). |
Review details
- Files reviewed: 29/64 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+168
to
+190
| let settled = false; | ||
| let output = ""; | ||
| let timer: ReturnType<typeof setTimeout> | undefined; | ||
|
|
||
| const settle = (outcome: QueryOutcome): void => { | ||
| if (settled) { | ||
| return; | ||
| } | ||
| settled = true; | ||
| if (timer !== undefined) { | ||
| clearTimeout(timer); | ||
| } | ||
| resolve(outcome); | ||
| }; | ||
|
|
||
| try { | ||
| child.stdout?.on("data", (chunk) => { | ||
| if (output.length < MAX_QUERY_OUTPUT_BYTES) { | ||
| const text = | ||
| typeof chunk === "string" ? chunk : chunk.toString("utf8"); | ||
| output += text.slice(0, MAX_QUERY_OUTPUT_BYTES - output.length); | ||
| } | ||
| }); |
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.
No description provided.