Compare commits

...
2 Commits
Author SHA1 Message Date
tbenandClaude Opus 5.5 ef0237ecf0 Bump version to 0.28.19
CI / check (push) Canceled after 0s
Release image / image (release) Canceled after 0s
Release image / computer-image (release) Canceled after 0s
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 09:25:57 +01:00
tbenandClaude Opus 5.5 02c49a3c9b Show why a hook's runner check failed, to the user and to the bot
The hook row and modal name the failure and when the runner was last
checked, and list_hooks describes the runner, its folder (inside the
bot's folder, not ~) and a failed check, pointing at propose_hook rather
than a process started by hand. Also reword Run silently: every hook has
its own thread, the setting is whether a run takes the conversation over.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 09:25:57 +01:00
8 changed files with 120 additions and 6 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cobble",
"version": "0.28.18",
"version": "0.28.19",
"module": "index.ts",
"type": "module",
"private": true,
+9 -1
View File
@@ -101,7 +101,15 @@ export default function HookDetailModal({ hook, can_manage = false, onClose, onE
<TaskFactRow label="Runner">
{runner.running
? `Up since ${relativeTime({ at: Number(hook.runner_started_at) || Date.now() })}`
: hook.runner_last_error || "Down"}
: "Down"}
</TaskFactRow>
{runner.error ? (
<TaskFactRow label="Check failed">{runner.error}</TaskFactRow>
) : null}
<TaskFactRow label="Last checked">
{hook.runner_checked_at
? relativeTime({ at: Number(hook.runner_checked_at) })
: "Not yet"}
</TaskFactRow>
{hook.runner_command ? (
<TaskFactRow label="Runner command">
+1 -1
View File
@@ -317,7 +317,7 @@ export default function HookForm({
) : null}
<Checkbox
title="Run silently"
label="Keep its runs in the hook's own thread: they never take over the conversation or notify me. Read them from the hook, or in the bot's sessions."
label="Run without taking over the conversation: its thread stays out of the rail, its runs don't notify me or change the bot's face. Unchecked, each run makes its thread the conversation's active session."
checked={silent}
changeHandler={setSilent}
labelProps={{ className: "w-full" }}
+4 -1
View File
@@ -1,4 +1,5 @@
import type { BotHookWithNames } from "@/src/types";
import describeHookRunner from "./describe-hook-runner";
type Params = {
hook: BotHookWithNames;
@@ -12,7 +13,8 @@ type Params = {
/**
* One hook as a bot reads it: id, name, what calls it, where it runs, its
* state, runs and last call (ISO, UTC), and the last error if any. Never
* state, runs and last call (ISO, UTC), the last error if any, and the
* runner it keeps with why its last check failed. Never
* its URL or any part of its token: a bot doesn't hold those.
*/
export default function describeBotHook({ hook, owner }: Params) {
@@ -31,6 +33,7 @@ export default function describeBotHook({ hook, owner }: Params) {
`${runs} run${runs == 1 ? "" : "s"} so far`,
hook.last_called_at ? `last called ${new Date(Number(hook.last_called_at)).toISOString()}` : "never called",
hook.last_error ? `last error: ${hook.last_error}` : "",
describeHookRunner({ hook }),
];
return parts.filter(Boolean).join(", ");
+58
View File
@@ -0,0 +1,58 @@
import { describe, expect, test } from "bun:test";
import type { BotHookWithNames } from "@/src/types";
import describeBotHook from "./describe-bot-hook";
import describeHookRunner from "./describe-hook-runner";
const base = {
id: 2,
title: "WhatsApp",
source: "url",
enabled: 1,
run_count: 0,
} as BotHookWithNames;
describe("describeHookRunner", () => {
test("says nothing for a hook without a runner", () => {
expect(describeHookRunner({ hook: base })).toBe("");
});
test("names a failed check, its time and the fix", () => {
const text = describeHookRunner({
hook: {
...base,
runner_command: "./run.sh",
runner_dir: "whatsapp",
runner_computer_id: 1,
runner_checked_at: Date.UTC(2026, 10, 30, 8, 5),
runner_last_error: "Its folder isn't there: /home/cb-4/workspace/whatsapp",
},
});
expect(text).toContain("runner `./run.sh` starts in \"whatsapp\" inside the bot's folder (not your ~) on computer 1");
expect(text).toContain("NOT RUNNING, the check failed (last checked 2026-11-30T08:05:00.000Z)");
expect(text).toContain("Its folder isn't there: /home/cb-4/workspace/whatsapp");
expect(text).toContain("propose_hook");
});
test("says a running runner is up and since when", () => {
expect(
describeHookRunner({
hook: {
...base,
runner_command: "./run.sh",
runner_pid: 42,
runner_started_at: Date.UTC(2026, 10, 30, 8, 0),
runner_checked_at: Date.UTC(2026, 10, 30, 8, 5),
},
}),
).toBe(
"runner `./run.sh` starts in the bot's folder (not your ~): running since 2026-11-30T08:00:00.000Z, last checked 2026-11-30T08:05:00.000Z",
);
});
test("is part of the hook a bot lists", () => {
expect(
describeBotHook({ hook: { ...base, runner_command: "./run.sh", runner_last_error: "It isn't running." } }),
).toContain("NOT RUNNING");
});
});
+45
View File
@@ -0,0 +1,45 @@
import type { BotHookWithNames } from "@/src/types";
import hookRunnerState from "./hook-runner-state";
type Params = {
hook: BotHookWithNames;
};
/**
* A hook's runner as a bot reads it, from what the last check stored
* (`syncHookRunners`): the command, the folder it starts in (inside the
* bot's folder, which is not a run's `~`), whether it is up, and when it
* isn't, why the check failed. Empty when the hook keeps no runner.
*
* A failed check says the fix is the runner itself, through a proposal:
* a bot that only saw "down" started the process by hand, which lasted
* until the computer restarted, and never learned the folder was wrong.
*/
export default function describeHookRunner({ hook }: Params) {
const state = hookRunnerState({ hook });
if (!state.configured) return "";
const where = [
`starts in ${hook.runner_dir ? `"${hook.runner_dir}" inside the bot's folder` : "the bot's folder"} (not your ~)`,
hook.runner_computer_id ? `on computer ${hook.runner_computer_id}` : "",
]
.filter(Boolean)
.join(" ");
const checked = hook.runner_checked_at
? `last checked ${new Date(Number(hook.runner_checked_at)).toISOString()}`
: "not checked yet";
const runner = `runner \`${hook.runner_command}\` ${where}`;
if (state.running) {
const since = hook.runner_started_at ? ` since ${new Date(Number(hook.runner_started_at)).toISOString()}` : "";
return `${runner}: running${since}, ${checked}`;
}
if (state.error) {
return `${runner}: NOT RUNNING, the check failed (${checked}): ${state.error}. Fix the runner with propose_hook (runner_command, runner_dir); starting the process by hand lasts only until the computer restarts`;
}
return `${runner}: not running, ${checked}`;
}
+1 -1
View File
@@ -33,7 +33,7 @@ export default function hookSubtitle({ hook, now = Date.now(), show_bot = true,
`${runs} ${runs == 1 ? "run" : "runs"}`,
hook.last_called_at ? `called ${relativeTime({ at: hook.last_called_at, now })}` : "never called",
hook.has_signing_secret ? "signed" : "",
runner.configured ? `runner ${runner.note}` : "",
runner.configured ? `runner ${runner.note}${runner.error ? `: ${runner.error}` : ""}` : "",
hook.last_error || "",
]
.filter(Boolean)