Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

refactor(desktop): let serverSwitch decide whether the origin moved

Dongdong Chend77931240e8f
diff --git a/apps/desktop/src/main/local-server.test.ts b/apps/desktop/src/main/local-server.test.ts
index 71421952..bd812df4 100644
--- a/apps/desktop/src/main/local-server.test.ts
+++ b/apps/desktop/src/main/local-server.test.ts
@@ -673,7 +673,10 @@ describe("LocalServerModule", () => {
"pw",
);
- expect(f.setServer).toHaveBeenCalledWith("http://localhost:3000");
+ expect(f.setServer).toHaveBeenCalledWith(
+ "http://localhost:3000",
+ undefined,
+ );
expect(f.enroll).toHaveBeenCalled();
expect(f.module.status()).toMatchObject({
phase: "ready",
@@ -2342,7 +2345,10 @@ describe("LocalServerModule after a restart", () => {
const f = fixture({}, enrolled, record);
await f.host.start();
await vi.waitFor(() => expect(f.module.status().phase).toBe("ready"));
- expect(f.setServer).toHaveBeenCalledWith("http://localhost:3000");
+ expect(f.setServer).toHaveBeenCalledWith(
+ "http://localhost:3000",
+ "http://localhost:3000",
+ );
// The services were down, so the window waited on the starting page.
expect(f.showStarting).toHaveBeenCalledOnce();
expect(f.showStartFailed).not.toHaveBeenCalled();
@@ -2576,7 +2582,10 @@ describe("LocalServerModule after a restart", () => {
expect(args[args.indexOf("--source-repo") + 1]).toBe(current);
// The window leaves the older interface while they restart.
expect(f.showUpdating).toHaveBeenCalledOnce();
- expect(f.setServer).toHaveBeenCalledWith("http://localhost:3000");
+ expect(f.setServer).toHaveBeenCalledWith(
+ "http://localhost:3000",
+ "http://localhost:3000",
+ );
expect(
JSON.parse(
readFileSync(path.join(f.home, "desktop", "local-server.json"), "utf8"),
@@ -2821,7 +2830,10 @@ describe("LocalServerModule after a restart", () => {
rmSync(path.join(f.home, "resume-fails"));
f.bus.emit("local-server.retry");
await vi.waitFor(() => expect(f.module.status().phase).toBe("ready"));
- expect(f.setServer).toHaveBeenCalledWith("http://localhost:3000");
+ expect(f.setServer).toHaveBeenCalledWith(
+ "http://localhost:3000",
+ "http://localhost:3000",
+ );
await f.host.stop("quit");
});
diff --git a/apps/desktop/src/main/local-server.ts b/apps/desktop/src/main/local-server.ts
index 4fba3eba..6c60b940 100644
--- a/apps/desktop/src/main/local-server.ts
+++ b/apps/desktop/src/main/local-server.ts
@@ -2171,9 +2171,9 @@ export class LocalServerModule implements Module {
// `previous` is the origin this installation answered at before.
#ready(origin: string, previous?: string): void {
this.#origin = origin;
- const windows = this.#ctx?.get<WindowManagerModule>("WindowManager");
- if (previous && previous !== origin) windows?.setServer(origin, previous);
- else windows?.setServer(origin);
+ this.#ctx
+ ?.get<WindowManagerModule>("WindowManager")
+ ?.setServer(origin, previous);
}
// The server sets up the Another Me once this computer offers a signed-in