Merge pull request #685 from carlulsoe/fix/daemon-restart-feedback
fix(cli): improve daemon restart feedback [AI-assisted]
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
- Docker: allow optional home volume + extra bind mounts in `docker-setup.sh`. (#679) — thanks @gabriel-trigo.
|
- Docker: allow optional home volume + extra bind mounts in `docker-setup.sh`. (#679) — thanks @gabriel-trigo.
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
- CLI: avoid success message when daemon restart is skipped. (#685) — thanks @carlulsoe.
|
||||||
- macOS: stabilize bridge tunnels, guard invoke senders on disconnect, and drain stdout/stderr to avoid deadlocks. (#676) — thanks @ngutman.
|
- macOS: stabilize bridge tunnels, guard invoke senders on disconnect, and drain stdout/stderr to avoid deadlocks. (#676) — thanks @ngutman.
|
||||||
- Agents/System: clarify sandboxed runtime in system prompt and surface elevated availability when sandboxed.
|
- Agents/System: clarify sandboxed runtime in system prompt and surface elevated availability when sandboxed.
|
||||||
- Auto-reply: prefer `RawBody` for command/directive parsing (WhatsApp + Discord) and prevent fallback runs from clobbering concurrent session updates. (#643) — thanks @mcinteerj.
|
- Auto-reply: prefer `RawBody` for command/directive parsing (WhatsApp + Discord) and prevent fallback runs from clobbering concurrent session updates. (#643) — thanks @mcinteerj.
|
||||||
|
|||||||
@@ -589,7 +589,6 @@ export async function getReplyFromConfig(
|
|||||||
(agentCfg?.elevatedDefault as ElevatedLevel | undefined) ??
|
(agentCfg?.elevatedDefault as ElevatedLevel | undefined) ??
|
||||||
"on")
|
"on")
|
||||||
: "off";
|
: "off";
|
||||||
const providerKey = sessionCtx.Provider?.trim().toLowerCase();
|
|
||||||
const resolvedBlockStreaming =
|
const resolvedBlockStreaming =
|
||||||
opts?.disableBlockStreaming === true
|
opts?.disableBlockStreaming === true
|
||||||
? "off"
|
? "off"
|
||||||
|
|||||||
@@ -993,7 +993,12 @@ export async function runDaemonStop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function runDaemonRestart() {
|
/**
|
||||||
|
* Restart the gateway daemon service.
|
||||||
|
* @returns `true` if restart succeeded, `false` if the service was not loaded.
|
||||||
|
* Throws/exits on check or restart failures.
|
||||||
|
*/
|
||||||
|
export async function runDaemonRestart(): Promise<boolean> {
|
||||||
const service = resolveGatewayService();
|
const service = resolveGatewayService();
|
||||||
let loaded = false;
|
let loaded = false;
|
||||||
try {
|
try {
|
||||||
@@ -1001,20 +1006,22 @@ export async function runDaemonRestart() {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
defaultRuntime.error(`Gateway service check failed: ${String(err)}`);
|
defaultRuntime.error(`Gateway service check failed: ${String(err)}`);
|
||||||
defaultRuntime.exit(1);
|
defaultRuntime.exit(1);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
defaultRuntime.log(`Gateway service ${service.notLoadedText}.`);
|
defaultRuntime.log(`Gateway service ${service.notLoadedText}.`);
|
||||||
for (const hint of renderGatewayServiceStartHints()) {
|
for (const hint of renderGatewayServiceStartHints()) {
|
||||||
defaultRuntime.log(`Start with: ${hint}`);
|
defaultRuntime.log(`Start with: ${hint}`);
|
||||||
}
|
}
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await service.restart({ stdout: process.stdout });
|
await service.restart({ stdout: process.stdout });
|
||||||
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
defaultRuntime.error(`Gateway restart failed: ${String(err)}`);
|
defaultRuntime.error(`Gateway restart failed: ${String(err)}`);
|
||||||
defaultRuntime.exit(1);
|
defaultRuntime.exit(1);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,13 +124,40 @@ describe("update-cli", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
vi.mocked(runGatewayUpdate).mockResolvedValue(mockResult);
|
vi.mocked(runGatewayUpdate).mockResolvedValue(mockResult);
|
||||||
vi.mocked(runDaemonRestart).mockResolvedValue();
|
vi.mocked(runDaemonRestart).mockResolvedValue(true);
|
||||||
|
|
||||||
await updateCommand({ restart: true });
|
await updateCommand({ restart: true });
|
||||||
|
|
||||||
expect(runDaemonRestart).toHaveBeenCalled();
|
expect(runDaemonRestart).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("updateCommand skips success message when restart does not run", async () => {
|
||||||
|
const { runGatewayUpdate } = await import("../infra/update-runner.js");
|
||||||
|
const { runDaemonRestart } = await import("./daemon-cli.js");
|
||||||
|
const { defaultRuntime } = await import("../runtime.js");
|
||||||
|
const { updateCommand } = await import("./update-cli.js");
|
||||||
|
|
||||||
|
const mockResult: UpdateRunResult = {
|
||||||
|
status: "ok",
|
||||||
|
mode: "git",
|
||||||
|
steps: [],
|
||||||
|
durationMs: 100,
|
||||||
|
};
|
||||||
|
|
||||||
|
vi.mocked(runGatewayUpdate).mockResolvedValue(mockResult);
|
||||||
|
vi.mocked(runDaemonRestart).mockResolvedValue(false);
|
||||||
|
vi.mocked(defaultRuntime.log).mockClear();
|
||||||
|
|
||||||
|
await updateCommand({ restart: true });
|
||||||
|
|
||||||
|
const logLines = vi
|
||||||
|
.mocked(defaultRuntime.log)
|
||||||
|
.mock.calls.map((call) => String(call[0]));
|
||||||
|
expect(
|
||||||
|
logLines.some((line) => line.includes("Daemon restarted successfully.")),
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it("updateCommand validates timeout option", async () => {
|
it("updateCommand validates timeout option", async () => {
|
||||||
const { defaultRuntime } = await import("../runtime.js");
|
const { defaultRuntime } = await import("../runtime.js");
|
||||||
const { updateCommand } = await import("./update-cli.js");
|
const { updateCommand } = await import("./update-cli.js");
|
||||||
|
|||||||
@@ -156,8 +156,8 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
|
|||||||
defaultRuntime.log(theme.heading("Restarting daemon..."));
|
defaultRuntime.log(theme.heading("Restarting daemon..."));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await runDaemonRestart();
|
const restarted = await runDaemonRestart();
|
||||||
if (!opts.json) {
|
if (!opts.json && restarted) {
|
||||||
defaultRuntime.log(theme.success("Daemon restarted successfully."));
|
defaultRuntime.log(theme.success("Daemon restarted successfully."));
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -42,5 +42,5 @@ describe("sandbox explain command", () => {
|
|||||||
expect(Array.isArray(parsed.fixIt)).toBe(true);
|
expect(Array.isArray(parsed.fixIt)).toBe(true);
|
||||||
expect(parsed.fixIt).toContain("agents.defaults.sandbox.mode=off");
|
expect(parsed.fixIt).toContain("agents.defaults.sandbox.mode=off");
|
||||||
expect(parsed.fixIt).toContain("tools.sandbox.tools.deny");
|
expect(parsed.fixIt).toContain("tools.sandbox.tools.deny");
|
||||||
});
|
}, 15_000);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ describe("discord tool result dispatch", () => {
|
|||||||
expect(runtimeError).not.toHaveBeenCalled();
|
expect(runtimeError).not.toHaveBeenCalled();
|
||||||
expect(sendMock).toHaveBeenCalledTimes(1);
|
expect(sendMock).toHaveBeenCalledTimes(1);
|
||||||
expect(sendMock.mock.calls[0]?.[1]).toMatch(/^PFX /);
|
expect(sendMock.mock.calls[0]?.[1]).toMatch(/^PFX /);
|
||||||
}, 10000);
|
}, 15_000);
|
||||||
|
|
||||||
it("caches channel info lookups between messages", async () => {
|
it("caches channel info lookups between messages", async () => {
|
||||||
const { createDiscordMessageHandler } = await import("./monitor.js");
|
const { createDiscordMessageHandler } = await import("./monitor.js");
|
||||||
|
|||||||
Reference in New Issue
Block a user