@yuriai/web 0.1.21 → 0.1.23
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/README.md +1 -1
- package/dist/assets/{AgentAvatar-Dn3d91Bp.js → AgentAvatar-C2p8G_Xw.js} +1 -1
- package/dist/assets/{AssistantView-DQiNW-MW.js → AssistantView-Cl8dtJE-.js} +3 -3
- package/dist/assets/{DiagramView-BmhwoZBs.js → DiagramView-zXlQky2c.js} +1 -1
- package/dist/assets/{FadeInOnReveal-D7ifJQAw.js → FadeInOnReveal-DhAYqopy.js} +1 -1
- package/dist/assets/{Icon-DZmADJWp.js → Icon-DKFfVCeK.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-Dw4P79Ms.js → ImageLoadingPlaceholder-DD2g7FjK.js} +1 -1
- package/dist/assets/{LoadingImage-CCKvcYRc.js → LoadingImage-Dc7hnEQ7.js} +1 -1
- package/dist/assets/{MarkdownRenderer-cLMYjCOZ.js → MarkdownRenderer-C1PXw_8U.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-Bv94t0JE.js → MarkdownRendererImpl-CWVOJcvk.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BXX_Gr__.js → MarkstreamRendererImpl-BwkPAY1P.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-DiMju5tJ.js → MobileDetailNavigation-B4ZBK4cl.js} +1 -1
- package/dist/assets/{MobileShareBridge-BvT-pieE.js → MobileShareBridge-B5LUJJ99.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-6TnrgU8f.js → MobileTabPageHeader-CkUhuZP6.js} +1 -1
- package/dist/assets/{MultiRunWindow-BKAWbnyr.js → MultiRunWindow-CqNrUij5.js} +1 -1
- package/dist/assets/{OnboardingScreen-DE2iB21m.js → OnboardingScreen-Dau5R5ew.js} +1 -1
- package/dist/assets/{OverlayScrollbar-BlzvB3ct.js → OverlayScrollbar-eBG-DXgX.js} +1 -1
- package/dist/assets/{SettingsView-CUuhQWoK.js → SettingsView-vZx4AKc1.js} +3 -3
- package/dist/assets/{SettingsWindow-h59i73ov.js → SettingsWindow-Rqxks-AG.js} +1 -1
- package/dist/assets/{TerminalView-Zo7cDHfo.js → TerminalView-CGYEbWpv.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DDBPTFEY.js → ToolOutputDialog-B24XEhve.js} +1 -1
- package/dist/assets/{YuriLogo-Dm011NCM.js → YuriLogo-CgTkNYZf.js} +1 -1
- package/dist/assets/{appThemeRegistry-DK-CSk5S.js → appThemeRegistry-DD8LRHDT.js} +1 -1
- package/dist/assets/{button-CEcZQm-B.js → button-LPikURUk.js} +1 -1
- package/dist/assets/{capgoAdapter-CZGKOfbD.js → capgoAdapter-BCy22KX-.js} +1 -1
- package/dist/assets/{collapsible-B6ON5Mai.js → collapsible-CbQmi7qt.js} +1 -1
- package/dist/assets/{diagram-9xxUjDb_.js → diagram-DWkoS1Uc.js} +1 -1
- package/dist/assets/{dialog-CjPdvmr0.js → dialog-D8AYQa70.js} +1 -1
- package/dist/assets/{dropdown-menu.styles-Cm3A3LAl.js → dropdown-menu.styles-BqAI_N66.js} +1 -1
- package/dist/assets/{es-CqWNlkik.js → es-Le3f45R2.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-9jKjMJHB.js → fileMentionTouchSelection-CnxrRlNO.js} +1 -1
- package/dist/assets/{fr-CpxexYkk.js → fr-Knp2_Wkz.js} +1 -1
- package/dist/assets/{gitApi-IVSP2ro3.js → gitApi-D3cHH50Y.js} +1 -1
- package/dist/assets/{input-yYSzMq8L.js → input-CAhwlkOT.js} +1 -1
- package/dist/assets/{insertionBoundaries-3xRx4bIM.js → insertionBoundaries-19EJsmCA.js} +1 -1
- package/dist/assets/{ja-ByTgQPSi.js → ja-_KJ_VLgM.js} +1 -1
- package/dist/assets/{ko-BGfRP-3B.js → ko-CmWIeRHF.js} +1 -1
- package/dist/assets/{main-C3lkHYme.js → main-BO2UnYBd.js} +2 -2
- package/dist/assets/{main-SwAGPxrJ.js → main-b2a4ZRXC.js} +4 -4
- package/dist/assets/{markdownHeightCache-w0HDCLwk.js → markdownHeightCache-CylzGsAe.js} +1 -1
- package/dist/assets/{mcpQueries-DF-qg0ML.js → mcpQueries-BBt1ELI8.js} +1 -1
- package/dist/assets/{miniChat-KQ7dhYRy.js → miniChat-BpvsuSKB.js} +2 -2
- package/dist/assets/{mobile-GqxrcIvm.js → mobile-CyklTbWh.js} +2 -2
- package/dist/assets/{mobileBackNavigation-CM08LMho.js → mobileBackNavigation-Df81BnZ5.js} +1 -1
- package/dist/assets/{multirun-w_nrm1ZM.js → multirun-BrpKcjYv.js} +1 -1
- package/dist/assets/{native-config-B2T-ZIEW.js → native-config-C3EM05Jz.js} +1 -1
- package/dist/assets/{pl-DIwCzbXW.js → pl-BoXY-ki3.js} +1 -1
- package/dist/assets/{platform-7bX6qtBV.js → platform-CCTs9UKZ.js} +1 -1
- package/dist/assets/{projectMeta-C6-BO3Sf.js → projectMeta-DOs0HlSf.js} +1 -1
- package/dist/assets/{pt-BR-4MjIbbWQ.js → pt-BR-C3gsTrhe.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DWdbSIM5.js → renderElectronMiniChatApp-DaeIwT-e.js} +2 -2
- package/dist/assets/{renderMobileApp-Dzc3S0T9.js → renderMobileApp-C-Rhiqyk.js} +5 -5
- package/dist/assets/{runtimeConfig-BkVhmUl_.js → runtimeConfig-CQ3TyMLm.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DOv4PgLe.js → runtimeEndpointReset-CINPdy23.js} +2 -2
- package/dist/assets/{scheduledTaskNavigation-BhsUww-K.js → scheduledTaskNavigation-FME9NQYP.js} +1 -1
- package/dist/assets/{sessionChangeSummary-CtU8ntJA.js → sessionChangeSummary-DYp-0K8f.js} +1 -1
- package/dist/assets/{sessionLookup-BPj-TfyV.js → sessionLookup-BMSCT9Y1.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-MyKMqyvw.js → sortable-tabs-strip-DiXAHgws.js} +1 -1
- package/dist/assets/speechSettingsQueries-Ci2kILTe.js +4 -0
- package/dist/assets/src-DlJVKekb.css +2 -0
- package/dist/assets/{store-JjNwX_aQ.js → store-CnVXA4NH.js} +2 -2
- package/dist/assets/{terminalApi-BHXvha-U.js → terminalApi-DhXTmxps.js} +1 -1
- package/dist/assets/{textarea-CO8JEdzP.js → textarea-BZhmG_bD.js} +1 -1
- package/dist/assets/{tooltip-Dmw1nU2I.js → tooltip-CFuO3PUH.js} +1 -1
- package/dist/assets/{types-FsIkN0-g.js → types-Du8LnIGl.js} +1 -1
- package/dist/assets/{uk-D9WsfZqn.js → uk-VUOVH9qH.js} +1 -1
- package/dist/assets/{useAppFontEffects-BBmnsBzL.js → useAppFontEffects-C-CZuq33.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-2uBv60jr.js → useDesktopWindowControlsLayout-C8BGnh2S.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-_OW1qW0a.js → useEffectiveDirectory-B85HOZow.js} +1 -1
- package/dist/assets/{useFontPreferences-D9PX5t6Y.js → useFontPreferences-CMyrMAmq.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BwspReaN.js → useMobileNavigationStore-_8410bpu.js} +7 -7
- package/dist/assets/{useWorkerHighlightedLines-BBUyEoH8.js → useWorkerHighlightedLines-D4HmbcHr.js} +1 -1
- package/dist/assets/vendor-opencode-client-XDI8AfPJ.js +12 -0
- package/dist/assets/{zh-CN-CAIBZPD7.js → zh-CN-CqOn122C.js} +1 -1
- package/dist/assets/{zh-TW-IpFLeeKe.js → zh-TW-53yr6Fdj.js} +1 -1
- package/dist/index.html +9 -9
- package/dist/mini-chat.html +9 -9
- package/dist/mobile.html +9 -9
- package/package.json +3 -3
- package/server/lib/config-sync/DOCUMENTATION.md +6 -2
- package/server/lib/config-sync/magpie.js +31 -6
- package/server/lib/config-sync/magpie.test.js +94 -1
- package/server/lib/opencode/DOCUMENTATION.md +9 -9
- package/server/lib/opencode/ensure-cli.js +12 -14
- package/server/lib/opencode/ensure-cli.test.js +8 -8
- package/server/lib/opencode/env-runtime.test.js +1 -1
- package/server/lib/opencode/opencode2-pin.js +3 -4
- package/server/lib/opencode/opencode2-pin.test.js +5 -4
- package/server/lib/opencode/owned-runtime-upgrade.js +4 -11
- package/server/lib/opencode/owned-runtime-upgrade.test.js +4 -0
- package/server/lib/opencode/routes.js +2 -1
- package/server/lib/opencode/routes.test.js +1 -1
- package/server/lib/opencode/runtime-contract.js +3 -4
- package/server/lib/opencode/session-directory-runtime.js +2 -13
- package/server/lib/opencode/session-directory-runtime.test.js +69 -4
- package/server/lib/opencode/upgrade-screen.js +9 -5
- package/server/lib/opencode/upgrade-screen.test.js +20 -0
- package/server/lib/opencode/version-alignment.test.js +6 -6
- package/server/lib/session-index/DOCUMENTATION.md +18 -8
- package/server/lib/session-index/routes.js +3 -1
- package/server/lib/session-index/routes.test.js +2 -0
- package/server/lib/session-index/service.js +23 -0
- package/server/lib/session-index/sync-runtime.js +75 -20
- package/server/lib/session-index/sync-runtime.test.js +5 -5
- package/dist/assets/speechSettingsQueries-BicoJlEO.js +0 -4
- package/dist/assets/src-CfEhXfYn.css +0 -2
- package/dist/assets/vendor-opencode-client-MF2GBrFx.js +0 -12
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import {
|
|
3
3
|
OPENCODE2_NPM_PACKAGE,
|
|
4
|
-
PINNED_OPENCODE2_VERSION,
|
|
5
4
|
compareOpenCode2Versions,
|
|
6
5
|
evaluateOpenCodeHealthBody,
|
|
7
6
|
isAcceptableOpenCode2HealthVersion,
|
|
@@ -13,6 +12,8 @@ import {
|
|
|
13
12
|
resolveOpenCode2UpgradeTarget,
|
|
14
13
|
} from './opencode2-pin.js';
|
|
15
14
|
|
|
15
|
+
const PINNED_OPENCODE2_VERSION = '2.0.23';
|
|
16
|
+
|
|
16
17
|
describe('opencode2 pin (ticket 12)', () => {
|
|
17
18
|
it('rejects 1.x version strings and accepts the pinned v2', () => {
|
|
18
19
|
expect(isOpenCode1xVersion('1.18.4')).toBe(true);
|
|
@@ -25,11 +26,11 @@ describe('opencode2 pin (ticket 12)', () => {
|
|
|
25
26
|
expect(isOpenCode1xVersion(null)).toBe(false);
|
|
26
27
|
});
|
|
27
28
|
|
|
28
|
-
it('throws on 1.x upgrade targets
|
|
29
|
+
it('throws on 1.x or unresolved upgrade targets', () => {
|
|
29
30
|
expect(() => rejectOpenCode1xUpgradeTarget('1.18.4')).toThrow(/1\.x/);
|
|
30
31
|
expect(() => rejectOpenCode1xUpgradeTarget('1.18.4')).toThrow(expect.objectContaining({ code: 'OPENCODE_UPGRADE_1X_REFUSED' }));
|
|
31
|
-
expect(resolveOpenCode2UpgradeTarget(undefined)).
|
|
32
|
-
expect(resolveOpenCode2UpgradeTarget('')).
|
|
32
|
+
expect(() => resolveOpenCode2UpgradeTarget(undefined)).toThrow('Resolve a stable');
|
|
33
|
+
expect(() => resolveOpenCode2UpgradeTarget('')).toThrow('Resolve a stable');
|
|
33
34
|
expect(resolveOpenCode2UpgradeTarget(PINNED_OPENCODE2_VERSION)).toBe(PINNED_OPENCODE2_VERSION);
|
|
34
35
|
expect(() => resolveOpenCode2UpgradeTarget('1.18.18')).toThrow(/1\.x/);
|
|
35
36
|
});
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
import path from 'node:path';
|
|
16
16
|
import {
|
|
17
|
-
PINNED_OPENCODE2_VERSION,
|
|
18
17
|
compareOpenCode2Versions,
|
|
19
18
|
isOpenCode1xVersion,
|
|
20
19
|
resolveOpenCode2UpgradeTarget,
|
|
@@ -176,15 +175,9 @@ export function buildUpgradeStatusSnapshot(input) {
|
|
|
176
175
|
const serveVersion = normalizeRuntimeVersion(input.serveVersion);
|
|
177
176
|
const cliVersion = normalizeRuntimeVersion(input.cliVersion);
|
|
178
177
|
const currentVersion = serveVersion || cliVersion;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
} catch {
|
|
183
|
-
targetVersion = PINNED_OPENCODE2_VERSION;
|
|
184
|
-
}
|
|
185
|
-
if (isOpenCode1xVersion(targetVersion)) {
|
|
186
|
-
targetVersion = PINNED_OPENCODE2_VERSION;
|
|
187
|
-
}
|
|
178
|
+
const targetVersion = input.targetVersion
|
|
179
|
+
? resolveOpenCode2UpgradeTarget(input.targetVersion)
|
|
180
|
+
: null;
|
|
188
181
|
|
|
189
182
|
const contract = input.contract || evaluateRuntimeContract({
|
|
190
183
|
serveVersion,
|
|
@@ -201,7 +194,7 @@ export function buildUpgradeStatusSnapshot(input) {
|
|
|
201
194
|
&& !isOpenCode1xVersion(currentVersion)
|
|
202
195
|
&& compareOpenCode2Versions(targetVersion, currentVersion) > 0,
|
|
203
196
|
);
|
|
204
|
-
const available = canManage &&
|
|
197
|
+
const available = canManage && targetVersion ? newerTarget : null;
|
|
205
198
|
|
|
206
199
|
/** @type {string | null} */
|
|
207
200
|
let reason = ownership.reason;
|
|
@@ -56,6 +56,10 @@ describe('owned runtime upgrade (ticket 12)', () => {
|
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
it('upgrade-status exposes manage rights and manual guidance', () => {
|
|
59
|
+
expect(buildUpgradeStatusSnapshot({
|
|
60
|
+
ownership: classifyRuntimeOwnership({ binarySource: 'installed', binaryPath: ownedBinary, dataDir }),
|
|
61
|
+
serveVersion: '2.2.0',
|
|
62
|
+
})).toMatchObject({ available: null, targetVersion: null });
|
|
59
63
|
const globalStatus = buildUpgradeStatusSnapshot({
|
|
60
64
|
ownership: classifyRuntimeOwnership({ isExternal: false, binarySource: 'path' }),
|
|
61
65
|
serveVersion: '2.0.12',
|
|
@@ -285,6 +285,7 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
|
285
285
|
isSharedService: () => getIsSharedOpenCodeService() === true,
|
|
286
286
|
install: (options) => installPinnedOpenCode2Cli({ ...options, dataDir: resolveDataDir() }),
|
|
287
287
|
upgradeCli: upgradeOpenCodeCli,
|
|
288
|
+
resolveLatestVersion: discoverOpenCodeUpdate,
|
|
288
289
|
readBinaryVersion: readOpenCode2BinaryVersion,
|
|
289
290
|
});
|
|
290
291
|
|
|
@@ -343,7 +344,7 @@ export const registerOpenCodeRoutes = (app, dependencies) => {
|
|
|
343
344
|
if (isOpenCode1xVersion(rawTarget)) {
|
|
344
345
|
return res.status(400).json({
|
|
345
346
|
success: false,
|
|
346
|
-
error: 'OpenCode upgrade refuses 1.x targets. Only
|
|
347
|
+
error: 'OpenCode upgrade refuses 1.x targets. Only OpenCode 2.x is allowed.',
|
|
347
348
|
errorCode: 'OPENCODE_UPGRADE_1X_REFUSED',
|
|
348
349
|
});
|
|
349
350
|
}
|
|
@@ -365,7 +365,7 @@ describe('opencode2 upgrade pin (ticket 12)', () => {
|
|
|
365
365
|
getIsExternalOpenCode: () => true,
|
|
366
366
|
getIsSharedOpenCodeService: () => true,
|
|
367
367
|
getActiveSessionCount: () => 1,
|
|
368
|
-
discoverOpenCodeUpdate: async () =>
|
|
368
|
+
discoverOpenCodeUpdate: async () => '2.0.23',
|
|
369
369
|
upgradeOpenCodeCli,
|
|
370
370
|
forceResolvedOpenCodeBinary: vi.fn(),
|
|
371
371
|
restartOpenCode,
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
|
-
PINNED_OPENCODE2_VERSION,
|
|
17
16
|
MINIMUM_OPENCODE2_VERSION,
|
|
18
17
|
compareOpenCode2Versions,
|
|
19
18
|
isAcceptableOpenCode2HealthVersion,
|
|
@@ -239,7 +238,7 @@ export function evaluateRuntimeContract(input = {}) {
|
|
|
239
238
|
versionMismatch,
|
|
240
239
|
minVerifiedVersion: RUNTIME_CONTRACT_MIN_VERIFIED,
|
|
241
240
|
maxVerifiedVersion: null,
|
|
242
|
-
pinnedVersion:
|
|
241
|
+
pinnedVersion: null,
|
|
243
242
|
capabilities,
|
|
244
243
|
reasons,
|
|
245
244
|
};
|
|
@@ -358,7 +357,7 @@ export function shouldBlockRuntimeContractExecution(method, pathWithQuery, contr
|
|
|
358
357
|
export function formatRuntimeContractBlockedError(contract) {
|
|
359
358
|
const serve = contract?.serveVersion ?? null;
|
|
360
359
|
const min = contract?.minVerifiedVersion ?? RUNTIME_CONTRACT_MIN_VERIFIED;
|
|
361
|
-
const pinned =
|
|
360
|
+
const pinned = 'latest stable 2.x';
|
|
362
361
|
const reasons = Array.isArray(contract?.reasons) ? contract.reasons : [];
|
|
363
362
|
|
|
364
363
|
if (reasons.includes('below-min-verified')) {
|
|
@@ -396,7 +395,7 @@ export function runtimeContractExecutionBlockedBody(contract) {
|
|
|
396
395
|
serveVersion: contract?.serveVersion ?? null,
|
|
397
396
|
minVerifiedVersion: contract?.minVerifiedVersion ?? null,
|
|
398
397
|
maxVerifiedVersion: contract?.maxVerifiedVersion ?? null,
|
|
399
|
-
pinnedVersion:
|
|
398
|
+
pinnedVersion: null,
|
|
400
399
|
contract: contract ?? null,
|
|
401
400
|
};
|
|
402
401
|
}
|
|
@@ -79,8 +79,8 @@ export const createSessionDirectoryRuntime = ({
|
|
|
79
79
|
return typeof data.id === 'string' ? { ...event, [field]: projectSession(data) } : event;
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
// v2 directory filters are lexical SQL equality.
|
|
83
|
-
//
|
|
82
|
+
// v2 directory filters are lexical SQL equality. Read session pages without
|
|
83
|
+
// booting a Location, then retain only the same physical directory.
|
|
84
84
|
// This also finds old aliases absent from Yuri's bounded index.
|
|
85
85
|
const fetchSessionList = async (input, init) => {
|
|
86
86
|
const url = new URL(input);
|
|
@@ -90,17 +90,6 @@ export const createSessionDirectoryRuntime = ({
|
|
|
90
90
|
if (!target || url.searchParams.has('project')) {
|
|
91
91
|
return fetchFn(input, init);
|
|
92
92
|
}
|
|
93
|
-
if (!url.searchParams.has('cursor')) {
|
|
94
|
-
const locationUrl = new URL(url);
|
|
95
|
-
locationUrl.pathname = locationUrl.pathname.replace(/\/session\/?$/, '/location');
|
|
96
|
-
locationUrl.search = '';
|
|
97
|
-
locationUrl.searchParams.set('location[directory]', target);
|
|
98
|
-
const response = await fetchFn(locationUrl, init);
|
|
99
|
-
if (!response.ok) return response;
|
|
100
|
-
const location = await response.json();
|
|
101
|
-
if (typeof location?.project?.id !== 'string') throw new Error('Invalid OpenCode location payload');
|
|
102
|
-
url.searchParams.set('project', location.project.id);
|
|
103
|
-
}
|
|
104
93
|
url.searchParams.delete('directory');
|
|
105
94
|
init?.signal?.throwIfAborted();
|
|
106
95
|
const response = await fetchFn(url, init);
|
|
@@ -24,6 +24,71 @@ const session = (id, directory, updated = 1) => ({ id, title: id, location: { di
|
|
|
24
24
|
const json = (value, status = 200) => new Response(JSON.stringify(value), { status, headers: { 'content-type': 'application/json' } });
|
|
25
25
|
|
|
26
26
|
describe('physical session directory identity', () => {
|
|
27
|
+
it('backfills only 30 days once per runtime, resumes failed pages, and never boots locations', async () => {
|
|
28
|
+
const { real } = fixture();
|
|
29
|
+
const dbPath = path.join(real, 'index.sqlite');
|
|
30
|
+
const now = 100 * 24 * 60 * 60 * 1000;
|
|
31
|
+
let fail = true;
|
|
32
|
+
let runtimeKey = 'http://localhost:4000';
|
|
33
|
+
const requests = [];
|
|
34
|
+
const fetchFn = vi.fn(async (input) => {
|
|
35
|
+
const url = new URL(input);
|
|
36
|
+
requests.push(url);
|
|
37
|
+
expect(url.pathname).toBe('/api/session');
|
|
38
|
+
expect(url.searchParams.has('directory')).toBe(false);
|
|
39
|
+
expect(url.searchParams.has('location[directory]')).toBe(false);
|
|
40
|
+
if (!url.searchParams.has('cursor')) return json({ data: [session('recent', real, now)], cursor: { next: 'second' } });
|
|
41
|
+
if (fail) return json({}, 503);
|
|
42
|
+
return json({ data: [session('older', real, now - 31 * 24 * 60 * 60 * 1000)], cursor: { next: 'never-read' } });
|
|
43
|
+
});
|
|
44
|
+
const open = () => {
|
|
45
|
+
const service = createSessionIndexService({ dbPath, getRuntimeConfig: () => ({ apiBaseUrl: runtimeKey }) });
|
|
46
|
+
const sync = createSessionIndexSyncRuntime({ sessionIndexService: service, now: () => now,
|
|
47
|
+
buildOpenCodeUrl: (route) => `http://localhost/api${route}`, getOpenCodeAuthHeaders: () => ({}), fetchFn });
|
|
48
|
+
return { service, sync };
|
|
49
|
+
};
|
|
50
|
+
let { service, sync } = open();
|
|
51
|
+
try {
|
|
52
|
+
sync.enqueue(Array.from({ length: 31 }, (_, i) => `/unused/${i}`), { startup: true });
|
|
53
|
+
sync.enqueue([], { startup: true });
|
|
54
|
+
await vi.waitFor(() => expect(sync.snapshot().sync.active).toBe(false));
|
|
55
|
+
expect(fetchFn).toHaveBeenCalledTimes(2);
|
|
56
|
+
expect(service.getHistoryBackfill()).toMatchObject({ cursor: 'second', complete: false });
|
|
57
|
+
expect(service.findBySessionId('recent')).toBeTruthy();
|
|
58
|
+
sync.stop(); service.close();
|
|
59
|
+
({ service, sync } = open());
|
|
60
|
+
fail = false;
|
|
61
|
+
sync.enqueue([], { startup: true });
|
|
62
|
+
await vi.waitFor(() => expect(sync.snapshot().sync.active).toBe(false));
|
|
63
|
+
expect(fetchFn).toHaveBeenCalledTimes(3);
|
|
64
|
+
expect(requests[2].searchParams.get('cursor')).toBe('second');
|
|
65
|
+
expect(service.getHistoryBackfill().complete).toBe(true);
|
|
66
|
+
expect(service.findBySessionId('older')).toBeNull();
|
|
67
|
+
sync.stop(); service.close();
|
|
68
|
+
({ service, sync } = open());
|
|
69
|
+
sync.enqueue([], { startup: true });
|
|
70
|
+
expect(sync.snapshot().sync.active).toBe(false);
|
|
71
|
+
expect(fetchFn).toHaveBeenCalledTimes(3);
|
|
72
|
+
runtimeKey = 'https://other.example';
|
|
73
|
+
expect(service.getHistoryBackfill()).toBeNull();
|
|
74
|
+
} finally { sync.stop(); service.close(); }
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('records an empty backfill as complete and preserves spaces in session directories', async () => {
|
|
78
|
+
const service = createSessionIndexService({ dbPath: ':memory:' });
|
|
79
|
+
const fetchFn = vi.fn(async () => json({ data: [], cursor: {} }));
|
|
80
|
+
const sync = createSessionIndexSyncRuntime({ sessionIndexService: service,
|
|
81
|
+
buildOpenCodeUrl: (route) => `http://localhost/api${route}`, getOpenCodeAuthHeaders: () => ({}), fetchFn });
|
|
82
|
+
try {
|
|
83
|
+
sync.enqueue([], { startup: true });
|
|
84
|
+
await vi.waitFor(() => expect(sync.snapshot().sync.active).toBe(false));
|
|
85
|
+
sync.enqueue([], { startup: true });
|
|
86
|
+
expect(fetchFn).toHaveBeenCalledTimes(1);
|
|
87
|
+
service.upsert(session('spaces', '/home/example/Library/Mobile Documents/project', Date.now()));
|
|
88
|
+
expect(service.findBySessionId('spaces').directory).toBe('/home/example/Library/Mobile Documents/project');
|
|
89
|
+
} finally { sync.stop(); service.close(); }
|
|
90
|
+
});
|
|
91
|
+
|
|
27
92
|
it('checks deletion only on the owning local runtime and preserves uncertain failures', async () => {
|
|
28
93
|
let url = 'http://127.0.0.1:4000';
|
|
29
94
|
const stat = vi.fn(async () => { throw Object.assign(new Error('missing'), { code: 'ENOENT' }); });
|
|
@@ -67,6 +132,7 @@ describe('physical session directory identity', () => {
|
|
|
67
132
|
fetchFn,
|
|
68
133
|
});
|
|
69
134
|
try {
|
|
135
|
+
runtime.enqueue([missing]);
|
|
70
136
|
await vi.waitFor(() => expect(service.snapshot().directories.map(x => x.directory)).not.toContain(missing));
|
|
71
137
|
expect(service.snapshot().directories.map(x => x.directory)).toEqual(expect.arrayContaining([real, history, partial, child]));
|
|
72
138
|
runtime.enqueue([missing, history, partial, child]);
|
|
@@ -95,10 +161,10 @@ describe('physical session directory identity', () => {
|
|
|
95
161
|
requests.push(url);
|
|
96
162
|
expect(init.signal).toBe(controller.signal);
|
|
97
163
|
expect(init.headers).toEqual({ Authorization: 'test-only' });
|
|
98
|
-
|
|
164
|
+
expect(url.pathname).toBe('/api/session');
|
|
99
165
|
expect(url.searchParams.has('directory')).toBe(false);
|
|
100
166
|
if (!url.searchParams.has('cursor')) {
|
|
101
|
-
expect(url.searchParams.
|
|
167
|
+
expect(url.searchParams.has('project')).toBe(false);
|
|
102
168
|
return json({ data: [session('other', other, 30)], cursor: { next: 'page-2' } });
|
|
103
169
|
}
|
|
104
170
|
return json({ data: [session('old-alias', alias, 20), session('real', real, 10)], cursor: { next: 'page-3' } });
|
|
@@ -117,8 +183,7 @@ describe('physical session directory identity', () => {
|
|
|
117
183
|
expect(payload.data.map((row) => row.id)).toEqual(['old-alias', 'real']);
|
|
118
184
|
expect(payload.data.every((row) => row.directory === real && row.location.directory === real)).toBe(true);
|
|
119
185
|
expect(payload.cursor.next).toBe('page-3');
|
|
120
|
-
expect(requests).toHaveLength(
|
|
121
|
-
expect(requests[0].searchParams.get('location[directory]')).toBe(real);
|
|
186
|
+
expect(requests).toHaveLength(2);
|
|
122
187
|
});
|
|
123
188
|
|
|
124
189
|
it('uses the same physical directory for cold sync and later native live events', async () => {
|
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
PINNED_OPENCODE2_VERSION,
|
|
12
11
|
MINIMUM_OPENCODE2_VERSION,
|
|
13
12
|
isAcceptableOpenCode2HealthVersion,
|
|
14
13
|
isOpenCode1xVersion,
|
|
15
14
|
isOpenCode2VersionAtLeast,
|
|
16
15
|
npmPackageForOpenCode2,
|
|
17
16
|
} from './opencode2-pin.js';
|
|
17
|
+
import { createOpenCodeUpdateDiscovery } from './update-discovery.js';
|
|
18
|
+
|
|
19
|
+
const discoverLatestVersion = createOpenCodeUpdateDiscovery();
|
|
18
20
|
|
|
19
21
|
/** Oldest OpenCode this Yuri build will enter a session against. */
|
|
20
22
|
export const REQUIRED_OPENCODE_VERSION = MINIMUM_OPENCODE2_VERSION;
|
|
@@ -26,11 +28,10 @@ const normalizeVersion = (value) => {
|
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
|
-
*
|
|
30
|
-
* the screen minimum. A pin still at 2.0.12 must not be what this screen installs.
|
|
31
|
+
* Describe the minimum until an installation resolves its remote stable target.
|
|
31
32
|
* @param {string} [pin]
|
|
32
33
|
*/
|
|
33
|
-
export function resolveUpgradeScreenTarget(pin =
|
|
34
|
+
export function resolveUpgradeScreenTarget(pin = REQUIRED_OPENCODE_VERSION) {
|
|
34
35
|
if (isOpenCode2VersionAtLeast(pin, REQUIRED_OPENCODE_VERSION)) return pin;
|
|
35
36
|
return REQUIRED_OPENCODE_VERSION;
|
|
36
37
|
}
|
|
@@ -181,7 +182,10 @@ export async function installRequiredOpenCode(deps) {
|
|
|
181
182
|
409,
|
|
182
183
|
);
|
|
183
184
|
}
|
|
184
|
-
const target =
|
|
185
|
+
const target = await (deps.resolveLatestVersion || discoverLatestVersion)();
|
|
186
|
+
if (!/^2\.\d+\.\d+$/.test(target) || !isUpgradeScreenSatisfied(target)) {
|
|
187
|
+
throw failure('No compatible stable OpenCode release was found.', 'UPGRADE_TARGET_INVALID');
|
|
188
|
+
}
|
|
185
189
|
const previousBinary = typeof deps.getResolvedBinary === 'function' ? deps.getResolvedBinary() : null;
|
|
186
190
|
const previousSource = typeof deps.getResolvedBinarySource === 'function' ? deps.getResolvedBinarySource() : null;
|
|
187
191
|
const ownership = typeof deps.resolveOwnership === 'function' ? await deps.resolveOwnership() : null;
|
|
@@ -108,12 +108,31 @@ describe('installRequiredOpenCode', () => {
|
|
|
108
108
|
calls.push('ready');
|
|
109
109
|
}),
|
|
110
110
|
readConfiguredBinary: async () => null,
|
|
111
|
+
resolveLatestVersion: async () => '2.0.23',
|
|
111
112
|
isSharedService: () => false,
|
|
112
113
|
...overrides,
|
|
113
114
|
};
|
|
114
115
|
return { deps, calls };
|
|
115
116
|
};
|
|
116
117
|
|
|
118
|
+
it('resolves a newer stable release instead of installing a compiled-in pin', async () => {
|
|
119
|
+
const { deps } = createDeps({
|
|
120
|
+
resolveLatestVersion: vi.fn(async () => '2.2.0'),
|
|
121
|
+
readBinaryVersion: () => '2.2.0',
|
|
122
|
+
readServeVersion: vi.fn().mockResolvedValueOnce('2.0.14').mockResolvedValueOnce('2.2.0'),
|
|
123
|
+
});
|
|
124
|
+
await expect(installRequiredOpenCode(deps)).resolves.toMatchObject({ upgraded: true, version: '2.2.0' });
|
|
125
|
+
expect(deps.install).toHaveBeenCalledWith({ version: '2.2.0' });
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('does not mutate installation or selection when release discovery fails', async () => {
|
|
129
|
+
const { deps } = createDeps({ resolveLatestVersion: async () => { throw new Error('offline'); } });
|
|
130
|
+
await expect(installRequiredOpenCode(deps)).rejects.toThrow('offline');
|
|
131
|
+
expect(deps.install).not.toHaveBeenCalled();
|
|
132
|
+
expect(deps.persistBinary).not.toHaveBeenCalled();
|
|
133
|
+
expect(deps.restart).not.toHaveBeenCalled();
|
|
134
|
+
});
|
|
135
|
+
|
|
117
136
|
it('installs 2.0.23 and only succeeds after the running serve is verified', async () => {
|
|
118
137
|
const { deps, calls } = createDeps({
|
|
119
138
|
readServeVersion: vi.fn()
|
|
@@ -190,6 +209,7 @@ describe('upgrade screen routes', () => {
|
|
|
190
209
|
resolveOwnership: async () => ({ ownership: 'owned-cache', guidance: null }),
|
|
191
210
|
readServeVersion,
|
|
192
211
|
readCliVersion: () => '2.0.12',
|
|
212
|
+
resolveLatestVersion: async () => '2.0.23',
|
|
193
213
|
platformCanInstall: true,
|
|
194
214
|
install: vi.fn(async () => {
|
|
195
215
|
throw new Error('registry unreachable');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { MINIMUM_OPENCODE2_VERSION
|
|
2
|
+
import { MINIMUM_OPENCODE2_VERSION } from './opencode2-pin.js';
|
|
3
3
|
import { evaluateRuntimeContract } from './runtime-contract.js';
|
|
4
4
|
import { describeUpgradeScreen, installRequiredOpenCode, resolveUpgradeScreenTarget } from './upgrade-screen.js';
|
|
5
5
|
import { ensurePinnedOpenCode2Cli } from './ensure-cli.js';
|
|
@@ -13,24 +13,24 @@ describe('v2 version alignment', () => {
|
|
|
13
13
|
expect(evaluateRuntimeContract({ serveVersion: version, cliVersion: '2.0.15', reachable: true, authenticated: true })).toMatchObject({ executionAllowed: true, versionMismatch: true, minVerifiedVersion: '2.0.20' });
|
|
14
14
|
expect(describeUpgradeScreen({ version }).state).toBe('compatible');
|
|
15
15
|
});
|
|
16
|
-
it('installs the
|
|
16
|
+
it('installs the discovered stable release and preserves existing CLIs', async () => {
|
|
17
17
|
expect(MINIMUM_OPENCODE2_VERSION).toBe('2.0.20');
|
|
18
|
-
expect(
|
|
19
|
-
expect(resolveUpgradeScreenTarget()).toBe('2.0.23');
|
|
18
|
+
expect(resolveUpgradeScreenTarget()).toBe(MINIMUM_OPENCODE2_VERSION);
|
|
20
19
|
const install = vi.fn(async () => '/owned/opencode');
|
|
21
|
-
await expect(ensurePinnedOpenCode2Cli({ readVersion: (path) => path === '/owned/opencode' ? '2.0.23' : '', install })).resolves.toMatchObject({ version: '2.0.23', installed: true });
|
|
20
|
+
await expect(ensurePinnedOpenCode2Cli({ resolveLatestVersion: async () => '2.0.23', readVersion: (path) => path === '/owned/opencode' ? '2.0.23' : '', install })).resolves.toMatchObject({ version: '2.0.23', installed: true });
|
|
22
21
|
expect(install).toHaveBeenCalledWith(expect.objectContaining({ version: '2.0.23' }));
|
|
23
22
|
install.mockClear();
|
|
24
23
|
await expect(ensurePinnedOpenCode2Cli({ discoveredPath: '/global/opencode', readVersion: () => '2.1.0', install })).resolves.toMatchObject({ version: '2.1.0', installed: false });
|
|
25
24
|
expect(install).not.toHaveBeenCalled();
|
|
26
25
|
});
|
|
27
26
|
it('does not infer a successful installation from an unreadable binary', async () => {
|
|
28
|
-
await expect(ensurePinnedOpenCode2Cli({ readVersion: () => '', install: async () => '/owned/opencode' })).rejects.toThrow('got unknown');
|
|
27
|
+
await expect(ensurePinnedOpenCode2Cli({ resolveLatestVersion: async () => '2.2.0', readVersion: () => '', install: async () => '/owned/opencode' })).rejects.toThrow('got unknown');
|
|
29
28
|
});
|
|
30
29
|
it('verifies the live service after explicit install, and rolls selection back on failure', async () => {
|
|
31
30
|
const persistBinary = vi.fn();
|
|
32
31
|
const restart = vi.fn();
|
|
33
32
|
const deps = { resolveOwnership: async () => ({ ownership: 'shared-service', binaryOwnership: 'owned-cache' }), readServeVersion: vi.fn().mockResolvedValueOnce('2.0.19').mockResolvedValueOnce('2.0.23'), readCliVersion: () => '2.0.23', platformCanInstall: true, install: async () => '/owned/opencode', readBinaryVersion: () => '2.0.23', persistBinary, restart, isSharedService: () => true };
|
|
33
|
+
deps.resolveLatestVersion = async () => '2.0.23';
|
|
34
34
|
await expect(installRequiredOpenCode(deps)).resolves.toMatchObject({ upgraded: true, version: '2.0.23' });
|
|
35
35
|
expect(restart).toHaveBeenCalledWith({ binaryPath: '/owned/opencode' });
|
|
36
36
|
deps.readServeVersion.mockResolvedValue('2.0.19');
|
|
@@ -8,15 +8,15 @@ with an empty result. Remote upstreams never use the Host filesystem as evidence
|
|
|
8
8
|
permission and I/O errors are not deletion. Checks are not negatively cached, so
|
|
9
9
|
a recreated directory participates in the next requested sync.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
Startup does not probe indexed directories. An explicitly requested directory
|
|
12
|
+
refresh removes only missing directory shells with no summary rows, no child rows,
|
|
13
13
|
and no more pages, using one conditional SQLite deletion. Session history and pins
|
|
14
14
|
are preserved. This maintenance does not touch code files or upstream projects.
|
|
15
15
|
Runtime switches and shutdown discard pending checks; successful cleanup publishes
|
|
16
16
|
a revision tip. Snapshot GETs do not perform filesystem scans. Old project paths
|
|
17
17
|
may still be submitted by clients, but pre-scan checks prevent recreating empty
|
|
18
18
|
shells for missing paths. App or external worktree deletion is picked up by the
|
|
19
|
-
next requested sync
|
|
19
|
+
next requested sync; there is no startup or periodic filesystem polling.
|
|
20
20
|
|
|
21
21
|
## Physical directory identity
|
|
22
22
|
|
|
@@ -33,8 +33,8 @@ child membership follows the directory, and the merged head stays bounded to 20.
|
|
|
33
33
|
Reconciliation failure rolls back the entire index conversion. Rechecking on reads
|
|
34
34
|
also recovers paths unavailable during startup.
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
and retain only records whose physical directory matches the
|
|
36
|
+
Explicit directory lists fetch session pages without initializing an upstream
|
|
37
|
+
Location and retain only records whose physical directory matches the request.
|
|
38
38
|
This discovers old aliases outside the index without admitting sibling worktrees.
|
|
39
39
|
Opaque next/previous cursors stay upstream-owned; filtered short/empty pages with
|
|
40
40
|
a continuation are partial, not exhausted. The existing five-page sync budget and
|
|
@@ -121,9 +121,19 @@ Repeated session summary events whose bounded root summary or child membership
|
|
|
121
121
|
is unchanged leave directory recency and the public revision unchanged. Root
|
|
122
122
|
events that remain outside the newest-20 bound follow the same no-op path.
|
|
123
123
|
|
|
124
|
-
`sync-runtime.js` owns cold-start synchronization. The renderer
|
|
125
|
-
|
|
126
|
-
The
|
|
124
|
+
`sync-runtime.js` owns cold-start synchronization. The renderer sends
|
|
125
|
+
`{ startup: true }` to `POST /api/yuri/session-index/sync`, without project paths.
|
|
126
|
+
The Host backfills sessions updated within the last 30 days using a single global
|
|
127
|
+
descending session-list cursor, stopping at the time boundary. It never requests
|
|
128
|
+
Location/config/plugin APIs or probes project paths. Each page and its cursor are
|
|
129
|
+
committed atomically in SQLite under the runtime key; empty success also records
|
|
130
|
+
completion. Subsequent launches perform no upstream history reads after completion.
|
|
131
|
+
Failure/shutdown preserves the last committed cursor for retry. Existing summaries
|
|
132
|
+
win over backfill, and normal create/update/archive/delete events maintain the index.
|
|
133
|
+
Existing databases without this marker receive one bounded backfill without being
|
|
134
|
+
cleared. Manual directory refresh remains a separate explicit operation.
|
|
135
|
+
|
|
136
|
+
The runtime processes explicit directory refreshes sequentially. OpenCode 2.x list is cursor-only (no
|
|
127
137
|
`start` incremental); each directory fetches active-only pages (`limit=20`)
|
|
128
138
|
after optional Host `projectSessions` overlay. Consecutive archived rows may
|
|
129
139
|
consume further pages within a small page budget so the newest-20 **active**
|
|
@@ -55,7 +55,9 @@ export const registerSessionIndexRoutes = (app, {
|
|
|
55
55
|
app.post('/api/yuri/session-index/sync', async (req, res) => {
|
|
56
56
|
if (!sessionIndexSyncRuntime) return unsupported(res);
|
|
57
57
|
const directories = Array.isArray(req.body?.directories) ? req.body.directories : [];
|
|
58
|
-
const base =
|
|
58
|
+
const base = req.body?.startup === true
|
|
59
|
+
? sessionIndexSyncRuntime.enqueue([], { startup: true })
|
|
60
|
+
: sessionIndexSyncRuntime.enqueue(directories);
|
|
59
61
|
if (!hostStoreWired) return res.status(202).json(base);
|
|
60
62
|
// Clients apply this body as a snapshot: same Host archive gate as GET.
|
|
61
63
|
const host = await readHostMap();
|
|
@@ -79,6 +79,8 @@ describe('session index routes', () => {
|
|
|
79
79
|
expect(res.statusCode).toBe(202);
|
|
80
80
|
expect(enqueue).toHaveBeenCalledWith(['/repo/a', '/repo/b']);
|
|
81
81
|
expect(res.body).toMatchObject({ revision: 1, sync: { active: true } });
|
|
82
|
+
route('POST', '/api/yuri/session-index/sync')({ body: { startup: true, directories: ['/ignored'] } }, res);
|
|
83
|
+
expect(enqueue).toHaveBeenLastCalledWith([], { startup: true });
|
|
82
84
|
});
|
|
83
85
|
|
|
84
86
|
it('does not register a long-poll changes route', () => {
|
|
@@ -688,7 +688,30 @@ export const createSessionIndexService = ({ dbPath, getRuntimeConfig = () => nul
|
|
|
688
688
|
`).run(runtimeKey(), directory).changes > 0;
|
|
689
689
|
|
|
690
690
|
try { reconcileDirectoryAliases(runtimeKey()); } catch (error) { db.close(); throw error; }
|
|
691
|
+
const historyKey = () => `history_backfill:${runtimeKey()}`;
|
|
692
|
+
const getHistoryBackfill = () => {
|
|
693
|
+
const row = db.prepare('SELECT value FROM session_index_meta WHERE key = ?').get(historyKey());
|
|
694
|
+
return row ? JSON.parse(row.value) : null;
|
|
695
|
+
};
|
|
696
|
+
const commitHistoryPage = db.transaction(({ sessions, progress, expectedRuntimeKey }) => {
|
|
697
|
+
if (expectedRuntimeKey !== runtimeKey()) return false;
|
|
698
|
+
for (const session of sessions) {
|
|
699
|
+
// Live events and already indexed summaries win over historical reads.
|
|
700
|
+
if (!findBySessionId(session.id)) {
|
|
701
|
+
upsert(session);
|
|
702
|
+
const directory = normalizeDirectory(session?.location?.directory ?? session?.directory);
|
|
703
|
+
// The bounded 30-day import is not proof that older history is empty.
|
|
704
|
+
db.prepare('UPDATE runtime_directory SET has_more = 1 WHERE runtime_key = ? AND directory = ? AND last_full_synced_at = 0')
|
|
705
|
+
.run(expectedRuntimeKey, directory);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
db.prepare('INSERT OR REPLACE INTO session_index_meta(key, value) VALUES (?, ?)')
|
|
709
|
+
.run(historyKey(), JSON.stringify(progress));
|
|
710
|
+
return true;
|
|
711
|
+
});
|
|
691
712
|
return {
|
|
713
|
+
getHistoryBackfill,
|
|
714
|
+
commitHistoryPage,
|
|
692
715
|
replaceDirectory,
|
|
693
716
|
removeEmptyDirectory,
|
|
694
717
|
replaceDirectories,
|