@openchamber/web 1.20.0 → 1.21.1
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-C36E738Y.js → CodeMirrorCommentWidgets-BGj8TJxW.js} +1 -1
- package/dist/assets/CommitSection-DwGiXyjf.js +1 -0
- package/dist/assets/DiffView-Db6bjVv1.js +4 -0
- package/dist/assets/FilesView-DQOa7Lgz.js +17 -0
- package/dist/assets/GitView-CHzJxTi0.js +6 -0
- package/dist/assets/{JsonTreeView-KnXFN2A-.js → JsonTreeView-CggOsLot.js} +1 -1
- package/dist/assets/MarkdownImageGallery-DoZpaHev.js +1 -0
- package/dist/assets/MarkdownRendererImpl-B5Y5xCOz.js +12 -0
- package/dist/assets/OnboardingScreen-C98d69Fp.js +1 -0
- package/dist/assets/{PatchDiff-BzVOVog8.js → PatchDiff-DJYMUiXA.js} +1 -1
- package/dist/assets/PierreDiffViewer-CY2bx_SB.js +157 -0
- package/dist/assets/PlanView-PkiOY_9H.js +5 -0
- package/dist/assets/SettingsView-D-K3ELCM.js +28 -0
- package/dist/assets/SettingsWindow-oyOm2fHR.js +1 -0
- package/dist/assets/{ToolOutputDialog-BB1c--Zr.js → ToolOutputDialog-lKyeQTPL.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-DaOIDISD.js → ToolPartDiffPreview-C7kBQNAA.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-lESMT-2b.js → VirtualizedFileDiff-BP7ebDFF.js} +4 -4
- package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
- package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
- package/dist/assets/{WalkthroughView-CaSYE0lw.js → WalkthroughView-MuJodAHD.js} +2 -2
- package/dist/assets/{computeVirtualFileMetrics-DkRR5b75.js → computeVirtualFileMetrics-CZ0xPeaT.js} +2 -2
- package/dist/assets/contextPanelEmbeddedChat-C9abMBTb.js +1 -0
- package/dist/assets/de-CEoCz3j6.js +9 -0
- package/dist/assets/es-DwyXCqaL.js +15 -0
- package/dist/assets/fr-CS7Csln9.js +13 -0
- package/dist/assets/index-CUKcHnUA.css +1 -0
- package/dist/assets/index-CaPAjwXQ.js +1 -0
- package/dist/assets/index-DIvDEKE-.js +7 -0
- package/dist/assets/{isDiffPlainText-BG53Ixxy.js → isDiffPlainText-ZBvDxhVB.js} +1 -1
- package/dist/assets/{isFilePlainText-BbV-39jl.js → isFilePlainText-DiLRrkJr.js} +1 -1
- package/dist/assets/ja-vnwqLcx6.js +15 -0
- package/dist/assets/ko-CXuSfZv5.js +15 -0
- package/dist/assets/main-D5RWr6sJ.js +2 -0
- package/dist/assets/main-DLlfDjQ_.js +926 -0
- package/dist/assets/{markdown-shiki.worker-CKGJ1J33.js → markdown-shiki.worker-D5fBU-lw.js} +5 -5
- package/dist/assets/markdownCore-CcTcLsQF.js +3 -0
- package/dist/assets/{miniChat-ldEghBLB.js → miniChat-CqR3icsk.js} +2 -2
- package/dist/assets/mobile-RN_UTTlB.js +2 -0
- package/dist/assets/{patchFileDiff-BcFaMtMu.js → patchFileDiff-CjRR5ESs.js} +1 -1
- package/dist/assets/pl-BJxry0Mi.js +15 -0
- package/dist/assets/pt-BR-DxLmkhdv.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-1wC94fQK.js +2 -0
- package/dist/assets/renderMobileApp-ltva2Plg.js +25 -0
- package/dist/assets/runtimeEndpointReset-D6SmNZaP.js +15 -0
- package/dist/assets/scheduledTasksApi-mjMDet_H.js +1 -0
- package/dist/assets/{shikiHighlight-DCT2Sq_z.js → shikiHighlight-fGmFkxAM.js} +1 -1
- package/dist/assets/tr-5Mk_hQ2Q.js +6 -0
- package/dist/assets/uk-ClgQjmlw.js +15 -0
- package/dist/assets/{useAppFontEffects-B53Rb6m7.js → useAppFontEffects-KP8_yiGW.js} +176 -184
- package/dist/assets/useInlineCommentController-HIjtuhxD.js +2 -0
- package/dist/assets/useRootScrollLock-BSiQ5F75.js +1 -0
- package/dist/assets/{vendor-base-ui-DsHmyMwp.js → vendor-base-ui-BeMD8X_w.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-vch3tJ4c.js → vendor-codemirror-language-data-DrTPkHl4.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-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
- package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
- 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-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
- package/dist/assets/vendor-uc.micro-BAd0H0z4.js +1 -0
- package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
- package/dist/assets/{web-components-pcwCTWjC.js → web-components-DOXvU-tB.js} +4 -4
- package/dist/assets/zh-CN-Ba6y8H-i.js +15 -0
- package/dist/assets/zh-TW-Dv8yyhN1.js +15 -0
- package/dist/index.html +7 -7
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/dist/site.webmanifest +1 -1
- package/dist/sw.js +1 -1
- package/package.json +4 -4
- package/public/site.webmanifest +1 -1
- package/server/index.js +10 -2
- package/server/lib/client-auth/pairing.js +8 -7
- package/server/lib/client-auth/pairing.test.js +5 -1
- package/server/lib/client-auth/remote-clients.js +9 -1
- package/server/lib/client-auth/remote-clients.test.js +17 -0
- package/server/lib/cloudflare-tunnel.js +1 -1
- package/server/lib/fs/DOCUMENTATION.md +1 -0
- package/server/lib/fs/routes.js +21 -0
- package/server/lib/fs/routes.test.js +89 -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/github/pr-status.js +10 -1
- 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/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/theme-runtime.js +1 -1
- package/server/lib/opencode/theme-runtime.test.js +129 -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/quota/providers/index.js +4 -18
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/service.js +34 -2
- package/server/lib/relay/service.test.js +69 -0
- package/server/lib/session-goal/runtime.js +2 -1
- package/server/lib/session-goal/runtime.test.js +4 -2
- 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/terminal/DOCUMENTATION.md +2 -0
- package/server/lib/terminal/runtime.js +29 -1
- package/server/lib/terminal/runtime.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/ui-auth/ui-auth.js +2 -2
- package/server/lib/ui-auth/ui-auth.test.js +2 -2
- package/server/lib/walkthrough/languages.js +1 -0
- package/dist/assets/CommitSection-C-F3AX6D.js +0 -1
- package/dist/assets/DiagramEditor-BPECg1jS.js +0 -1
- package/dist/assets/DiagramView-D0YNMix8.js +0 -1
- package/dist/assets/DiffView-BHWaMYCC.js +0 -4
- package/dist/assets/FilesView-NMBCW2Tm.js +0 -14
- package/dist/assets/GitView-Rp8P1KEI.js +0 -6
- package/dist/assets/MarkdownImageGallery-BMn3mtor.js +0 -1
- package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +0 -12
- package/dist/assets/OnboardingScreen-CenIeD4v.js +0 -1
- package/dist/assets/PierreDiffViewer-Dlby4XqT.js +0 -136
- package/dist/assets/PlanView-Czu1KMJa.js +0 -4
- package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +0 -1
- package/dist/assets/SettingsView-B6vmuf-c.js +0 -28
- package/dist/assets/SettingsWindow-CauZpdD3.js +0 -1
- package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +0 -1
- package/dist/assets/de-DFdX3ABv.js +0 -9
- package/dist/assets/es-iC-FKvV9.js +0 -15
- package/dist/assets/fr-BBbi_1AL.js +0 -13
- package/dist/assets/index-BiEgzzkg.js +0 -1
- package/dist/assets/index-Cwmuwk3V.js +0 -7
- package/dist/assets/index-GNm1wgUH.css +0 -1
- package/dist/assets/ja-DQLQJL2J.js +0 -15
- package/dist/assets/ko-BeElEB4Y.js +0 -15
- package/dist/assets/main-Dpzo18z7.js +0 -2
- package/dist/assets/main-WMjtYzJs.js +0 -921
- package/dist/assets/markdownCore--tDmyI_v.js +0 -2
- package/dist/assets/mobile-Dk-VGreF.js +0 -2
- package/dist/assets/pl-CLHt2_vV.js +0 -15
- package/dist/assets/pt-BR-C_MPUq7e.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +0 -2
- package/dist/assets/renderMobileApp-CDfHS5rr.js +0 -25
- package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +0 -15
- package/dist/assets/scheduledTasksApi-BFSlqgnG.js +0 -1
- package/dist/assets/uk-PhsC-c4-.js +0 -15
- package/dist/assets/useInlineCommentController-DSfrIBKT.js +0 -2
- package/dist/assets/vendor-zod-C9ioTTSo.js +0 -39
- package/dist/assets/zh-CN-wF-NOFHM.js +0 -15
- package/dist/assets/zh-TW-4m4-A7rT.js +0 -15
- package/server/lib/quota/providers/command-code.js +0 -90
- package/server/lib/quota/providers/command-code.test.js +0 -85
|
@@ -2,10 +2,11 @@ import { execFileSync } from 'node:child_process';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
-
import { afterEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { afterAll, afterEach, describe, expect, it, vi } from 'vitest';
|
|
6
6
|
import simpleGit from 'simple-git';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
|
+
checkoutBranch,
|
|
9
10
|
checkoutCommit,
|
|
10
11
|
cherryPick,
|
|
11
12
|
createWorktree,
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
getBranches,
|
|
14
15
|
getRangeDiff,
|
|
15
16
|
getStatus,
|
|
17
|
+
getWorktrees,
|
|
16
18
|
isGitRepository,
|
|
17
19
|
populateWorktreeWithLockRecovery,
|
|
18
20
|
removeWorktree,
|
|
@@ -463,6 +465,51 @@ describe('worktree root resolution', () => {
|
|
|
463
465
|
});
|
|
464
466
|
});
|
|
465
467
|
|
|
468
|
+
// ---------------------------------------------------------------------------
|
|
469
|
+
// getWorktrees
|
|
470
|
+
// ---------------------------------------------------------------------------
|
|
471
|
+
|
|
472
|
+
describe('getWorktrees', () => {
|
|
473
|
+
if (!canRunGit()) {
|
|
474
|
+
it.skip('git binary not available', () => {});
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
479
|
+
|
|
480
|
+
afterEach(() => {
|
|
481
|
+
warnSpy.mockClear();
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
afterAll(() => {
|
|
485
|
+
warnSpy.mockRestore();
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
it('returns an empty list for a non-git directory without warning', async () => {
|
|
489
|
+
const nonGit = createTempDir();
|
|
490
|
+
|
|
491
|
+
const result = await getWorktrees(nonGit);
|
|
492
|
+
|
|
493
|
+
expect(result).toEqual([]);
|
|
494
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
it('returns the worktrees for a real git repository', async () => {
|
|
498
|
+
const repo = createTempDir();
|
|
499
|
+
runGit(repo, ['init', '-b', 'main']);
|
|
500
|
+
runGit(repo, ['config', 'user.email', 'test@example.com']);
|
|
501
|
+
runGit(repo, ['config', 'user.name', 'Test User']);
|
|
502
|
+
fs.writeFileSync(path.join(repo, 'README.md'), '# Test\n');
|
|
503
|
+
runGit(repo, ['add', 'README.md']);
|
|
504
|
+
runGit(repo, ['commit', '-m', 'init']);
|
|
505
|
+
|
|
506
|
+
const result = await getWorktrees(repo);
|
|
507
|
+
|
|
508
|
+
expect(Array.isArray(result)).toBe(true);
|
|
509
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
|
|
466
513
|
// ---------------------------------------------------------------------------
|
|
467
514
|
// createWorktree
|
|
468
515
|
// ---------------------------------------------------------------------------
|
|
@@ -1006,6 +1053,92 @@ describe('checkoutCommit', () => {
|
|
|
1006
1053
|
});
|
|
1007
1054
|
});
|
|
1008
1055
|
|
|
1056
|
+
// ---------------------------------------------------------------------------
|
|
1057
|
+
// checkoutBranch
|
|
1058
|
+
// ---------------------------------------------------------------------------
|
|
1059
|
+
|
|
1060
|
+
describe('checkoutBranch', () => {
|
|
1061
|
+
it('checks out a local branch by name', async () => {
|
|
1062
|
+
const { repository } = createRepositoryWithRemote();
|
|
1063
|
+
runGit(repository, ['branch', 'feature']);
|
|
1064
|
+
|
|
1065
|
+
const result = await checkoutBranch(repository, 'feature');
|
|
1066
|
+
|
|
1067
|
+
expect(result).toEqual({ success: true, branch: 'feature' });
|
|
1068
|
+
expect(runGit(repository, ['rev-parse', '--abbrev-ref', 'HEAD']).trim()).toBe('feature');
|
|
1069
|
+
});
|
|
1070
|
+
|
|
1071
|
+
it('creates a tracking local branch instead of detaching HEAD on a remote branch', async () => {
|
|
1072
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'react' });
|
|
1073
|
+
|
|
1074
|
+
const result = await checkoutBranch(repository, 'origin/react');
|
|
1075
|
+
|
|
1076
|
+
expect(result).toEqual({ success: true, branch: 'react' });
|
|
1077
|
+
expect(runGit(repository, ['rev-parse', '--abbrev-ref', 'HEAD']).trim()).toBe('react');
|
|
1078
|
+
expect(runGit(repository, ['rev-parse', '--abbrev-ref', 'react@{upstream}']).trim()).toBe('origin/react');
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
it('checks out the existing local branch when a remote branch is picked', async () => {
|
|
1082
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'react' });
|
|
1083
|
+
runGit(repository, ['branch', 'react', 'origin/react']);
|
|
1084
|
+
|
|
1085
|
+
const result = await checkoutBranch(repository, 'origin/react');
|
|
1086
|
+
|
|
1087
|
+
expect(result).toEqual({ success: true, branch: 'react' });
|
|
1088
|
+
expect(runGit(repository, ['rev-parse', '--abbrev-ref', 'HEAD']).trim()).toBe('react');
|
|
1089
|
+
});
|
|
1090
|
+
|
|
1091
|
+
it('accepts the remotes/ prefixed form of a remote branch', async () => {
|
|
1092
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'react' });
|
|
1093
|
+
|
|
1094
|
+
const result = await checkoutBranch(repository, 'remotes/origin/react');
|
|
1095
|
+
|
|
1096
|
+
expect(result).toEqual({ success: true, branch: 'react' });
|
|
1097
|
+
expect(runGit(repository, ['rev-parse', '--abbrev-ref', 'HEAD']).trim()).toBe('react');
|
|
1098
|
+
});
|
|
1099
|
+
|
|
1100
|
+
it('prefers a local branch whose name looks like a remote ref', async () => {
|
|
1101
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'react' });
|
|
1102
|
+
runGit(repository, ['branch', 'origin/react']);
|
|
1103
|
+
|
|
1104
|
+
const result = await checkoutBranch(repository, 'origin/react');
|
|
1105
|
+
|
|
1106
|
+
expect(result).toEqual({ success: true, branch: 'origin/react' });
|
|
1107
|
+
expect(runGit(repository, ['symbolic-ref', 'HEAD']).trim()).toBe('refs/heads/origin/react');
|
|
1108
|
+
});
|
|
1109
|
+
|
|
1110
|
+
it('rejects an unknown branch', async () => {
|
|
1111
|
+
const { repository } = createRepositoryWithRemote();
|
|
1112
|
+
await expect(checkoutBranch(repository, 'does-not-exist')).rejects.toThrow();
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
it('fetches a remote-only branch that was never fetched locally (#2735)', async () => {
|
|
1116
|
+
const { repository, remote } = createRepositoryWithRemote({ defaultBranch: 'react' });
|
|
1117
|
+
// A collaborator pushes straight to the remote; this repository never
|
|
1118
|
+
// fetches, so `remotes/origin/collab` is listed (#2098) with no local ref.
|
|
1119
|
+
const collaborator = createTempDir();
|
|
1120
|
+
runGit(collaborator, ['clone', remote, '.']);
|
|
1121
|
+
runGit(collaborator, ['config', 'user.email', 'test@example.com']);
|
|
1122
|
+
runGit(collaborator, ['config', 'user.name', 'Test']);
|
|
1123
|
+
runGit(collaborator, ['checkout', '-b', 'collab']);
|
|
1124
|
+
runGit(collaborator, ['push', 'origin', 'collab']);
|
|
1125
|
+
|
|
1126
|
+
const result = await checkoutBranch(repository, 'remotes/origin/collab');
|
|
1127
|
+
|
|
1128
|
+
expect(result).toEqual({ success: true, branch: 'collab' });
|
|
1129
|
+
expect(runGit(repository, ['rev-parse', '--abbrev-ref', 'HEAD']).trim()).toBe('collab');
|
|
1130
|
+
expect(runGit(repository, ['rev-parse', '--abbrev-ref', 'collab@{upstream}']).trim()).toBe('origin/collab');
|
|
1131
|
+
});
|
|
1132
|
+
|
|
1133
|
+
it('reports a clear failure when the remote branch no longer exists', async () => {
|
|
1134
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'react' });
|
|
1135
|
+
|
|
1136
|
+
await expect(checkoutBranch(repository, 'remotes/origin/never-pushed')).rejects.toThrow(
|
|
1137
|
+
/Failed to fetch never-pushed from origin/
|
|
1138
|
+
);
|
|
1139
|
+
});
|
|
1140
|
+
});
|
|
1141
|
+
|
|
1009
1142
|
// ---------------------------------------------------------------------------
|
|
1010
1143
|
// cherryPick
|
|
1011
1144
|
// ---------------------------------------------------------------------------
|
|
@@ -1322,6 +1455,47 @@ describe.runIf(canRunGit())('getBranches', () => {
|
|
|
1322
1455
|
// decide whether a base branch exists at all.
|
|
1323
1456
|
expect(branches.all).toContain('remotes/origin/react');
|
|
1324
1457
|
});
|
|
1458
|
+
|
|
1459
|
+
it('includes remote branches with no local tracking ref and prunes refs deleted on the remote (#2098)', async () => {
|
|
1460
|
+
const remote = createTempDir();
|
|
1461
|
+
runGit(remote, ['init', '--bare', '--initial-branch=main']);
|
|
1462
|
+
|
|
1463
|
+
const repository = createTempDir();
|
|
1464
|
+
runGit(repository, ['init', '-b', 'main']);
|
|
1465
|
+
runGit(repository, ['config', 'user.email', 'test@example.com']);
|
|
1466
|
+
runGit(repository, ['config', 'user.name', 'Test']);
|
|
1467
|
+
fs.writeFileSync(path.join(repository, 'README.md'), '# Test\n');
|
|
1468
|
+
runGit(repository, ['add', 'README.md']);
|
|
1469
|
+
runGit(repository, ['commit', '-m', 'init']);
|
|
1470
|
+
runGit(repository, ['remote', 'add', 'origin', remote]);
|
|
1471
|
+
runGit(repository, ['push', '-u', 'origin', 'main']);
|
|
1472
|
+
runGit(repository, ['checkout', '-b', 'feature-known']);
|
|
1473
|
+
runGit(repository, ['push', '-u', 'origin', 'feature-known']);
|
|
1474
|
+
// This tracking ref will go stale: the collaborator deletes the branch on
|
|
1475
|
+
// the remote below, and the list must prune it.
|
|
1476
|
+
runGit(repository, ['checkout', '-b', 'feature-stale']);
|
|
1477
|
+
runGit(repository, ['push', '-u', 'origin', 'feature-stale']);
|
|
1478
|
+
runGit(repository, ['checkout', 'main']);
|
|
1479
|
+
runGit(repository, ['branch', '-D', 'feature-stale']);
|
|
1480
|
+
|
|
1481
|
+
// A collaborator pushes a branch straight to the remote and deletes
|
|
1482
|
+
// another; this repository never fetches, so it has no local
|
|
1483
|
+
// remote-tracking ref for feature-remote-only.
|
|
1484
|
+
const collaborator = createTempDir();
|
|
1485
|
+
runGit(collaborator, ['clone', remote, '.']);
|
|
1486
|
+
runGit(collaborator, ['config', 'user.email', 'test@example.com']);
|
|
1487
|
+
runGit(collaborator, ['config', 'user.name', 'Test']);
|
|
1488
|
+
runGit(collaborator, ['checkout', '-b', 'feature-remote-only']);
|
|
1489
|
+
runGit(collaborator, ['push', 'origin', 'feature-remote-only']);
|
|
1490
|
+
runGit(collaborator, ['push', 'origin', ':feature-stale']);
|
|
1491
|
+
|
|
1492
|
+
const branches = await getBranches(repository);
|
|
1493
|
+
|
|
1494
|
+
expect(branches.all).toContain('remotes/origin/feature-remote-only');
|
|
1495
|
+
expect(branches.all).toContain('remotes/origin/feature-known');
|
|
1496
|
+
expect(branches.all).toContain('feature-known');
|
|
1497
|
+
expect(branches.all).not.toContain('remotes/origin/feature-stale');
|
|
1498
|
+
});
|
|
1325
1499
|
});
|
|
1326
1500
|
|
|
1327
1501
|
describe.runIf(canRunGit())('getRangeDiff', () => {
|
|
@@ -1337,6 +1511,14 @@ describe.runIf(canRunGit())('getRangeDiff', () => {
|
|
|
1337
1511
|
|
|
1338
1512
|
expect(diff).toContain('feature.txt');
|
|
1339
1513
|
});
|
|
1514
|
+
|
|
1515
|
+
it('names an unfetched remote-only ref instead of failing with git\'s ambiguous argument (#2735)', async () => {
|
|
1516
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'react' });
|
|
1517
|
+
|
|
1518
|
+
await expect(
|
|
1519
|
+
getRangeDiff(repository, { base: 'remotes/origin/never-fetched', head: 'next' })
|
|
1520
|
+
).rejects.toThrow(/is not available locally/);
|
|
1521
|
+
});
|
|
1340
1522
|
});
|
|
1341
1523
|
|
|
1342
1524
|
describe('parseBranchCreationSource', () => {
|
|
@@ -1354,6 +1536,14 @@ describe('parseBranchCreationSource', () => {
|
|
|
1354
1536
|
expect(parseBranchCreationSource(reflog)).toBeNull();
|
|
1355
1537
|
});
|
|
1356
1538
|
|
|
1539
|
+
it('returns null when the branch was created from the current HEAD without a named source', () => {
|
|
1540
|
+
// `git switch -c <branch>` / `git checkout -b <branch>` from the current
|
|
1541
|
+
// branch record `branch: Created from HEAD` in the reflog (git 2.x). The
|
|
1542
|
+
// source branch name is not recorded, so no base can be derived from it.
|
|
1543
|
+
const reflog = 'branch: Created from HEAD';
|
|
1544
|
+
expect(parseBranchCreationSource(reflog)).toBeNull();
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1357
1547
|
it('returns null when the branch was created from a raw commit', () => {
|
|
1358
1548
|
const reflog = 'branch: Created from 9a3b2c1d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b';
|
|
1359
1549
|
expect(parseBranchCreationSource(reflog)).toBeNull();
|
|
@@ -674,7 +674,16 @@ export async function resolveGitHubPrStatus({ octokit, directory, branch, remote
|
|
|
674
674
|
};
|
|
675
675
|
}
|
|
676
676
|
|
|
677
|
-
|
|
677
|
+
// Only the repo this branch actually pushes to (the ranked-first remote)
|
|
678
|
+
// and its fork network can be the SOURCE of the branch's PRs. Other
|
|
679
|
+
// configured remotes — a maintainer's checkout often carries contributor
|
|
680
|
+
// forks — are places to look for an open PR, but their `owner:branch`
|
|
681
|
+
// heads are unrelated branches that merely share a name; treating them as
|
|
682
|
+
// sources made a fork's closed `main` PR show up on the local main.
|
|
683
|
+
const primaryRemoteName = resolvedTargets[0]?.remoteName ?? null;
|
|
684
|
+
const sourceCandidates = resolvedTargets.filter(
|
|
685
|
+
(target) => target.remoteName === primaryRemoteName,
|
|
686
|
+
);
|
|
678
687
|
// When every consulted repo list was complete, a no-PR result is
|
|
679
688
|
// authoritative and the expensive Search API fallback is pointless.
|
|
680
689
|
const coverage = { authoritative: true };
|
|
@@ -34,3 +34,7 @@ server implementation. VS Code does not call this route for workspace images;
|
|
|
34
34
|
those use its local filesystem bridge. If called, the grant route returns an
|
|
35
35
|
explicit unsupported response because OpenCode temporary images are not
|
|
36
36
|
supported there.
|
|
37
|
+
|
|
38
|
+
Requests to OpenCode carry the directory in a percent-encoded
|
|
39
|
+
`x-opencode-directory` header, matching the SDK wire format; OpenCode rejects
|
|
40
|
+
raw non-ASCII header values.
|
|
@@ -200,7 +200,9 @@ const fetchMessage = async ({ sessionId, messageId, directory, buildOpenCodeUrl,
|
|
|
200
200
|
const response = await fetch(url, {
|
|
201
201
|
headers: {
|
|
202
202
|
accept: 'application/json',
|
|
203
|
-
|
|
203
|
+
// Percent-encoded to match the SDK wire format; raw non-ASCII values
|
|
204
|
+
// are rejected by OpenCode.
|
|
205
|
+
'x-opencode-directory': encodeURIComponent(directory),
|
|
204
206
|
...getOpenCodeAuthHeaders(),
|
|
205
207
|
},
|
|
206
208
|
signal: AbortSignal.timeout(10_000),
|
|
@@ -74,6 +74,20 @@ const prepare = (app, directory, sources) => request(app)
|
|
|
74
74
|
.expect(200);
|
|
75
75
|
|
|
76
76
|
describe('session image assets', () => {
|
|
77
|
+
it('percent-encodes the directory header on the message fetch', async () => {
|
|
78
|
+
const fixture = await createFixture();
|
|
79
|
+
await prepare(fixture.app, fixture.directory, ['image.png']);
|
|
80
|
+
|
|
81
|
+
expect(fixture.fetchMock).toHaveBeenCalledWith(
|
|
82
|
+
expect.any(URL),
|
|
83
|
+
expect.objectContaining({
|
|
84
|
+
headers: expect.objectContaining({
|
|
85
|
+
'x-opencode-directory': encodeURIComponent(fixture.directory),
|
|
86
|
+
}),
|
|
87
|
+
}),
|
|
88
|
+
);
|
|
89
|
+
});
|
|
90
|
+
|
|
77
91
|
it('prepares workspace and OpenCode temporary images with one message fetch', async () => {
|
|
78
92
|
const fixture = await createFixture({ sources: ['workspace.png'] });
|
|
79
93
|
await fs.writeFile(path.join(fixture.directory, 'workspace.png'), PNG);
|
|
@@ -83,7 +83,10 @@ const resolveVariant = (providers, providerID, modelID, variant) => {
|
|
|
83
83
|
const parseConfigModel = (value) => splitModel(value);
|
|
84
84
|
|
|
85
85
|
const buildDirectoryHeaders = (directory) => ({
|
|
86
|
-
|
|
86
|
+
// OpenCode rejects non-ASCII header values; the official SDK sends this
|
|
87
|
+
// header percent-encoded, so match that wire format (non-ASCII checkout
|
|
88
|
+
// paths such as "Masaüstü" otherwise fail every dispatched prompt).
|
|
89
|
+
...(directory ? { 'x-opencode-directory': encodeURIComponent(directory) } : {}),
|
|
87
90
|
});
|
|
88
91
|
|
|
89
92
|
const fetchJson = async (url, authHeaders, fallback, directory) => {
|
|
@@ -161,6 +161,29 @@ describe('openchamber session routes', () => {
|
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
|
|
164
|
+
it('percent-encodes the directory header for non-ASCII checkout paths', async () => {
|
|
165
|
+
const originalFetch = globalThis.fetch;
|
|
166
|
+
globalThis.fetch = vi.fn(async () => ({ ok: true, json: async () => ({ id: 'ses_123' }) }));
|
|
167
|
+
try {
|
|
168
|
+
const { app } = createApp();
|
|
169
|
+
await request(app)
|
|
170
|
+
.post('/api/openchamber/sessions')
|
|
171
|
+
.send({ directory: '/home/user/Masaüstü/projeler', title: 'Side task' })
|
|
172
|
+
.expect(200);
|
|
173
|
+
|
|
174
|
+
expect(globalThis.fetch).toHaveBeenCalledWith(
|
|
175
|
+
expect.any(String),
|
|
176
|
+
expect.objectContaining({
|
|
177
|
+
headers: expect.objectContaining({
|
|
178
|
+
'x-opencode-directory': encodeURIComponent('/home/user/Masaüstü/projeler'),
|
|
179
|
+
}),
|
|
180
|
+
}),
|
|
181
|
+
);
|
|
182
|
+
} finally {
|
|
183
|
+
globalThis.fetch = originalFetch;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
164
187
|
it('parses JSON body without global middleware', async () => {
|
|
165
188
|
const originalFetch = globalThis.fetch;
|
|
166
189
|
globalThis.fetch = vi.fn(async () => ({ ok: true, json: async () => ({ id: 'ses_123' }) }));
|
|
@@ -5,6 +5,12 @@ import path from 'node:path';
|
|
|
5
5
|
import { clearAppImageArgv0FromProcessEnv } from '../inherited-env.js';
|
|
6
6
|
import { mergePathValues } from './path-utils.js';
|
|
7
7
|
|
|
8
|
+
// Login-shell probes source the user's rc files. A slow or interactive rc
|
|
9
|
+
// (nvm, pyenv, a prompt waiting for input) must not hold server startup
|
|
10
|
+
// hostage: a probe that overruns is abandoned and resolution falls through
|
|
11
|
+
// to the next candidate. Electron's own login-shell probe uses the same bound.
|
|
12
|
+
const SHELL_PROBE_TIMEOUT_MS = 5_000;
|
|
13
|
+
|
|
8
14
|
export const createOpenCodeEnvRuntime = (deps) => {
|
|
9
15
|
const {
|
|
10
16
|
state,
|
|
@@ -208,6 +214,7 @@ export const createOpenCodeEnvRuntime = (deps) => {
|
|
|
208
214
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
209
215
|
maxBuffer: 10 * 1024 * 1024,
|
|
210
216
|
windowsHide: true,
|
|
217
|
+
timeout: SHELL_PROBE_TIMEOUT_MS,
|
|
211
218
|
});
|
|
212
219
|
|
|
213
220
|
if (result.status !== 0) {
|
|
@@ -460,6 +467,7 @@ export const createOpenCodeEnvRuntime = (deps) => {
|
|
|
460
467
|
encoding: 'utf8',
|
|
461
468
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
462
469
|
windowsHide: true,
|
|
470
|
+
timeout: SHELL_PROBE_TIMEOUT_MS,
|
|
463
471
|
});
|
|
464
472
|
if (result.status === 0) {
|
|
465
473
|
const found = (result.stdout || '').trim().split(/\s+/).pop() || '';
|
|
@@ -527,6 +535,7 @@ export const createOpenCodeEnvRuntime = (deps) => {
|
|
|
527
535
|
encoding: 'utf8',
|
|
528
536
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
529
537
|
windowsHide: true,
|
|
538
|
+
timeout: SHELL_PROBE_TIMEOUT_MS,
|
|
530
539
|
});
|
|
531
540
|
if (result.status === 0) {
|
|
532
541
|
const found = (result.stdout || '').trim().split(/\s+/).pop() || '';
|
|
@@ -608,6 +617,7 @@ export const createOpenCodeEnvRuntime = (deps) => {
|
|
|
608
617
|
encoding: 'utf8',
|
|
609
618
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
610
619
|
windowsHide: true,
|
|
620
|
+
timeout: SHELL_PROBE_TIMEOUT_MS,
|
|
611
621
|
});
|
|
612
622
|
if (result.status === 0) {
|
|
613
623
|
const found = (result.stdout || '').trim().split(/\s+/).pop() || '';
|
|
@@ -1011,7 +1021,13 @@ export const createOpenCodeEnvRuntime = (deps) => {
|
|
|
1011
1021
|
const normalized = normalizeOpencodeBinarySetting(settings.opencodeBinary);
|
|
1012
1022
|
|
|
1013
1023
|
if (normalized === '') {
|
|
1014
|
-
|
|
1024
|
+
// The empty-string sentinel drops a previously APPLIED settings
|
|
1025
|
+
// override (source === 'settings'). An OPENCODE_BINARY provided by
|
|
1026
|
+
// the user's own environment is explicit configuration and must not
|
|
1027
|
+
// be destroyed by an empty setting.
|
|
1028
|
+
if (state.resolvedOpencodeBinarySource === 'settings') {
|
|
1029
|
+
delete process.env.OPENCODE_BINARY;
|
|
1030
|
+
}
|
|
1015
1031
|
state.resolvedOpencodeBinary = null;
|
|
1016
1032
|
state.resolvedOpencodeBinarySource = null;
|
|
1017
1033
|
clearWslOpencodeResolution();
|
|
@@ -200,6 +200,39 @@ describe('OpenCode env runtime', () => {
|
|
|
200
200
|
expect(state.resolvedOpencodeBinarySource).toBe('settings');
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
+
it('keeps an env-provided OPENCODE_BINARY when the setting is an empty-string sentinel', async () => {
|
|
204
|
+
const dir = createTempDir('openchamber-env-opencode-');
|
|
205
|
+
const binary = path.join(dir, 'opencode');
|
|
206
|
+
fs.writeFileSync(binary, '#!/bin/sh\nexit 0\n');
|
|
207
|
+
if (process.platform !== 'win32') fs.chmodSync(binary, 0o755);
|
|
208
|
+
process.env.OPENCODE_BINARY = binary;
|
|
209
|
+
const { runtime, state } = createRuntime({ opencodeBinary: '' });
|
|
210
|
+
|
|
211
|
+
await expect(runtime.applyOpencodeBinaryFromSettings()).resolves.toBeNull();
|
|
212
|
+
expect(process.env.OPENCODE_BINARY).toBe(binary);
|
|
213
|
+
expect(state.resolvedOpencodeBinary).toBeNull();
|
|
214
|
+
expect(state.resolvedOpencodeBinarySource).toBeNull();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('drops a previously applied settings override when the setting is cleared to an empty string', async () => {
|
|
218
|
+
const dir = createTempDir('openchamber-settings-opencode-');
|
|
219
|
+
const binary = path.join(dir, 'opencode');
|
|
220
|
+
fs.writeFileSync(binary, '#!/bin/sh\nexit 0\n');
|
|
221
|
+
if (process.platform !== 'win32') fs.chmodSync(binary, 0o755);
|
|
222
|
+
const settings = { opencodeBinary: binary };
|
|
223
|
+
const { runtime, state } = createRuntime(settings);
|
|
224
|
+
|
|
225
|
+
await expect(runtime.applyOpencodeBinaryFromSettings()).resolves.toBe(binary);
|
|
226
|
+
expect(process.env.OPENCODE_BINARY).toBe(binary);
|
|
227
|
+
expect(state.resolvedOpencodeBinarySource).toBe('settings');
|
|
228
|
+
|
|
229
|
+
settings.opencodeBinary = '';
|
|
230
|
+
await expect(runtime.applyOpencodeBinaryFromSettings()).resolves.toBeNull();
|
|
231
|
+
expect(process.env.OPENCODE_BINARY).toBeUndefined();
|
|
232
|
+
expect(state.resolvedOpencodeBinary).toBeNull();
|
|
233
|
+
expect(state.resolvedOpencodeBinarySource).toBeNull();
|
|
234
|
+
});
|
|
235
|
+
|
|
203
236
|
it('prefers the bundled CLI over a user-installed OpenCode from PATH', () => {
|
|
204
237
|
const bundledDir = createTempDir('openchamber-bundled-opencode-');
|
|
205
238
|
const bundledBinary = path.join(bundledDir, process.platform === 'win32' ? 'opencode.exe' : 'opencode');
|
|
@@ -301,6 +334,29 @@ describe('OpenCode env runtime', () => {
|
|
|
301
334
|
});
|
|
302
335
|
});
|
|
303
336
|
|
|
337
|
+
it('bounds every login-shell probe and falls through when one overruns', () => {
|
|
338
|
+
setPlatform('darwin');
|
|
339
|
+
process.env.PATH = createTempDir('openchamber-empty-path-');
|
|
340
|
+
process.env.SHELL = '/bin/zsh';
|
|
341
|
+
delete process.env.OPENCODE_BINARY;
|
|
342
|
+
const shellCalls = [];
|
|
343
|
+
const { runtime } = createRuntime({}, {
|
|
344
|
+
homedir: () => createTempDir('openchamber-empty-home-'),
|
|
345
|
+
spawnSync: (command, args, options) => {
|
|
346
|
+
shellCalls.push({ command, args, options });
|
|
347
|
+
// What spawnSync reports when `timeout` fires: no status, an error.
|
|
348
|
+
return { status: null, signal: 'SIGTERM', error: new Error('spawnSync ETIMEDOUT'), stdout: '', stderr: '' };
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
expect(runtime.resolveOpencodeCliPath()).toBeNull();
|
|
353
|
+
expect(shellCalls.length).toBeGreaterThan(0);
|
|
354
|
+
for (const call of shellCalls) {
|
|
355
|
+
expect(call.args).toContain('-lic');
|
|
356
|
+
expect(call.options.timeout).toBe(5_000);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
|
|
304
360
|
it('does not auto-detect the Windows OpenCode desktop app as a CLI', () => {
|
|
305
361
|
setPlatform('win32');
|
|
306
362
|
const localAppData = createTempDir('openchamber-localappdata-');
|
|
@@ -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
|
}
|