Skip to content

armgit / kwant

Public Imported from GitHub
0

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.

Follow-up card date in local time; drop stale AutoFix line once settled (#283)

Oleksandr Ivanchenko1325b12c1e95
diff --git a/frontend/src/botActions.ts b/frontend/src/botActions.ts
index c80a83fe..2e83fd93 100644
--- a/frontend/src/botActions.ts
+++ b/frontend/src/botActions.ts
@@ -186,6 +186,25 @@ export function scheduleWords(schedule: unknown, scheduleText?: unknown): string
return typeof scheduleText === 'string' && scheduleText ? sentence(scheduleText) : 'Unknown schedule';
}
+/** "once on Fri, Nov 6 at 03:00 PM" in the viewer's own time zone, the way `formatWhen` writes it. */
+export function onceWords(iso: string): string | null {
+ const d = new Date(iso);
+ if (Number.isNaN(d.getTime())) return null;
+ const day = d.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric' });
+ const time = d.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });
+ return `once on ${day} at ${time}`;
+}
+
+/** The card's one line. The server writes a one-off schedule as "once at <RFC 3339 UTC>"; that part is
+ * put in the viewer's local time. Anything else stays as the server wrote it. */
+export function summaryText(m: BotActionMeta): string {
+ const s = asSchedule(m.details.schedule);
+ const raw = m.details.schedule_text;
+ if (s?.type !== 'once' || typeof raw !== 'string' || !raw || !m.summary.includes(raw)) return m.summary;
+ const words = onceWords(s.at);
+ return words ? m.summary.replace(raw, words) : m.summary;
+}
+
/** The facts a routine card lists: when, as whom, where, and the next run. */
export function routineFacts(m: BotActionMeta): Array<{ label: string; value: string }> {
if (m.target_kind !== 'routine') return [];
diff --git a/frontend/src/components/BotActionCard.tsx b/frontend/src/components/BotActionCard.tsx
index 18d851ab..2e98880a 100644
--- a/frontend/src/components/BotActionCard.tsx
+++ b/frontend/src/components/BotActionCard.tsx
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { AlertTriangle, CalendarClock, CheckCircle2, Loader2, MinusCircle, Pause, Pencil, ShieldQuestion, Undo2, Wrench } from 'lucide-react';
import { ModernAvatar } from './ModernAvatar';
-import { BotActionMeta, actionStateText, botGone, actionVerb, botActionView, routineButtons, routineFacts, sentence } from '../botActions';
+import { BotActionMeta, actionStateText, botGone, actionVerb, botActionView, routineButtons, routineFacts, sentence, summaryText } from '../botActions';
export type BotActionDecision = 'undo' | 'confirm' | 'decline';
@@ -70,7 +70,7 @@ export const BotActionCard: React.FC<BotActionCardProps> = ({ meta, messageId, k
</span>
</span>
<p className={`text-sm break-words leading-relaxed ${resolved ? 'text-zinc-400 line-through decoration-zinc-600' : 'text-zinc-100'}`}>
- {sentence(view.summary) || 'A change in the app.'}
+ {sentence(summaryText(view)) || 'A change in the app.'}
</p>
{reason && (
<p className="text-sm text-zinc-300 break-words leading-relaxed">
diff --git a/frontend/src/components/MissionBoardView.tsx b/frontend/src/components/MissionBoardView.tsx
index 7b63d582..8230d21f 100644
--- a/frontend/src/components/MissionBoardView.tsx
+++ b/frontend/src/components/MissionBoardView.tsx
@@ -162,6 +162,8 @@ import {
untilText,
upsertMission,
upsertTask,
+ noticeFor,
+ type TaskNotice,
} from '../missions';
import { DEFAULT_CLASS, ENGINE_CANT_SANDBOX, TIER_HINTS, classLabel, engineCantSandboxText, showsTier, tierLabel, toClass, validClass } from '../flightSchool';
@@ -1945,7 +1947,7 @@ export const TaskDetailBody: React.FC<{
tasksById?: Record<string, Task>;
now?: number;
busy?: boolean;
- notice?: { text: string; error: boolean } | null;
+ notice?: TaskNotice | null;
onAction: (a: TaskAction, reason?: string) => void;
onApproveCheck: (c: Check) => void;
onOpenChat?: (t: Task, place?: ChatPlace | null) => void;
@@ -2013,6 +2015,7 @@ export const TaskDetailBody: React.FC<{
onOpenAuditCard,
}) => {
const t = detail.task;
+ const shownNotice = noticeFor(notice, t.state);
const limitHit = outOfBudget(t);
const flags = openFlags(t);
const others = t.needs_you.filter((n) => !OWN_SECTION.has(n.kind));
@@ -2082,7 +2085,7 @@ export const TaskDetailBody: React.FC<{
{((t.state === 'blocked' && !limitHit) || t.state === 'failed') && (
<p className="px-3 py-2 rounded-lg border border-rose-500/30 bg-rose-500/10 text-xs text-rose-200">{cardStatus(t, names, now)}</p>
)}
- {notice && <Notice text={notice.text} error={notice.error} />}
+ {shownNotice && <Notice text={shownNotice.text} error={shownNotice.error} />}
{held && <HeldBox task={t} busy={busy} now={now} onRun={onRunHeld} />}
{actions.length > 0 && !asking && (
<div className="flex flex-wrap gap-2" data-actions>
@@ -2984,7 +2987,7 @@ export const MissionBoardPage: React.FC<{
const [openId, setOpenId] = useState<string | null>(null);
const [detail, setDetail] = useState<TaskDetail | null>(null);
const [detailError, setDetailError] = useState<string | null>(null);
- const [detailNotice, setDetailNotice] = useState<{ text: string; error: boolean } | null>(null);
+ const [detailNotice, setDetailNotice] = useState<TaskNotice | null>(null);
const [failures, setFailures] = useState<TaskFailure[]>([]);
const [changes, setChanges] = useState<WorkflowChange[]>([]);
const [busy, setBusy] = useState(false);
@@ -3376,7 +3379,13 @@ export const MissionBoardPage: React.FC<{
};
/** One person action on the open task: keyed, one at a time, 401 asks for the token, 409 shows what it is now. */
- const personAction = async (what: string, run: (taskId: string, key: string) => Promise<string>, errorText: (e: unknown) => string, key?: string) => {
+ const personAction = async (
+ what: string,
+ run: (taskId: string, key: string) => Promise<string>,
+ errorText: (e: unknown) => string,
+ key?: string,
+ pending = false,
+ ) => {
if (!openId || inFlight.current) return;
const taskId = openId;
inFlight.current = true;
@@ -3386,7 +3395,7 @@ export const MissionBoardPage: React.FC<{
const text = await run(taskId, key ?? keyFor(what));
pendingKey.current = null;
if (!alive.current) return;
- setDetailNotice({ text, error: false });
+ setDetailNotice({ text, error: false, pending });
playSfx('click');
await afterChange([], taskId);
load();
@@ -3414,6 +3423,7 @@ export const MissionBoardPage: React.FC<{
},
restoreErrorText,
runKeys.current[hold],
+ true,
);
};
const retryAutofix = (failureId?: string) =>
@@ -3424,6 +3434,8 @@ export const MissionBoardPage: React.FC<{
return 'AutoFix retries it now.';
},
autofixErrorText,
+ undefined,
+ true,
);
const skipAutofix = (a: AutofixAttempt) =>
personAction(
@@ -3433,6 +3445,8 @@ export const MissionBoardPage: React.FC<{
return 'AutoFix won’t retry it. It stays failed until you try again.';
},
autofixErrorText,
+ undefined,
+ true,
);
const resolveRisk = async (r: Risk, resolution: RiskResolution) => {
if (!openId || inFlight.current) return;
diff --git a/frontend/src/missions.ts b/frontend/src/missions.ts
index 438b9948..4b09eecd 100644
--- a/frontend/src/missions.ts
+++ b/frontend/src/missions.ts
@@ -468,6 +468,23 @@ export const COLUMNS: Array<{ key: Column; label: string; hint: string; empty: s
* carry the state before it, so a blocked task waits in Ready (it can't start) and a failed one in
* Review (its checks failed; you decide whether to retry). Cancelled tasks are hidden (null).
*/
+/** A line the task panel shows after the person acts. `pending` marks a line about work still to come
+ * ("AutoFix retries it now."), which is stale once the task has settled. */
+export interface TaskNotice {
+ text: string;
+ error: boolean;
+ pending?: boolean;
+}
+
+/** States after which a retry or a pickup is over: verified, waiting on a check, or cancelled. */
+const SETTLED: TaskState[] = ['verified', 'review', 'cancelled'];
+
+/** The notice to show for a task in `state`: a pending line goes once the task has settled. */
+export function noticeFor(notice: TaskNotice | null | undefined, state: TaskState): TaskNotice | null {
+ if (!notice) return null;
+ return notice.pending && !notice.error && SETTLED.includes(state) ? null : notice;
+}
+
export function columnOf(state: TaskState): Column | null {
switch (state) {
case 'backlog':
diff --git a/frontend/tests/botActions.test.mjs b/frontend/tests/botActions.test.mjs
index 9d92cbdf..7f5fbf3a 100644
--- a/frontend/tests/botActions.test.mjs
+++ b/frontend/tests/botActions.test.mjs
@@ -331,3 +331,24 @@ test('a card whose bot has since been deleted settles: no Undo, says so', () =>
assert.match(text(gone), /Hired Ledger\. It's since been deleted\./);
assert.deepEqual(buttons(gone), ['Show its instructions']);
});
+
+test('a follow-up card says when it runs in local words, never the raw ISO time', () => {
+ const at = '2026-11-06T14:00:00Z';
+ const meta = routineMeta({
+ action: 'follow_up_create',
+ summary: `scheduled a follow-up 'Follow-up: check the deploy', once at ${at}, in the thread "Deploy"`,
+ details: { ...routineMeta().details, schedule: { type: 'once', at }, schedule_text: `once at ${at}`, follow_up: true, next_run_at: at, delivers_to: 'the thread "Deploy"' },
+ });
+ const shown = text(ui.action(actionProps(meta)));
+ assert.doesNotMatch(shown, /2026-11-06T|14:00:00Z/, shown);
+ const d = new Date(at);
+ const day = d.toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric' });
+ const time = d.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' });
+ assert.match(shown, new RegExp(`once on ${day} at ${time}`), shown);
+ assert.equal(b.summaryText(b.parseBotActionMeta(meta)), `scheduled a follow-up 'Follow-up: check the deploy', once on ${day} at ${time}, in the thread "Deploy"`);
+ // A summary whose schedule we can't read stays as the server wrote it.
+ const odd = routineMeta({ summary: 'created routine x, sometimes', details: { ...routineMeta().details, schedule: null, schedule_text: 'sometimes' } });
+ assert.equal(b.summaryText(b.parseBotActionMeta(odd)), 'created routine x, sometimes');
+ // Other schedules keep the server's words.
+ assert.equal(b.summaryText(b.parseBotActionMeta(routineMeta())), "created routine 'Morning motivation', daily 07:00 Europe/Berlin, delivering to #general");
+});
diff --git a/frontend/tests/missionAutofix.test.mjs b/frontend/tests/missionAutofix.test.mjs
index 0ceede4b..4a3c163d 100644
--- a/frontend/tests/missionAutofix.test.mjs
+++ b/frontend/tests/missionAutofix.test.mjs
@@ -327,3 +327,18 @@ test('AutoFix settings parse safely from GET /api/settings', () => {
assert.deepEqual(m.parseAutofixSettings({ autofix: 'on', recovery_budget_pct: 140 }), { autofix: 'on', recovery_budget_pct: 100 });
assert.deepEqual(m.parseAutofixSettings({ autofix: 'suggest' }), { autofix: 'suggest', recovery_budget_pct: 25 });
});
+
+test('a line about a pending retry goes once the task is verified or otherwise settled', () => {
+ const retrying = { text: 'AutoFix retries it now.', error: false, pending: true };
+ // While the retry is still to come, the line stays.
+ for (const state of ['failed', 'ready', 'working']) {
+ assert.match(ui.detail(detailProps(task({ state }), { notice: retrying })), /AutoFix retries it now/, state);
+ }
+ // Verified, waiting on a check, or cancelled: the retry is over, so the line is stale.
+ for (const state of ['verified', 'review', 'cancelled']) {
+ assert.doesNotMatch(ui.detail(detailProps(task({ state, finished_at: '2026-10-27T11:58:00Z' }), { notice: retrying })), /AutoFix retries it now/, state);
+ }
+ // Errors and lines that report something already done stay, whatever the state.
+ assert.match(ui.detail(detailProps(task({ state: 'verified' }), { notice: { text: 'Could not retry it.', error: true } })), /Could not retry it/);
+ assert.match(ui.detail(detailProps(task({ state: 'verified' }), { notice: { text: 'Marked still valid.', error: false } })), /Marked still valid/);
+});