Your own team of AI bots in one self-hosted binary: spaces, every account you have, handoffs, approvals and routines. Open-source, self-hosted alternative to Grok Bot, Claude Duet and OpenAI dots. Rust + React.
Rust ai-agentsai-assistantai-botautomationbotbots-teamchatbotclaude-duetgrokgrok-botgrok-bot-alternativeharnessllmmulti-agentopenai-dotsopenbotpersonal-agentrustself-hostedselfhosted-ai
Undo delete: a second delete sends the waiting one; scenario notice names past runs; no skill flicker
Lin (kwant bot)856de4c7573d
diff --git a/frontend/src/components/ParallelUniverseView.tsx b/frontend/src/components/ParallelUniverseView.tsxindex a1865e3e..94499611 100644--- a/frontend/src/components/ParallelUniverseView.tsx+++ b/frontend/src/components/ParallelUniverseView.tsx@@ -755,10 +755,7 @@ export const ParallelPage: React.FC<{ onBack?: () => void }> = ({ onBack }) => {const [notice, setNotice] = useState<{ text: string; error: boolean } | null>(null);// A deleted scenario leaves the list at once; the delete is sent once Undo has had its chanceconst [removing, setRemoving] = useState<Scenario | null>(null);- const removal = useUndoableDelete(() => {- setScenarios((list) => (list ?? []).filter((x) => x.id !== removing?.id));- setRemoving(null);- });+ const removal = useUndoableDelete();const alive = useRef(true);const fail = (e: unknown) => {@@ -885,7 +882,11 @@ export const ParallelPage: React.FC<{ onBack?: () => void }> = ({ onBack }) => {const remove = (s: Scenario) => {setRemoving(s);- removal.start(() => parallelApi.remove(s.id));+ // Each delete drops its own scenario: a quick second delete sends the first one straight away+ removal.start(async () => {+ await parallelApi.remove(s.id);+ if (alive.current) setScenarios((list) => (list ?? []).filter((x) => x.id !== s.id));+ });setScreen({ kind: 'list' });};const undoRemove = () => {@@ -899,7 +900,7 @@ export const ParallelPage: React.FC<{ onBack?: () => void }> = ({ onBack }) => {if (screen.kind === 'list') {body = (<>- {removal.pending && removing && <UndoNotice text={`Deleted “${removing.title}”.`} onUndo={undoRemove} className="mb-3" />}+ {removal.pending && removing && <UndoNotice text={`Deleted “${removing.title}” and its past runs.`} onUndo={undoRemove} className="mb-3" />}{removal.error && <Notice text={`Couldn’t delete it: ${removal.error}`} error />}<ScenarioList scenarios={listed} onOpen={(s) => setScreen({ kind: 'scenario', id: s.id })} onNew={() => (setSaveError(null), setScreen({ kind: 'edit', scenario: null }))} /></>diff --git a/frontend/src/components/SkillsPanel.tsx b/frontend/src/components/SkillsPanel.tsxindex 5e5b571d..ac58721e 100644--- a/frontend/src/components/SkillsPanel.tsx+++ b/frontend/src/components/SkillsPanel.tsx@@ -232,6 +232,7 @@ export const PendingSkill: React.FC<{ skill: Skill; replaces?: Skill; initialPenrejection.start(() => skillsApi.reject(skill.id));};+ if (rejection.gone) return null;if (rejection.pending) return <UndoNotice as="li" text={`Rejected “${skill.name}”. Nothing was added.`} onUndo={rejection.undo} />;return (@@ -313,6 +314,7 @@ export const ActiveSkill: React.FC<{ skill: Skill; initialPending?: boolean }> =removal.start(() => skillsApi.remove(skill.id));};+ if (removal.gone) return null;if (removal.pending) return <UndoNotice as="li" text={`Deleted “${skill.name}”. Bots stop using it.`} onUndo={removal.undo} />;return (diff --git a/frontend/src/undoDelete.ts b/frontend/src/undoDelete.tsindex 2033671a..88ddf694 100644--- a/frontend/src/undoDelete.ts+++ b/frontend/src/undoDelete.ts@@ -32,11 +32,13 @@ export class DeferredDelete {return this.run !== null;}- /** Starts the window. A second start while one is waiting replaces it. */+ /** Starts the window. One already waiting is sent at once, so a quick second delete never drops it. */start(run: () => Promise<unknown>): void {+ const earlier = this.run;this.cancelTimer();this.run = run;this.handle = this.timers.set(() => void this.flush(), this.ms);+ if (earlier) void this.send(earlier);}/** Cancels the waiting delete; nothing is sent. Returns whether there was one. */@@ -53,6 +55,10 @@ export class DeferredDelete {if (!run) return;this.cancelTimer();this.run = null;+ await this.send(run);+ }++ private async send(run: () => Promise<unknown>): Promise<void> {try {await run();this.onCommitted(null);@@ -70,11 +76,13 @@ export class DeferredDelete {/*** `pending` while the Undo window is open. `start(run)` hides the item, `undo()` brings it back,* and `run` is sent when the window closes or the component unmounts. A failed delete brings the- * item back with `error` set; `onDone` runs after a successful one (e.g. to reload the list).+ * item back with `error` set; `onDone` runs after a successful one (e.g. to reload the list), and+ * `gone` stays true so the item doesn't show again before the list catches up.*/export function useUndoableDelete(onDone?: () => void, initialPending = false) {const [pending, setPending] = useState(initialPending);const [error, setError] = useState<string | null>(null);+ const [gone, setGone] = useState(false);const alive = useRef(true);const done = useRef(onDone);done.current = onDone;@@ -82,9 +90,13 @@ export function useUndoableDelete(onDone?: () => void, initialPending = false) {if (!box.current) {box.current = new DeferredDelete((err) => {if (!alive.current) return;- setPending(false);+ // An earlier delete can finish while a later one is still waiting+ setPending(box.current?.pending ?? false);setError(err);- if (!err) done.current?.();+ if (!err) {+ setGone(true);+ done.current?.();+ }});}@@ -107,5 +119,5 @@ export function useUndoableDelete(onDone?: () => void, initialPending = false) {setPending(false);}, []);- return { pending, error, start, undo };+ return { pending, gone, error, start, undo };}diff --git a/frontend/tests/fewerConfirms.test.mjs b/frontend/tests/fewerConfirms.test.mjsindex 47ba60bf..d50539ad 100644--- a/frontend/tests/fewerConfirms.test.mjs+++ b/frontend/tests/fewerConfirms.test.mjs@@ -98,6 +98,50 @@ test('leaving the screen sends it at once; a failed delete reports why', async (assert.deepEqual(results, [null, 'HTTP 500']);});+test('a second delete inside the window sends the first one, never drops it', async () => {+ // Rigel's repro: delete scenario A, open B within 6s, delete B. A used to be silently dropped.+ const sent = [];+ const timers = { set: (fn) => fn, clear: () => {} };+ const d = new u.DeferredDelete(() => {}, 6000, timers);+ d.start(async () => sent.push('A'));+ d.start(async () => sent.push('B'));+ await d.flush();+ assert.deepEqual(sent, ['A', 'B']);+});++test('the second delete keeps its own Undo window; a failed first one still reports', async () => {+ const t = fakeTimers();+ const results = [];+ const sent = [];+ const d = new u.DeferredDelete((err) => results.push(err), u.UNDO_MS, t);+ d.start(async () => {+ sent.push('A');+ throw new Error('HTTP 500');+ });+ d.start(async () => sent.push('B'));+ await settle();+ assert.deepEqual(sent, ['A'], 'A goes at once, B waits');+ assert.deepEqual(results, ['HTTP 500']);+ assert.equal(d.pending, true, 'B can still be undone');+ assert.equal(t.count, 1, 'only B is on a timer');+ assert.equal(d.undo(), true);+ t.fire();+ await settle();+ assert.deepEqual(sent, ['A'], 'undoing B sends nothing more');+});++test('scenario Undo says its past runs go too; each scenario delete drops only itself', () => {+ const s = readFileSync(join(root, 'src/components/ParallelUniverseView.tsx'), 'utf8');+ assert.match(s, /Deleted “\$\{removing\.title\}” and its past runs\./);+ assert.match(s, /await parallelApi\.remove\(s\.id\);[^]*filter\(\(x\) => x\.id !== s\.id\)/);+});++test('a deleted or rejected skill stays hidden after the window, not back until the list reloads', () => {+ const s = readFileSync(join(root, 'src/components/SkillsPanel.tsx'), 'utf8');+ assert.match(s, /if \(removal\.gone\) return null;/);+ assert.match(s, /if \(rejection\.gone\) return null;/);+});+const routine = {id: 'r1', kwant_id: 'k1', channel_id: null, name: 'Morning digest', instructions: 'x',schedule: { type: 'daily', time: '09:00', tz: 'UTC' }, enabled: true, next_run_at: null, last_run_at: null, last_status: null, created_at: '2026-10-20T08:00:00Z',