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.

31e goal-board-text-fits: drafting line, draft card span, "Waiting on you" (#914)

Oleksandr Ivanchenko3bc185f65946
diff --git a/frontend/src/components/GoalsStrip.tsx b/frontend/src/components/GoalsStrip.tsx
index 6c85f6f7..019263cd 100644
--- a/frontend/src/components/GoalsStrip.tsx
+++ b/frontend/src/components/GoalsStrip.tsx
@@ -368,6 +368,15 @@ export const DecisionCard: React.FC<{
);
};
+/**
+ * The person's goal sentence as quoted in the drafting line: one closing `.`, `!`, `?` or `…` comes off, so the line
+ * never reads `…HTTP 200.”.`; longer than 80 characters, it is cut to 79 and ends in `…`.
+ */
+export const quotedGoalText = (text: string): string => {
+ const t = text.trim().replace(/[.!?…]$/, '');
+ return t.length > 80 ? `${t.slice(0, 79)}…` : t;
+};
+
/** What a goal says after the person chose Not now: not a request, so no amber and no counting (D1, D3). */
export const declinedText = (at: string | null, now: number): string => {
const when = atClock(at, now);
@@ -412,7 +421,7 @@ export const GoalRow: React.FC<{
return (
<li
aria-labelledby={`${id}-t`}
- className={`relative min-w-0 rounded-lg border bg-zinc-900/40 px-2.5 py-1.5 ${wide ? 'sm:col-span-2 xl:col-span-3 space-y-1.5' : 'flex items-center gap-2 hover:bg-zinc-900/70'} ${CARD_EDGE[g.status] ?? 'border-zinc-800'} ${hideOnPhone ? 'max-sm:hidden' : ''}`}
+ className={`relative min-w-0 rounded-lg border bg-zinc-900/40 px-2.5 py-1.5 ${wide ? 'sm:col-span-2 xl:col-span-3 space-y-1.5' : `flex items-center gap-2 hover:bg-zinc-900/70${draft ? ' sm:col-span-2 xl:col-span-3' : ''}`} ${CARD_EDGE[g.status] ?? 'border-zinc-800'} ${hideOnPhone ? 'max-sm:hidden' : ''}`}
data-goal={g.id}
data-status={g.status}
>
@@ -424,7 +433,7 @@ export const GoalRow: React.FC<{
id={`${id}-t`}
title={g.title}
onClick={() => onOpen(g)}
- className={`min-w-0 flex-1 truncate text-left text-xs font-medium text-zinc-100 rounded ${wide ? 'hover:underline' : "after:absolute after:inset-0 after:content-['']"} ${focusRing}`}
+ className={`min-w-0 flex-1 ${draft && !wide ? 'max-sm:whitespace-normal max-sm:line-clamp-2 max-sm:break-words sm:truncate' : 'truncate'} text-left text-xs font-medium text-zinc-100 rounded ${wide ? 'hover:underline' : "after:absolute after:inset-0 after:content-['']"} ${focusRing}`}
data-goal-open
>
{g.title}
@@ -440,7 +449,7 @@ export const GoalRow: React.FC<{
</div>
)}
{wide ? null : draft ? (
- <p className="mt-0.5 truncate text-[11px] text-zinc-400" data-goal-line="draft">
+ <p className={`mt-0.5 text-[11px] text-zinc-400 ${wrap}`} data-goal-line="draft">
{proposer ? `${proposer} proposed this.` : 'A bot proposed this.'} Nothing runs until you approve it.
</p>
) : declined ? (
@@ -1901,7 +1910,7 @@ export const GoalsStrip: React.FC<{
const draftingLine = drafting && (
<p role="status" className={`flex min-w-0 items-center gap-1.5 text-[11px] text-sky-200 ${wrap}`} data-goals-drafting>
<Loader2 size={11} className={`shrink-0 ${spin}`} aria-hidden="true" />
- {drafting.bot} is drafting checks for “{drafting.text.length > 80 ? `${drafting.text.slice(0, 79)}…` : drafting.text}”. The draft shows here.
+ {drafting.bot} is drafting checks for “{quotedGoalText(drafting.text)}”. The draft shows here.
</p>
);
diff --git a/frontend/src/components/MissionBoardView.tsx b/frontend/src/components/MissionBoardView.tsx
index 74d63dbd..70edcaf1 100644
--- a/frontend/src/components/MissionBoardView.tsx
+++ b/frontend/src/components/MissionBoardView.tsx
@@ -432,7 +432,7 @@ export const InsightsStrip: React.FC<{
hint: 'A bot said done, then the check failed (last 7 days)',
tone: insights.false_success_7d > 0 ? 'rose' : undefined,
},
- { label: 'Board tasks waiting on you', value: String(needsNow), hint: 'Board tasks waiting on a question, approval or step from you. Your Inbox can hold more.', tone: needsNow > 0 ? 'amber' : undefined },
+ { label: 'Waiting on you', value: String(needsNow), hint: 'Board tasks waiting on a question, approval or step from you. Your Inbox can hold more.', tone: needsNow > 0 ? 'amber' : undefined },
typeof blockedMin === 'number'
? {
label: 'Blocked this week',
diff --git a/frontend/src/missions.ts b/frontend/src/missions.ts
index 773c0a78..6e64f2e2 100644
--- a/frontend/src/missions.ts
+++ b/frontend/src/missions.ts
@@ -558,7 +558,7 @@ export function defaultColumn(tasks: Task[]): Column {
}
/**
- * The "Board tasks waiting on you" count: the cards the Needs you column holds across all work, so the tile and the
+ * The "Waiting on you" tile's count: the cards the Needs you column holds across all work, so the tile and the
* column never disagree. The server's `needs_you_now` counts the same tasks.
*/
export function needsYouCount(tasks: Task[]): number {
diff --git a/frontend/tests/goalBoardTextFits.test.mjs b/frontend/tests/goalBoardTextFits.test.mjs
new file mode 100644
index 00000000..b752e771
--- /dev/null
+++ b/frontend/tests/goalBoardTextFits.test.mjs
@@ -0,0 +1,79 @@
+// 31e goal-board-text-fits (Mira's 0.9.31 UX pass, "Also seen" d, e, f): the drafting line never reads
+// "…HTTP 200.”.", a bot's draft goal card spans the strip so its two lines stop cutting off at 1440, and the
+// Mission board tile says "Waiting on you".
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { readFileSync } from 'node:fs';
+import { loadBundled } from './bundle.mjs';
+
+globalThis.localStorage ??= { getItem: () => null, setItem: () => {}, removeItem: () => {} };
+
+const b = await loadBundled(`
+ import React from 'react';
+ import { renderToStaticMarkup } from 'react-dom/server.browser';
+ import { GoalRow } from './src/components/GoalsStrip';
+ import { InsightsStrip } from './src/components/MissionBoardView';
+ export { quotedGoalText } from './src/components/GoalsStrip';
+ export { parseGoal } from './src/goals';
+ export const rowHtml = (p) => renderToStaticMarkup(React.createElement(GoalRow, { onOpen() {}, ...p }));
+ export const insightsHtml = (p) => renderToStaticMarkup(React.createElement(InsightsStrip, p));
+`);
+
+const NOW = Date.parse('2026-11-20T08:00:00Z');
+const ago = (m) => new Date(NOW - m * 60_000).toISOString();
+const names = { k_mia: 'Mia' };
+const goal = (over = {}) =>
+ b.parseGoal({
+ id: 'g1', space_id: 's1', title: 'Check kwant.si answers with HTTP 200', description: '', kwant_id: 'k_mia', status: 'met', mode: 'suggest',
+ interval_minutes: 60, created_by: 'person', last_checked_at: ago(10), next_check_at: ago(-50), created_at: ago(600), updated_at: ago(10),
+ checks: [{ id: 'c1', label: 'Site answers', kind: 'http', spec: { url: 'https://kwant.si', expect_status: 200 }, required: true, freshness_minutes: null, latest: { status: 'passed', verdict: 'met', excerpt: 'HTTP 200', observed_at: ago(10) } }],
+ open_mission: null, ...over,
+ });
+const liClass = (html) => html.match(/^<li[^>]*class="([^"]*)"/)?.[1] ?? '';
+
+test('the drafting line quotes the goal without its closing full stop, question or exclamation mark', () => {
+ assert.equal(b.quotedGoalText('Check kwant.si answers with HTTP 200.'), 'Check kwant.si answers with HTTP 200');
+ assert.equal(b.quotedGoalText(' Is it up? '), 'Is it up');
+ assert.equal(b.quotedGoalText('Keep it up!'), 'Keep it up');
+ assert.equal(b.quotedGoalText('Wait for it…'), 'Wait for it');
+ assert.equal(b.quotedGoalText('Backups run nightly'), 'Backups run nightly', 'no punctuation: unchanged');
+ assert.equal(b.quotedGoalText('Version 0.9.33 ships'), 'Version 0.9.33 ships', 'dots inside the sentence stay');
+ assert.equal(b.quotedGoalText('Really?!'), 'Really?', 'only one mark comes off');
+ const long = `${'a'.repeat(90)}.`;
+ assert.equal(b.quotedGoalText(long), `${'a'.repeat(79)}…`, 'over 80 characters: cut to 79 and "…"');
+ assert.equal(b.quotedGoalText(`${'a'.repeat(80)}.`), 'a'.repeat(80), 'exactly 80 after the stop comes off: not cut');
+ const src = readFileSync(new URL('../src/components/GoalsStrip.tsx', import.meta.url), 'utf8');
+ assert.match(src, /is drafting checks for “\{quotedGoalText\(drafting\.text\)\}”\. The draft shows here\./, 'the line uses the helper');
+});
+
+test('a bot’s draft card spans the strip and its "proposed this" line wraps; a met card keeps its cell', () => {
+ const draft = b.rowHtml({ goal: goal({ status: 'draft', created_by: 'k_mia', last_checked_at: null }), names, now: NOW });
+ const cls = liClass(draft);
+ assert.match(cls, /(^|\s)sm:col-span-2(\s|$)/);
+ assert.match(cls, /(^|\s)xl:col-span-3(\s|$)/);
+ assert.match(cls, /(^|\s)flex(\s|$)/, 'still the compact row layout, with Review on the right');
+ const line = draft.match(/<p class="([^"]*)" data-goal-line="draft">([^<]*)</);
+ assert.ok(line, draft);
+ assert.doesNotMatch(line[1], /truncate/, 'the "proposed this" line is not cut off');
+ assert.match(line[1], /break-words/);
+ assert.equal(line[2], 'Mia proposed this. Nothing runs until you approve it.');
+ assert.match(draft, /title="Check kwant.si answers with HTTP 200"/, 'the title keeps its tooltip');
+ const titleCls = draft.match(/<button[^>]*class="([^"]*)"[^>]*data-goal-open/)?.[1] ?? '';
+ assert.match(titleCls, /max-sm:line-clamp-2/, 'on a phone (no hover, no tooltip) the draft title wraps to 2 lines');
+ assert.match(titleCls, /(^|\s)sm:truncate(\s|$)/, 'from sm up it stays one line');
+ assert.doesNotMatch(titleCls, /(^|\s)truncate(\s|$)/);
+
+ const metHtml = b.rowHtml({ goal: goal(), names, now: NOW });
+ const met = liClass(metHtml);
+ assert.doesNotMatch(met, /col-span/, 'a met goal stays in one cell');
+ assert.doesNotMatch(metHtml, /line-clamp-2/, 'a met title stays one line');
+ const failing = liClass(b.rowHtml({ goal: goal({ status: 'not_met' }), names, now: NOW }));
+ assert.doesNotMatch(failing, /col-span/, 'a failing goal stays in one cell');
+});
+
+test('the Mission board tile reads "Waiting on you"; its hint still says these are board tasks', () => {
+ const html = b.insightsHtml({ insights: { verified_7d: 0, false_success_7d: 0, needs_you_now: 2, blocked_now: 0, blocked_minutes_7d: 0, interventions_7d: 0, tokens_7d: 0, tokens_per_verified_7d: null }, needsYou: 2 });
+ assert.match(html, />Waiting on you<\/dt>/);
+ assert.doesNotMatch(html, /Board tasks waiting on you/);
+ assert.match(html, /Board tasks waiting on a question, approval or step from you\. Your Inbox can hold more\./);
+});
diff --git a/frontend/tests/missionAutofix.test.mjs b/frontend/tests/missionAutofix.test.mjs
index 14adc0ef..42b3c478 100644
--- a/frontend/tests/missionAutofix.test.mjs
+++ b/frontend/tests/missionAutofix.test.mjs
@@ -146,7 +146,7 @@ test('the failure panel says each fact once, with the older server text and the
assert.equal(m.skippedWithFixText(attempt({ status: 'failed' })), undefined, 'only a skipped attempt is folded');
});
-test('"Board tasks waiting on you" counts the same cards as the Needs you column', () => {
+test('"Waiting on you" counts the same cards as the Needs you column', () => {
const tasks = [
task({ id: 'q', state: 'needs_you' }),
failed({ id: 'f', needs_you: [{ kind: 'fix_needed', id: 'fl1', text: 'Usage limit reached.' }] }),
@@ -165,8 +165,8 @@ test('"Board tasks waiting on you" counts the same cards as the Needs you column
// Eval 10: the server said 0 while 9 failed tasks waited on a fix; the tile follows the column.
const nine = Array.from({ length: 9 }, (_, i) => failed({ id: `f${i}`, needs_you: [{ kind: 'fix_needed', id: `fl${i}`, text: 'Sign in again.' }] }));
const ins = { verified_7d: 1, false_success_7d: 7, needs_you_now: 0, blocked_now: 0, tokens_7d: 0, tokens_per_verified_7d: null };
- assert.match(ui.insights({ insights: ins, needsYou: m.needsYouCount(nine) }), /Board tasks waiting on you<\/dt><dd class="[^"]*text-amber-300[^"]*">9</);
- assert.match(ui.insights({ insights: ins }), /Board tasks waiting on you<\/dt><dd[^>]*>0</, 'without the board it falls back to the server count');
+ assert.match(ui.insights({ insights: ins, needsYou: m.needsYouCount(nine) }), />Waiting on you<\/dt><dd class="[^"]*text-amber-300[^"]*">9</);
+ assert.match(ui.insights({ insights: ins }), />Waiting on you<\/dt><dd[^>]*>0</, 'without the board it falls back to the server count');
});
test('AutoFix tries come from the server count, not from counting failures in the browser', () => {
diff --git a/frontend/tests/mobileBoard0613.test.mjs b/frontend/tests/mobileBoard0613.test.mjs
index 0e69120c..6d7a5505 100644
--- a/frontend/tests/mobileBoard0613.test.mjs
+++ b/frontend/tests/mobileBoard0613.test.mjs
@@ -137,9 +137,9 @@ test('tapping "This week" opens the tiles and tapping again folds them', async (
host.remove();
});
-test('the tile reads "Board tasks waiting on you", not the Inbox-like "Needs you now"', () => {
+test('the tile reads "Waiting on you", not the Inbox-like "Needs you now"', () => {
const html = ui.insights({ insights: insightsData, needsYou: 2 });
- assert.match(html, /Board tasks waiting on you<\/dt>/);
+ assert.match(html, />Waiting on you<\/dt>/);
assert.doesNotMatch(html, /Needs you now/);
});