@openchamber/web 1.21.0 → 1.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.test.js +35 -0
- package/bin/lib/DOCUMENTATION.md +12 -0
- package/bin/lib/cli-settings-accessors.js +111 -0
- package/bin/lib/cli-settings-accessors.test.js +189 -0
- package/bin/lib/cli-startup.js +29 -9
- package/bin/lib/commands-connect-url.js +12 -14
- package/dist/assets/{CodeMirrorCommentWidgets-C2BopIs3.js → CodeMirrorCommentWidgets-CPvfxh0N.js} +1 -1
- package/dist/assets/CommitSection-CC5mFzO2.js +1 -0
- package/dist/assets/DiffView-6xGdyI0n.js +4 -0
- package/dist/assets/FilesView-Bm3vT63N.js +17 -0
- package/dist/assets/GitView-B6y1Y69c.js +6 -0
- package/dist/assets/{JsonTreeView-osju7J70.js → JsonTreeView-rwHz84MX.js} +1 -1
- package/dist/assets/LinearIssuesView-B0UM_Rkx.js +1 -0
- package/dist/assets/MarkdownImageGallery-sGilV9Hs.js +1 -0
- package/dist/assets/MarkdownRendererImpl--4sRsKBn.js +12 -0
- package/dist/assets/OnboardingScreen-CECL_Cms.js +1 -0
- package/dist/assets/{PatchDiff-Dan3mADn.js → PatchDiff-BGPl1s-U.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CGoI2v0q.js → PierreDiffViewer-Cvz9Z-io.js} +2 -2
- package/dist/assets/PlanView-BFMsnHk3.js +5 -0
- package/dist/assets/SettingsView-_Gtn5SdT.js +28 -0
- package/dist/assets/{SettingsWindow-DXF-MTHG.js → SettingsWindow-C1Qa09YO.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DrCa1JRk.js → ToolOutputDialog-DzQlzMF4.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-B_tfvlNF.js → ToolPartDiffPreview-DfVOfwHy.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-CN_BctrR.js → VirtualizedFileDiff-DT5MDv-u.js} +1 -1
- package/dist/assets/WalkthroughView-D8sLH_M8.js +4 -0
- package/dist/assets/{computeVirtualFileMetrics-Gi1d5eU1.js → computeVirtualFileMetrics-DmpLWhll.js} +1 -1
- package/dist/assets/{contextPanelEmbeddedChat-CpzVNWAv.js → contextPanelEmbeddedChat-BK78t3M_.js} +1 -1
- package/dist/assets/de-C3luvSd_.js +9 -0
- package/dist/assets/es-CmU4HLv9.js +15 -0
- package/dist/assets/fr-Bgyni40l.js +13 -0
- package/dist/assets/index-C57jT0Sa.css +1 -0
- package/dist/assets/{index-Brm3X9rs.js → index-CWYs7sMK.js} +1 -1
- package/dist/assets/index-b0zDkWyg.js +7 -0
- package/dist/assets/{isDiffPlainText-pH9kAJQH.js → isDiffPlainText-BO_q5ezD.js} +1 -1
- package/dist/assets/{isFilePlainText-CVKy_dgB.js → isFilePlainText-D8qPqUAf.js} +1 -1
- package/dist/assets/ja-C1ImKinT.js +15 -0
- package/dist/assets/ko-CP7OdxYH.js +15 -0
- package/dist/assets/main-D4rd8Hy5.js +928 -0
- package/dist/assets/{main-vUCh0VB0.js → main-D7fwjW2z.js} +2 -2
- package/dist/assets/{markdown-shiki.worker-CKGJ1J33.js → markdown-shiki.worker-D5fBU-lw.js} +5 -5
- package/dist/assets/markdownCore-BcmkWZPO.js +3 -0
- package/dist/assets/{miniChat-BlzGEYgE.js → miniChat-D5rraz-g.js} +2 -2
- package/dist/assets/{mobile-CkX6H-IT.js → mobile-Cg_DE3KL.js} +2 -2
- package/dist/assets/{patchFileDiff-BCTsE43U.js → patchFileDiff-Bpql0QGw.js} +3 -3
- package/dist/assets/pl-DQYSiGYX.js +15 -0
- package/dist/assets/pt-BR-DytpsW4M.js +15 -0
- package/dist/assets/{renderElectronMiniChatApp-CJYe_KOL.js → renderElectronMiniChatApp-B_Bn7BbN.js} +2 -2
- package/dist/assets/renderMobileApp-DLfxMzGJ.js +25 -0
- package/dist/assets/runtimeEndpointReset-HlRmXFGW.js +16 -0
- package/dist/assets/scheduledTasksApi-BPvxrynl.js +1 -0
- package/dist/assets/{shikiHighlight-BgTPSITe.js → shikiHighlight-CFAVs_lu.js} +1 -1
- package/dist/assets/tr-aizaUvft.js +6 -0
- package/dist/assets/uk-DwnRxJZd.js +15 -0
- package/dist/assets/useAppFontEffects-DWXGRUPZ.js +7310 -0
- package/dist/assets/{useInlineCommentController-DFFv0hae.js → useInlineCommentController-Cc0OCXr0.js} +2 -2
- package/dist/assets/useRootScrollLock-BFZtfciC.js +1 -0
- package/dist/assets/{vendor-base-ui-_6j2xOWl.js → vendor-base-ui-BeMD8X_w.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-DkQX2EBa.js → vendor-codemirror-language-data-BGFszm8n.js} +2 -2
- package/dist/assets/{vendor-floating-ui-core-CXmKXOXc.js → vendor-floating-ui-core-PuGzNPnN.js} +1 -1
- package/dist/assets/{vendor-floating-ui-dom-WyXykhNi.js → vendor-floating-ui-dom-BTvzWks8.js} +1 -1
- package/dist/assets/{vendor-floating-ui-react-dom-DKpLs02S.js → vendor-floating-ui-react-dom-DxYCWdHj.js} +1 -1
- package/dist/assets/{vendor-floating-ui-utils-BzXdqYpP.js → vendor-floating-ui-utils-D6FqdtJt.js} +1 -1
- package/dist/assets/vendor-linkify-it-DZCzzDkK.js +1 -0
- package/dist/assets/vendor-marked-linkify-it-CXI_LHIE.js +1 -0
- package/dist/assets/vendor-uc.micro-BAd0H0z4.js +1 -0
- package/dist/assets/{web-components-DLnGY4fs.js → web-components-CD-GFayc.js} +4 -4
- package/dist/assets/zh-CN-UDNMxm7r.js +15 -0
- package/dist/assets/zh-TW-BsswdYL-.js +15 -0
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/dist/site.webmanifest +1 -1
- package/dist/sw.js +1 -1
- package/package.json +2 -2
- package/public/site.webmanifest +1 -1
- package/server/index.js +6 -2
- package/server/lib/cloudflare-tunnel.js +1 -1
- package/server/lib/dictation/DOCUMENTATION.md +19 -6
- package/server/lib/dictation/local/model-catalog.js +220 -0
- package/server/lib/dictation/local/model-catalog.test.js +42 -0
- package/server/lib/dictation/local/sherpa-tts.js +41 -20
- package/server/lib/dictation/local/worker-process.js +2 -0
- package/server/lib/dictation/runtime.js +4 -0
- package/server/lib/dictation/service.js +27 -4
- package/server/lib/fs/DOCUMENTATION.md +5 -0
- package/server/lib/fs/routes.js +150 -0
- package/server/lib/fs/routes.test.js +308 -3
- package/server/lib/git/DOCUMENTATION.md +4 -3
- package/server/lib/git/service.js +128 -6
- package/server/lib/git/service.test.js +191 -1
- package/server/lib/linear/DOCUMENTATION.md +97 -0
- package/server/lib/linear/OAUTH-BROKER-HANDOFF.md +91 -0
- package/server/lib/linear/auth.js +436 -0
- package/server/lib/linear/auth.test.js +242 -0
- package/server/lib/linear/client.js +191 -0
- package/server/lib/linear/index.js +61 -0
- package/server/lib/linear/issues.js +499 -0
- package/server/lib/linear/issues.test.js +512 -0
- package/server/lib/linear/mapping.js +188 -0
- package/server/lib/linear/mapping.test.js +147 -0
- package/server/lib/linear/oauth.js +345 -0
- package/server/lib/linear/oauth.test.js +166 -0
- package/server/lib/linear/parse.js +23 -0
- package/server/lib/linear/routes.js +432 -0
- package/server/lib/linear/routes.test.js +661 -0
- package/server/lib/linear/status-runtime.js +64 -0
- package/server/lib/linear/status-runtime.test.js +167 -0
- package/server/lib/linear/status.js +280 -0
- package/server/lib/linear/status.test.js +271 -0
- package/server/lib/linear/teams.js +72 -0
- package/server/lib/linear/teams.test.js +94 -0
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
- package/server/lib/markdown-image-grants/routes.js +3 -1
- package/server/lib/markdown-image-grants/routes.test.js +14 -0
- package/server/lib/openchamber-sessions/routes.js +4 -1
- package/server/lib/openchamber-sessions/routes.test.js +23 -0
- package/server/lib/opencode/env-runtime.js +17 -1
- package/server/lib/opencode/env-runtime.test.js +56 -0
- package/server/lib/opencode/feature-routes-runtime.js +2 -0
- package/server/lib/opencode/lifecycle.js +48 -9
- package/server/lib/opencode/lifecycle.test.js +125 -1
- package/server/lib/opencode/managed-process-registry.d.ts +13 -0
- package/server/lib/opencode/managed-process-registry.js +213 -163
- package/server/lib/opencode/managed-process-registry.test.mjs +285 -0
- package/server/lib/opencode/project-directory-runtime.js +16 -11
- package/server/lib/opencode/project-directory-runtime.test.js +32 -12
- package/server/lib/opencode/pwa-manifest-routes.js +1 -1
- package/server/lib/opencode/routes-upgrade.test.js +96 -12
- package/server/lib/opencode/routes.js +53 -5
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +10 -0
- package/server/lib/opencode/static-routes-runtime.js +3 -3
- package/server/lib/opencode/theme-runtime.js +1 -1
- package/server/lib/opencode/theme-runtime.test.js +129 -0
- package/server/lib/projects/project-config.js +33 -5
- package/server/lib/projects/project-config.test.js +85 -0
- package/server/lib/quota/DOCUMENTATION.md +19 -0
- package/server/lib/quota/providers/copilot.js +26 -10
- package/server/lib/quota/providers/copilot.test.js +78 -0
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +7 -0
- package/server/lib/small-model/DOCUMENTATION.md +11 -5
- package/server/lib/small-model/call.js +64 -20
- package/server/lib/small-model/call.test.js +184 -2
- package/server/lib/tts/DOCUMENTATION.md +1 -0
- package/server/lib/tts/language-detect.js +210 -0
- package/server/lib/tts/language-detect.test.js +76 -0
- package/server/lib/tts/routes.js +23 -1
- package/server/lib/tts/routes.test.js +26 -0
- package/server/lib/tunnels/install-help.js +2 -2
- package/server/lib/tunnels/install-help.test.js +9 -0
- package/server/lib/walkthrough/languages.js +1 -0
- package/dist/assets/CommitSection-HJeMUAWb.js +0 -1
- package/dist/assets/DiffView-D5cvbEPb.js +0 -4
- package/dist/assets/FilesView-DPU8aNPL.js +0 -17
- package/dist/assets/GitView-Ct6xWrVH.js +0 -6
- package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +0 -1
- package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +0 -12
- package/dist/assets/OnboardingScreen-w2VG4fWY.js +0 -1
- package/dist/assets/PlanView-Dgg-WTEc.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +0 -1
- package/dist/assets/SettingsView-D9yRuFZw.js +0 -28
- package/dist/assets/WalkthroughView-D9Q4lr5x.js +0 -4
- package/dist/assets/de-B_LdJwEM.js +0 -9
- package/dist/assets/es-CubfsAYV.js +0 -15
- package/dist/assets/fr-5qJM0nFS.js +0 -13
- package/dist/assets/index-BW82eK5v.css +0 -1
- package/dist/assets/index-rlLjZUM5.js +0 -7
- package/dist/assets/ja-DJYIBUlH.js +0 -15
- package/dist/assets/ko-DcUBkB7y.js +0 -15
- package/dist/assets/main-DLBxKIoX.js +0 -926
- package/dist/assets/markdownCore-DG6GHLF4.js +0 -3
- package/dist/assets/pl-rB6BLcio.js +0 -15
- package/dist/assets/pt-BR-DcwtlO-o.js +0 -15
- package/dist/assets/renderMobileApp-hQJTnr8B.js +0 -25
- package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +0 -15
- package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +0 -1
- package/dist/assets/uk-INZlFD9A.js +0 -15
- package/dist/assets/useAppFontEffects-Cll4gnsh.js +0 -7268
- package/dist/assets/zh-CN-Dzda8xa1.js +0 -15
- package/dist/assets/zh-TW-Cwn3rNYZ.js +0 -15
|
@@ -112,8 +112,45 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
112
112
|
now = Date.now,
|
|
113
113
|
} = deps;
|
|
114
114
|
|
|
115
|
+
const killProcessOnPortWin32 = (port) => {
|
|
116
|
+
try {
|
|
117
|
+
// Get-NetTCPConnection reads the same locale-independent WinNT API
|
|
118
|
+
// netstat's display layer translates (e.g. "LISTENING" renders as
|
|
119
|
+
// "ABHÖREN"/"ÉCOUTE"/"ESCUTANDO" on non-English Windows), so this
|
|
120
|
+
// works regardless of the OS display language.
|
|
121
|
+
const result = spawnSync(
|
|
122
|
+
'powershell',
|
|
123
|
+
[
|
|
124
|
+
'-NoProfile',
|
|
125
|
+
'-NonInteractive',
|
|
126
|
+
'-Command',
|
|
127
|
+
`Get-NetTCPConnection -State Listen -LocalPort ${Number.parseInt(port, 10)} -ErrorAction SilentlyContinue | Select-Object -ExpandProperty OwningProcess`,
|
|
128
|
+
],
|
|
129
|
+
{ encoding: 'utf8', timeout: 5000, windowsHide: true }
|
|
130
|
+
);
|
|
131
|
+
const output = result.stdout || '';
|
|
132
|
+
const myPid = process.pid;
|
|
133
|
+
const pids = new Set();
|
|
134
|
+
for (const line of output.split(/\r?\n/)) {
|
|
135
|
+
const pid = Number.parseInt(line.trim(), 10);
|
|
136
|
+
if (pid && pid !== myPid) pids.add(pid);
|
|
137
|
+
}
|
|
138
|
+
for (const pid of pids) {
|
|
139
|
+
try {
|
|
140
|
+
spawnSync('taskkill', ['/PID', String(pid), '/F'], { stdio: 'ignore', timeout: 3000, windowsHide: true });
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
} catch {
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
115
148
|
const killProcessOnPort = (port) => {
|
|
116
|
-
if (!port
|
|
149
|
+
if (!port) return;
|
|
150
|
+
if (process.platform === 'win32') {
|
|
151
|
+
killProcessOnPortWin32(port);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
117
154
|
try {
|
|
118
155
|
const result = spawnSync('lsof', ['-ti', `:${port}`], { encoding: 'utf8', timeout: 5000, windowsHide: true });
|
|
119
156
|
const output = result.stdout || '';
|
|
@@ -324,7 +361,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
324
361
|
// Drop it from the registry only once it has actually exited, so a child
|
|
325
362
|
// that survived teardown stays eligible for the next run's reaper.
|
|
326
363
|
if (Number.isInteger(pid) && hasChildProcessExited(child)) {
|
|
327
|
-
unregisterManagedProcess(pid);
|
|
364
|
+
await unregisterManagedProcess(pid);
|
|
328
365
|
}
|
|
329
366
|
}
|
|
330
367
|
};
|
|
@@ -477,7 +514,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
477
514
|
// actual host (Electron sets OPENCHAMBER_RUNTIME='desktop'; the standalone
|
|
478
515
|
// web CLI leaves it unset → 'web'; SSH remote → 'ssh-remote') rather than a
|
|
479
516
|
// hardcoded label, matching the server's existing runtimeName convention.
|
|
480
|
-
registerManagedProcess({
|
|
517
|
+
await registerManagedProcess({
|
|
481
518
|
pid: child.pid,
|
|
482
519
|
ownerPid: process.pid,
|
|
483
520
|
port,
|
|
@@ -792,11 +829,12 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
792
829
|
|
|
793
830
|
if (state.isExternalOpenCode) {
|
|
794
831
|
console.log('Re-probing external OpenCode server...');
|
|
795
|
-
const probePort = state.openCodePort
|
|
832
|
+
const probePort = state.openCodePort ?? env.ENV_EFFECTIVE_PORT ?? 4096;
|
|
796
833
|
const probeOrigin = state.openCodeBaseUrl ?? env.ENV_CONFIGURED_OPENCODE_HOST?.origin;
|
|
797
834
|
const healthy = await probeExternalOpenCode(probePort, probeOrigin);
|
|
798
835
|
if (healthy) {
|
|
799
836
|
console.log(`External OpenCode server on port ${probePort} is healthy`);
|
|
837
|
+
state.openCodeBaseUrl = probeOrigin ?? null;
|
|
800
838
|
setOpenCodePort(probePort);
|
|
801
839
|
state.isOpenCodeReady = true;
|
|
802
840
|
state.lastOpenCodeError = null;
|
|
@@ -859,10 +897,11 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
859
897
|
}
|
|
860
898
|
|
|
861
899
|
// The restart may have landed on a NEW port (the old one can remain
|
|
862
|
-
// occupied
|
|
863
|
-
//
|
|
864
|
-
// the UI silent forever, so rebind them to the
|
|
865
|
-
// effort: a failure here must not fail the restart
|
|
900
|
+
// occupied if killProcessOnPort/waitForPortRelease didn't free it in
|
|
901
|
+
// time, on any platform). Upstream event readers pinned to the old
|
|
902
|
+
// process would keep the UI silent forever, so rebind them to the
|
|
903
|
+
// current port. Best effort: a failure here must not fail the restart
|
|
904
|
+
// itself.
|
|
866
905
|
try {
|
|
867
906
|
onOpenCodeRestarted?.();
|
|
868
907
|
} catch (error) {
|
|
@@ -875,7 +914,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
875
914
|
} catch (error) {
|
|
876
915
|
console.error(`Failed to restart OpenCode: ${error.message}`);
|
|
877
916
|
state.lastOpenCodeError = error.message;
|
|
878
|
-
if (!env.
|
|
917
|
+
if (!env.ENV_EFFECTIVE_PORT) {
|
|
879
918
|
state.openCodePort = null;
|
|
880
919
|
syncToHmrState();
|
|
881
920
|
}
|
|
@@ -2,11 +2,17 @@ import { EventEmitter } from 'node:events';
|
|
|
2
2
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
const spawnMock = vi.fn();
|
|
5
|
+
const spawnSyncMock = vi.fn();
|
|
5
6
|
const recordStartupPerformanceMock = vi.fn();
|
|
6
7
|
|
|
7
8
|
vi.mock('node:child_process', () => ({
|
|
8
9
|
spawn: spawnMock,
|
|
9
|
-
spawnSync:
|
|
10
|
+
spawnSync: spawnSyncMock,
|
|
11
|
+
// `managed-process-registry.js` (imported transitively via lifecycle.js)
|
|
12
|
+
// calls `promisify(execFile)` at module load, so the mock must expose a
|
|
13
|
+
// function here. Lifecycle tests don't exercise the reaper path, so a plain
|
|
14
|
+
// stub is enough; the registry's best-effort writes are no-ops on errors.
|
|
15
|
+
execFile: vi.fn(),
|
|
10
16
|
}));
|
|
11
17
|
vi.mock('./startup-performance.js', () => ({
|
|
12
18
|
recordStartupPerformance: recordStartupPerformanceMock,
|
|
@@ -20,6 +26,7 @@ const originalFetch = globalThis.fetch;
|
|
|
20
26
|
|
|
21
27
|
afterEach(() => {
|
|
22
28
|
spawnMock.mockReset();
|
|
29
|
+
spawnSyncMock.mockReset();
|
|
23
30
|
recordStartupPerformanceMock.mockReset();
|
|
24
31
|
globalThis.fetch = originalFetch;
|
|
25
32
|
if (typeof originalOpencodeBinary === 'string') {
|
|
@@ -151,6 +158,56 @@ describe('OpenCode lifecycle', () => {
|
|
|
151
158
|
expect(terminalEvents).toHaveLength(1);
|
|
152
159
|
});
|
|
153
160
|
|
|
161
|
+
it('recovers an external OPENCODE_HOST connection using its configured endpoint', async () => {
|
|
162
|
+
const fetchMock = vi.fn(async () => ({
|
|
163
|
+
ok: true,
|
|
164
|
+
json: async () => ({ healthy: true }),
|
|
165
|
+
}));
|
|
166
|
+
globalThis.fetch = fetchMock;
|
|
167
|
+
const runtime = createRuntime({}, {
|
|
168
|
+
openCodePort: null,
|
|
169
|
+
openCodeBaseUrl: null,
|
|
170
|
+
isExternalOpenCode: true,
|
|
171
|
+
}, {
|
|
172
|
+
ENV_CONFIGURED_OPENCODE_PORT: null,
|
|
173
|
+
ENV_CONFIGURED_OPENCODE_HOST: { origin: 'http://seamus:4095', port: 4095 },
|
|
174
|
+
ENV_EFFECTIVE_PORT: 4095,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
await runtime.restartOpenCode();
|
|
178
|
+
|
|
179
|
+
expect(fetchMock).toHaveBeenCalledWith(
|
|
180
|
+
'http://seamus:4095/global/health',
|
|
181
|
+
expect.objectContaining({ method: 'GET' }),
|
|
182
|
+
);
|
|
183
|
+
expect(runtime.testState.openCodePort).toBe(4095);
|
|
184
|
+
expect(runtime.testState.openCodeBaseUrl).toBe('http://seamus:4095');
|
|
185
|
+
expect(runtime.testState.lastOpenCodeError).toBeNull();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('retains the OPENCODE_HOST port after an external re-probe fails', async () => {
|
|
189
|
+
globalThis.fetch = vi.fn(async () => ({
|
|
190
|
+
ok: false,
|
|
191
|
+
json: async () => null,
|
|
192
|
+
}));
|
|
193
|
+
const runtime = createRuntime({}, {
|
|
194
|
+
openCodePort: 4095,
|
|
195
|
+
openCodeBaseUrl: 'http://seamus:4095',
|
|
196
|
+
isExternalOpenCode: true,
|
|
197
|
+
}, {
|
|
198
|
+
ENV_CONFIGURED_OPENCODE_PORT: null,
|
|
199
|
+
ENV_CONFIGURED_OPENCODE_HOST: { origin: 'http://seamus:4095', port: 4095 },
|
|
200
|
+
ENV_EFFECTIVE_PORT: 4095,
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
await expect(runtime.restartOpenCode()).rejects.toThrow(
|
|
204
|
+
'External OpenCode server on port 4095 is not responding',
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
expect(runtime.testState.openCodePort).toBe(4095);
|
|
208
|
+
expect(runtime.testState.openCodeBaseUrl).toBe('http://seamus:4095');
|
|
209
|
+
});
|
|
210
|
+
|
|
154
211
|
it('warms recently used directories after a successful bootstrap', async () => {
|
|
155
212
|
const fetchMock = vi.fn(async () => ({
|
|
156
213
|
ok: true,
|
|
@@ -791,3 +848,70 @@ describe('OpenCode lifecycle', () => {
|
|
|
791
848
|
await server.close();
|
|
792
849
|
});
|
|
793
850
|
});
|
|
851
|
+
|
|
852
|
+
describe('killProcessOnPort on Windows', () => {
|
|
853
|
+
const originalPlatform = process.platform;
|
|
854
|
+
|
|
855
|
+
afterEach(() => {
|
|
856
|
+
Object.defineProperty(process, 'platform', { value: originalPlatform });
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
const setPlatform = (platform) => {
|
|
860
|
+
Object.defineProperty(process, 'platform', { value: platform, configurable: true });
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
it('force-kills the process listening on the target port via taskkill', () => {
|
|
864
|
+
setPlatform('win32');
|
|
865
|
+
const orphanPid = 54321;
|
|
866
|
+
spawnSyncMock.mockImplementation((cmd) => {
|
|
867
|
+
if (cmd === 'powershell') {
|
|
868
|
+
return { stdout: `${orphanPid}\r\n` };
|
|
869
|
+
}
|
|
870
|
+
return { stdout: '' };
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
const runtime = createRuntime();
|
|
874
|
+
runtime.killProcessOnPort(45678);
|
|
875
|
+
|
|
876
|
+
expect(spawnSyncMock).toHaveBeenCalledWith(
|
|
877
|
+
'powershell',
|
|
878
|
+
expect.arrayContaining([expect.stringContaining('-LocalPort 45678')]),
|
|
879
|
+
expect.objectContaining({ windowsHide: true })
|
|
880
|
+
);
|
|
881
|
+
expect(spawnSyncMock).toHaveBeenCalledWith(
|
|
882
|
+
'taskkill',
|
|
883
|
+
['/PID', String(orphanPid), '/F'],
|
|
884
|
+
expect.objectContaining({ windowsHide: true })
|
|
885
|
+
);
|
|
886
|
+
});
|
|
887
|
+
|
|
888
|
+
it('never force-kills its own process id', () => {
|
|
889
|
+
setPlatform('win32');
|
|
890
|
+
spawnSyncMock.mockImplementation((cmd) => {
|
|
891
|
+
if (cmd === 'powershell') {
|
|
892
|
+
return { stdout: `${process.pid}\r\n` };
|
|
893
|
+
}
|
|
894
|
+
return { stdout: '' };
|
|
895
|
+
});
|
|
896
|
+
|
|
897
|
+
const runtime = createRuntime();
|
|
898
|
+
runtime.killProcessOnPort(45678);
|
|
899
|
+
|
|
900
|
+
expect(spawnSyncMock).not.toHaveBeenCalledWith('taskkill', expect.anything(), expect.anything());
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
it('does nothing when no process is listening on the target port', () => {
|
|
904
|
+
setPlatform('win32');
|
|
905
|
+
spawnSyncMock.mockImplementation((cmd) => {
|
|
906
|
+
if (cmd === 'powershell') {
|
|
907
|
+
return { stdout: '' };
|
|
908
|
+
}
|
|
909
|
+
return { stdout: '' };
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
const runtime = createRuntime();
|
|
913
|
+
runtime.killProcessOnPort(45678);
|
|
914
|
+
|
|
915
|
+
expect(spawnSyncMock).not.toHaveBeenCalledWith('taskkill', expect.anything(), expect.anything());
|
|
916
|
+
});
|
|
917
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function registerManagedProcess(entry: {
|
|
2
|
+
pid?: number;
|
|
3
|
+
ownerPid?: number;
|
|
4
|
+
port?: number | null;
|
|
5
|
+
binary?: string | null;
|
|
6
|
+
runtime?: string;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
|
|
9
|
+
export function unregisterManagedProcess(pid?: number): Promise<void>;
|
|
10
|
+
|
|
11
|
+
export function reapOrphanedProcesses(options?: {
|
|
12
|
+
log?: (message: string) => void;
|
|
13
|
+
}): Promise<{ inspected: number; reaped: number }>;
|