opencode-pilot 0.9.2 → 0.9.3
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/package.json +1 -1
- package/service/actions.js +12 -7
- package/test/unit/actions.test.js +3 -3
package/package.json
CHANGED
package/service/actions.js
CHANGED
|
@@ -102,10 +102,11 @@ function isServerHealthy(project) {
|
|
|
102
102
|
* 1. Exact sandbox match (highest priority)
|
|
103
103
|
* 2. Exact worktree match
|
|
104
104
|
* 3. Target is subdirectory of worktree
|
|
105
|
+
* 4. Global server (worktree="/") as fallback
|
|
105
106
|
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
107
|
+
* Global servers are used as a fallback when no project-specific match is found,
|
|
108
|
+
* since OpenCode Desktop may be connected to a global server that can display
|
|
109
|
+
* sessions for any project.
|
|
109
110
|
*
|
|
110
111
|
* @param {string} targetDir - The directory we want to work in
|
|
111
112
|
* @param {object} [options] - Options for testing/mocking
|
|
@@ -127,6 +128,7 @@ export async function discoverOpencodeServer(targetDir, options = {}) {
|
|
|
127
128
|
|
|
128
129
|
let bestMatch = null;
|
|
129
130
|
let bestScore = 0;
|
|
131
|
+
let globalServer = null;
|
|
130
132
|
|
|
131
133
|
for (const port of ports) {
|
|
132
134
|
const url = `http://localhost:${port}`;
|
|
@@ -148,9 +150,10 @@ export async function discoverOpencodeServer(targetDir, options = {}) {
|
|
|
148
150
|
const worktree = project.worktree || '/';
|
|
149
151
|
const sandboxes = project.sandboxes || [];
|
|
150
152
|
|
|
151
|
-
//
|
|
153
|
+
// Track global server as fallback (but prefer project-specific matches)
|
|
152
154
|
if (worktree === '/') {
|
|
153
|
-
debug(`discoverOpencodeServer: ${url} is global project,
|
|
155
|
+
debug(`discoverOpencodeServer: ${url} is global project, tracking as fallback`);
|
|
156
|
+
globalServer = url;
|
|
154
157
|
continue;
|
|
155
158
|
}
|
|
156
159
|
|
|
@@ -166,8 +169,10 @@ export async function discoverOpencodeServer(targetDir, options = {}) {
|
|
|
166
169
|
}
|
|
167
170
|
}
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
// Use project-specific match if found, otherwise fall back to global server
|
|
173
|
+
const result = bestMatch || globalServer;
|
|
174
|
+
debug(`discoverOpencodeServer: best match=${bestMatch} score=${bestScore}, global=${globalServer}, using=${result}`);
|
|
175
|
+
return result;
|
|
171
176
|
}
|
|
172
177
|
|
|
173
178
|
// Default templates directory
|
|
@@ -394,7 +394,7 @@ describe('actions.js', () => {
|
|
|
394
394
|
assert.strictEqual(result, 'http://localhost:4000');
|
|
395
395
|
});
|
|
396
396
|
|
|
397
|
-
test('
|
|
397
|
+
test('uses global project server as fallback when no specific match', async () => {
|
|
398
398
|
const { discoverOpencodeServer } = await import('../../service/actions.js');
|
|
399
399
|
|
|
400
400
|
const mockPorts = async () => [3000];
|
|
@@ -406,13 +406,13 @@ describe('actions.js', () => {
|
|
|
406
406
|
return { ok: false };
|
|
407
407
|
};
|
|
408
408
|
|
|
409
|
-
// Global servers should be
|
|
409
|
+
// Global servers should be used as fallback when no project-specific match
|
|
410
410
|
const result = await discoverOpencodeServer('/Users/test/random/path', {
|
|
411
411
|
getPorts: mockPorts,
|
|
412
412
|
fetch: mockFetch
|
|
413
413
|
});
|
|
414
414
|
|
|
415
|
-
assert.strictEqual(result,
|
|
415
|
+
assert.strictEqual(result, 'http://localhost:3000');
|
|
416
416
|
});
|
|
417
417
|
|
|
418
418
|
test('returns null when fetch fails for all servers', async () => {
|