Skip to content

Commit 28495ea

Browse files
committed
refactor: isolate workshop revision handoff
1 parent f979883 commit 28495ea

3 files changed

Lines changed: 26 additions & 24 deletions

File tree

‎ui/src/app/bootstrap.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import {
1111
normalizeInitialApplicationLocation,
1212
resolveInitialApplicationLocation,
1313
} from "./bootstrap-location.ts";
14-
import { bootstrapApplication, createSkillWorkshopRevisionHandoff } from "./bootstrap.ts";
14+
import { bootstrapApplication } from "./bootstrap.ts";
1515
import type { ApplicationContext } from "./context.ts";
1616
import { loadSettings, saveSettings } from "./settings.ts";
17+
import { createSkillWorkshopRevisionHandoff } from "./skill-workshop-revision-handoff.ts";
1718

1819
// Startup progress (dynamic imports, gateway subscribe, router start) is not a
1920
// performance assertion, so these waits must not inherit vi.waitFor's 1s default:

‎ui/src/app/bootstrap.ts‎

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import type {
3232
ApplicationContext,
3333
ApplicationNavigationPreferences,
3434
ApplicationNavigationPreferencesSnapshot,
35-
ApplicationSkillWorkshopRevisionHandoff,
3635
ApplicationTheme,
3736
ApplicationThemeServerSelection,
3837
} from "./context.ts";
@@ -51,6 +50,7 @@ import {
5150
saveSettings,
5251
type UiSettings,
5352
} from "./settings.ts";
53+
import { createSkillWorkshopRevisionHandoff } from "./skill-workshop-revision-handoff.ts";
5454
import { createStartupLifecycle, type StartupStep } from "./startup-lifecycle.ts";
5555
import { resolveApplicationStartupSettings } from "./startup-settings.ts";
5656
import { startThemeTransition } from "./theme-transition.ts";
@@ -204,28 +204,6 @@ function createApplicationNavigationPreferences(
204204
};
205205
}
206206

207-
export function createSkillWorkshopRevisionHandoff(): ApplicationSkillWorkshopRevisionHandoff {
208-
let pending: Parameters<ApplicationSkillWorkshopRevisionHandoff["prepare"]>[0] | null = null;
209-
return {
210-
prepare: (handoff) => {
211-
pending = handoff;
212-
},
213-
consume: (sessionKey, owner) => {
214-
if (!pending || pending.sessionKey !== sessionKey || pending.owner !== owner) {
215-
return null;
216-
}
217-
const handoff = pending;
218-
pending = null;
219-
return handoff;
220-
},
221-
clear: (handoff) => {
222-
if (!handoff || pending === handoff) {
223-
pending = null;
224-
}
225-
},
226-
};
227-
}
228-
229207
export type ApplicationRuntime = {
230208
readonly context: ApplicationContext<RouteId>;
231209
readonly router: ApplicationRouter;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { ApplicationSkillWorkshopRevisionHandoff } from "./context.ts";
2+
3+
export function createSkillWorkshopRevisionHandoff(): ApplicationSkillWorkshopRevisionHandoff {
4+
let pending: Parameters<ApplicationSkillWorkshopRevisionHandoff["prepare"]>[0] | null = null;
5+
return {
6+
prepare: (handoff) => {
7+
pending = handoff;
8+
},
9+
consume: (sessionKey, owner) => {
10+
if (!pending || pending.sessionKey !== sessionKey || pending.owner !== owner) {
11+
return null;
12+
}
13+
const handoff = pending;
14+
pending = null;
15+
return handoff;
16+
},
17+
clear: (handoff) => {
18+
if (!handoff || pending === handoff) {
19+
pending = null;
20+
}
21+
},
22+
};
23+
}

0 commit comments

Comments
 (0)