) => {
+ if (row.longOpen) return `Open for ${row.ageDays} days`;
+ if (row.ageDays === 0) return 'Asked today';
+ return row.ageDays === 1 ? 'Asked 1 day ago' : `Asked ${row.ageDays} days ago`;
+};
+
+function Answers({ answers }: { answers: AnswerRow[] }) {
+ if (answers.length === 0) return No answers yet.
;
+ return (
+
+ {answers.map((a) => (
+ -
+ {`${a.who}, ${a.kind.toLowerCase()}: `}
+ {a.withheld ?? [a.choice, a.text && `"${a.text}"`].filter(Boolean).join(' ')}
+ {` (${date(a.at)})`}
+
+ ))}
+
+ );
+}
+
+function Row({ row }: { row: DeskRow }) {
+ const phone = useScreenSizeContext() === ScreenSize.Mobile;
+ // Phones list titles; a tap opens one. Wide screens show every row open.
+ const [open, setOpen] = useState(!phone);
+ if (row.kind === 'hidden') {
+ return (
+
+
+ {`A question here is hidden by ${row.hidden.by}, ${date(row.hidden.at)}, ${
+ row.hidden.reason
+ }.`}
+
+
+ );
+ }
+ const noteId = `note-${row.forkId}`;
+ return (
+
+
+ {phone ? (
+
+ ) : (
+ row.title
+ )}
+
+ {age(row)}
+ {open && (
+ <>
+ {row.body}
+
+ {row.options.map((o) => (
+ -
+ {`${o.id} ${o.text}`}
+ {o.recommended && ' (recommended)'}
+
+ ))}
+
+ {row.depends.map((d) => (
+
+ {`Waits on: "${d.text}"${d.status ? ` (${d.status})` : ''}`}
+
+ ))}
+ Your note
+
+
+ {SIGN_IN_NOTE}
+
+
+ >
+ )}
+
+ );
+}
+
+function Status({ desk, label }: { desk: Desk; label: string }) {
+ if (!desk.published) return {`${label}'s questions have not been published yet.`}
;
+ return (
+
+ {desk.counts.open === 0
+ ? `Nothing is waiting on you from ${label}. `
+ : `${desk.counts.open} open. `}
+ {`Synced ${desk.syncedAt && date(desk.syncedAt)}.`}
+ {desk.stale && ' This may be out of date.'}
+
+ );
+}
+
+type DeskViewProps = {
+ /** The Mind's key, as the navigator groups it. */
+ mind: string;
+ label: string;
+ projection?: DeskProjection;
+ now: number;
+};
+
+/** One Mind's desk, read-only: a stream of rows, the recorded rulings, and the booth Persona. */
+export function DeskView({ mind, label, projection, now }: DeskViewProps) {
+ const desk = buildDesk(projection, now);
+ const mood = deskMood(desk.counts.open, desk.counts.answered);
+ return (
+
+
+
+
+ {desk.open.map((row) => (
+
+ ))}
+
+ {/* Only Minds with art in the catalogue get a booth; none gets another Mind's face. */}
+ {desk.published && MINDS.includes(mind) && (
+
+
undefined} />
+
+ {mood.line}
+
+
+ )}
+
+ {desk.recorded.length > 0 && (
+ <>
+ Recorded as rulings
+
+ {desk.recorded.map((r) => (
+ -
+ {`${r.title} (${r.rulingId})`}
+
+ ))}
+
+ >
+ )}
+
+ );
+}
diff --git a/src/app/features/desk/buildDesk.test.ts b/src/app/features/desk/buildDesk.test.ts
new file mode 100644
index 00000000..29d2df40
--- /dev/null
+++ b/src/app/features/desk/buildDesk.test.ts
@@ -0,0 +1,127 @@
+import { describe, expect, it } from 'vitest';
+import { LONG_OPEN_DAYS, buildDesk, countOpen } from './buildDesk';
+import { NOW, STATES } from './fixtures';
+
+const questions = (d: ReturnType) =>
+ d.open.flatMap((r) => (r.kind === 'question' ? [r] : []));
+
+describe('buildDesk', () => {
+ it('says "not published" for a projection that never arrived, never "no questions"', () => {
+ expect(buildDesk(undefined, NOW).published).toBe(false);
+ expect(buildDesk(STATES.unpublished, NOW)).toMatchObject({
+ published: false,
+ open: [],
+ counts: { open: 0, answered: 0 },
+ });
+ });
+ it('is published and empty, with its sync time, when nothing is open', () => {
+ const d = buildDesk(STATES.empty, NOW);
+ expect(d).toMatchObject({ published: true, open: [], counts: { open: 0 } });
+ expect(d.syncedAt).toBeDefined();
+ });
+ it('is stale only past thirty minutes since sync', () => {
+ expect(buildDesk(STATES.noAnswers, NOW).stale).toBe(false);
+ expect(buildDesk(STATES.stale, NOW).stale).toBe(true);
+ });
+ it('shows no answers as an empty list on an open row', () => {
+ expect(questions(buildDesk(STATES.noAnswers, NOW))[0].answers).toEqual([]);
+ });
+ it('flags a question open past fourteen days and keeps it listed', () => {
+ const [row] = questions(buildDesk(STATES.longOpen, NOW));
+ expect(row).toMatchObject({ ageDays: 21, longOpen: true });
+ expect(LONG_OPEN_DAYS).toBe(14);
+ expect(questions(buildDesk(STATES.noAnswers, NOW))[0].longOpen).toBe(false);
+ });
+ it('puts the long-open line past fourteen days exactly: day 14 is not long, day 15 is', () => {
+ const at = (days: number) => {
+ const p = structuredClone(STATES.noAnswers);
+ (p.questions[0] as { askedAt: string }).askedAt = new Date(
+ NOW - days * 86400000
+ ).toISOString();
+ return questions(buildDesk(p, NOW))[0].longOpen;
+ };
+ expect([at(14), at(15)]).toEqual([false, true]);
+ });
+ it('resolves the recommendation to its option, marks only that option, and never preselects', () => {
+ const [row] = questions(buildDesk(STATES.noAnswers, NOW));
+ expect(row.recommended).toBe('Second way');
+ expect(row.options.filter((o) => o.recommended).map((o) => o.id)).toEqual(['B']);
+ });
+ it('leaves the recommendation unresolved when it names no option', () => {
+ const p = structuredClone(STATES.noAnswers);
+ (p.questions[0] as { recommendation?: string }).recommendation = 'Z';
+ const [row] = questions(buildDesk(p, NOW));
+ expect(row.recommended).toBeUndefined();
+ expect(row.options.some((o) => o.recommended)).toBe(false);
+ });
+ it('carries the status of a cited dependency, and none for one that cites no question', () => {
+ const rows = questions(buildDesk(STATES.blocked, NOW));
+ expect(rows.find((r) => r.forkId.endsWith('second'))?.depends).toEqual([
+ { text: 'Needs the first one settled', status: 'open' },
+ ]);
+ expect(rows.find((r) => r.forkId.endsWith('first'))?.depends).toEqual([]);
+ });
+ it('lists a settled question under recorded rulings with its ruling id, not as open; drops a closed one', () => {
+ const d = buildDesk(STATES.settled, NOW);
+ expect(d.recorded).toEqual([
+ { forkId: 'c:question:done', title: 'Question done', rulingId: 'ruling:done-1' },
+ ]);
+ expect(d.open.map((r) => r.forkId)).toEqual(['c:question:live']);
+ });
+ it('orders open rows oldest first', () => {
+ const p = structuredClone(STATES.blocked);
+ (p.questions[0] as { askedAt: string }).askedAt = new Date(NOW).toISOString();
+ expect(buildDesk(p, NOW).open.map((r) => r.forkId)).toEqual([
+ 'c:question:second',
+ 'c:question:first',
+ ]);
+ });
+ it('folds earlier answers by one account under its latest and shows choice as option text', () => {
+ const [row] = questions(buildDesk(STATES.answered, NOW));
+ expect(row.answers).toHaveLength(2);
+ const first = row.answers.find((a) => a.recordId === 'plain.a2');
+ expect(first).toMatchObject({ choice: 'Third way', text: 'On reflection, third.' });
+ expect(row.answers.some((a) => a.recordId === 'plain.a1')).toBe(false);
+ });
+ it('lists answers oldest first and tallies nothing', () => {
+ const [row] = questions(buildDesk(STATES.answered, NOW));
+ const times = row.answers.map((a) => a.at);
+ expect([...times].sort()).toEqual(times);
+ expect(Object.keys(buildDesk(STATES.answered, NOW).counts).sort()).toEqual([
+ 'answered',
+ 'open',
+ ]);
+ });
+ it('withholds a hidden answer and a hidden question, naming who hid them', () => {
+ const d = buildDesk(STATES.hidden, NOW);
+ expect(d.open.find((r) => r.kind === 'hidden')).toMatchObject({
+ hidden: { by: 'Kiko', reason: 'PrivateMatter' },
+ });
+ const [row] = questions(d);
+ expect(row.answers[0]).toMatchObject({ choice: undefined, text: undefined });
+ expect(row.answers[0].withheld).toMatch(/^Hidden by Kiko, 2026-11-\d\d, Spam$/);
+ });
+ it('does not count a hidden question as open', () => {
+ expect(buildDesk(STATES.hidden, NOW).counts.open).toBe(1);
+ expect(countOpen(STATES.hidden)).toBe(1);
+ });
+ it('shows an erased author as "erased account" with no name or content, keeping kind and time', () => {
+ const [row] = questions(buildDesk(STATES.erased, NOW));
+ expect(row.answers[0]).toMatchObject({
+ who: 'erased account',
+ kind: 'Member',
+ choice: undefined,
+ text: undefined,
+ });
+ expect(row.answers[0].withheld).toBeDefined();
+ expect(row.answers[0].at).toBeDefined();
+ });
+ it('counts answered only for the viewer, so a signed-out desk has none', () => {
+ expect(buildDesk(STATES.answered, NOW).counts.answered).toBe(0);
+ expect(buildDesk(STATES.answered, NOW, 'acct-1').counts.answered).toBe(1);
+ expect(buildDesk(STATES.answered, NOW, 'acct-9').counts.answered).toBe(0);
+ });
+ it('does not count the viewer as answered when their only answer was hidden', () => {
+ expect(buildDesk(STATES.hidden, NOW, 'acct-1').counts.answered).toBe(0);
+ });
+});
diff --git a/src/app/features/desk/buildDesk.ts b/src/app/features/desk/buildDesk.ts
new file mode 100644
index 00000000..6b9cc103
--- /dev/null
+++ b/src/app/features/desk/buildDesk.ts
@@ -0,0 +1,153 @@
+import {
+ Answer,
+ DeskProjection,
+ Hidden,
+ Question,
+ QuestionStatus,
+ isHiddenQuestion,
+} from './feedback';
+
+/** Past two heartbeats the projection may be out of date (provisional, doc section 8). */
+export const STALE_MS = 30 * 60 * 1000;
+/** Past this a question shows how long it has waited; it is never demoted or hidden (provisional). */
+export const LONG_OPEN_DAYS = 14;
+const DAY_MS = 24 * 60 * 60 * 1000;
+
+export type AnswerRow = {
+ recordId: string;
+ /** Never a handle: the name at answer time, or the words for an account that has none. */
+ who: string;
+ kind: Answer['kind'];
+ /** The option's text for a choice. */
+ choice?: string;
+ text?: string;
+ at: string;
+ /** Why the content is not shown: hidden by the Mind, or the author's account was erased. */
+ withheld?: string;
+};
+
+export type DeskRow =
+ | { kind: 'hidden'; forkId: string; hidden: Hidden }
+ | {
+ kind: 'question';
+ forkId: string;
+ title: string;
+ body: string;
+ options: { id: string; text: string; recommended: boolean }[];
+ /** The recommendation resolved to its option's text; absent if it names no option. */
+ recommended?: string;
+ depends: { text: string; status?: QuestionStatus['state'] }[];
+ ageDays: number;
+ longOpen: boolean;
+ answers: AnswerRow[];
+ };
+
+export type Desk = {
+ /** False until the projection first arrives: "not published yet", never "no questions". */
+ published: boolean;
+ syncedAt?: string;
+ stale: boolean;
+ /** Oldest first. */
+ open: DeskRow[];
+ /** Settled questions with the Mind's ruling id. Closed (withdrawn) questions are not listed. */
+ recorded: { forkId: string; title: string; rulingId: string }[];
+ /** Derived for the booth mood. The page tallies nothing about answers. */
+ counts: { open: number; answered: number };
+};
+
+const ageDays = (iso: string, now: number) =>
+ Math.max(0, Math.floor((now - Date.parse(iso)) / DAY_MS));
+
+const answerRow = (a: Answer, q: Question): AnswerRow => {
+ let withheld: string | undefined;
+ if (a.hidden)
+ withheld = `Hidden by ${a.hidden.by}, ${a.hidden.at.slice(0, 10)}, ${a.hidden.reason}`;
+ else if (a.erased) withheld = 'Author erased their account';
+ const choice = withheld ? undefined : a.answer?.choice;
+ return {
+ recordId: a.recordId,
+ who: a.erased ? 'erased account' : a.displayName ?? 'an account',
+ kind: a.kind,
+ choice:
+ choice === undefined ? undefined : q.options.find((o) => o.id === choice)?.text ?? choice,
+ text: withheld ? undefined : a.answer?.text,
+ at: a.answered_at,
+ withheld,
+ };
+};
+
+/** Earlier answers by the same account fold under their latest; the page never counts them. */
+const standing = (answers: Answer[]): Answer[] => {
+ const latest = new Map();
+ answers.forEach((a) => {
+ const key = a.answerer ?? a.recordId;
+ const held = latest.get(key);
+ if (!held || held.answered_at <= a.answered_at) latest.set(key, a);
+ });
+ return [...latest.values()].sort((a, b) => a.answered_at.localeCompare(b.answered_at));
+};
+
+/** Open questions the page would list: the one rule the navigator's count and the desk share. */
+export const countOpen = (p?: DeskProjection): number =>
+ p?.questions.filter((q) => !isHiddenQuestion(q) && q.status.state === 'open').length ?? 0;
+
+export const buildDesk = (p: DeskProjection | undefined, now: number, viewerId?: string): Desk => {
+ if (!p?.syncedAt) {
+ return {
+ published: false,
+ stale: false,
+ open: [],
+ recorded: [],
+ counts: { open: 0, answered: 0 },
+ };
+ }
+ const known = new Map();
+ p.questions.forEach((q) => !isHiddenQuestion(q) && known.set(q.fork_id, q));
+
+ const open: DeskRow[] = [];
+ const recorded: Desk['recorded'] = [];
+ let answered = 0;
+ [...p.questions]
+ .sort((a, b) => {
+ const at = (q: typeof a) => (isHiddenQuestion(q) ? '' : q.askedAt);
+ return at(a).localeCompare(at(b));
+ })
+ .forEach((q) => {
+ if (isHiddenQuestion(q)) {
+ open.push({ kind: 'hidden', forkId: q.fork_id, hidden: q.hidden });
+ return;
+ }
+ if (q.status.state === 'answered') {
+ recorded.push({ forkId: q.fork_id, title: q.title, rulingId: q.status.rulingId });
+ return;
+ }
+ if (q.status.state !== 'open') return;
+ const mine = standing(p.answers.filter((a) => a.fork_id === q.fork_id));
+ if (viewerId && mine.some((a) => a.answerer === viewerId && !a.hidden)) answered += 1;
+ const days = ageDays(q.askedAt, now);
+ open.push({
+ kind: 'question',
+ forkId: q.fork_id,
+ title: q.title,
+ body: q.body,
+ options: q.options.map((o) => ({ ...o, recommended: o.id === q.recommendation })),
+ recommended: q.options.find((o) => o.id === q.recommendation)?.text,
+ depends: q.dependsOn.map((d) => ({
+ text: d.text,
+ status: d.questionId ? known.get(d.questionId)?.status.state : undefined,
+ })),
+ ageDays: days,
+ longOpen: days > LONG_OPEN_DAYS,
+ answers: mine.map((a) => answerRow(a, q)),
+ });
+ });
+
+ return {
+ published: true,
+ syncedAt: p.syncedAt,
+ stale: now - Date.parse(p.syncedAt) > STALE_MS,
+ open,
+ recorded,
+ counts: { open: countOpen(p), answered },
+ };
+};
diff --git a/src/app/features/desk/deskMood.test.ts b/src/app/features/desk/deskMood.test.ts
new file mode 100644
index 00000000..9c981640
--- /dev/null
+++ b/src/app/features/desk/deskMood.test.ts
@@ -0,0 +1,59 @@
+import { describe, expect, it } from 'vitest';
+import { MINDS, resolvePose } from '../../components/message/pose/poses';
+import { MOOD_POSE, deskMood } from './deskMood';
+
+describe('deskMood', () => {
+ it('is neutral with the desk clear when nothing is open', () => {
+ expect(deskMood(0, 0)).toEqual({
+ mood: 'neutral',
+ pose: 'neutral',
+ line: "Desk's clear. I'll wave when something lands.",
+ });
+ });
+ it('is triumph when every open fork is answered', () => {
+ expect(deskMood(3, 3).mood).toBe('triumph');
+ expect(deskMood(1, 1).mood).toBe('triumph');
+ });
+ it('is thinking when none is answered, and says whether it is one fork or several', () => {
+ expect(deskMood(1, 0)).toMatchObject({ mood: 'thinking', line: 'Just one fork on the desk.' });
+ expect(deskMood(4, 0)).toMatchObject({
+ mood: 'thinking',
+ line: '4 forks on the desk. No rush.',
+ });
+ });
+ it('is determined partway, counting what is left', () => {
+ expect(deskMood(5, 2)).toMatchObject({ mood: 'determined', line: '3 to go.' });
+ });
+ it('is happy when the pick is the recommendation', () => {
+ expect(deskMood(2, 0, { type: 'picked', choice: 'B', recommended: 'B' }).mood).toBe('happy');
+ });
+ it('is surprised, and asks for a line on why, when the pick differs', () => {
+ expect(deskMood(2, 0, { type: 'picked', choice: 'A', recommended: 'B' })).toMatchObject({
+ mood: 'surprised',
+ line: expect.stringContaining('A line in the note on why helps'),
+ });
+ });
+ it('is surprised, not happy, when there is no recommendation to match', () => {
+ expect(deskMood(2, 0, { type: 'picked', choice: 'A' }).mood).toBe('surprised');
+ });
+ it('is note when a pick is cleared, saying the note can carry the answer', () => {
+ expect(deskMood(2, 1, { type: 'cleared' })).toMatchObject({
+ mood: 'note',
+ line: expect.stringContaining('note can carry the answer on its own'),
+ });
+ });
+ it('is concerned when a send failed, even with everything answered', () => {
+ expect(deskMood(2, 2, { type: 'sendFailed' }).mood).toBe('concerned');
+ });
+ it('is surprised when a new fork arrives, even on a clear desk', () => {
+ expect(deskMood(0, 0, { type: 'newFork' })).toMatchObject({
+ mood: 'surprised',
+ line: 'New fork on the desk!',
+ });
+ });
+ it('maps every mood to a label every Mind in the catalogue can show', () => {
+ Object.values(MOOD_POSE).forEach((pose) =>
+ MINDS.forEach((mind) => expect(resolvePose(mind, pose)).toBe(pose))
+ );
+ });
+});
diff --git a/src/app/features/desk/deskMood.ts b/src/app/features/desk/deskMood.ts
new file mode 100644
index 00000000..75d9f23e
--- /dev/null
+++ b/src/app/features/desk/deskMood.ts
@@ -0,0 +1,75 @@
+/**
+ * The booth Persona's reactions, from the original Fork Desk's mood() and choose() rules. A pure function of
+ * what is on the desk and the last thing that happened; it is the desk's character, so each rule is tested.
+ */
+
+/** The original's nine moods. */
+export type Mood =
+ | 'idle'
+ | 'neutral'
+ | 'thinking'
+ | 'happy'
+ | 'surprised'
+ | 'note'
+ | 'determined'
+ | 'triumph'
+ | 'concerned';
+
+/** What last happened; `none` means nothing since the page opened or the last event wore off. */
+export type DeskEvent =
+ | { type: 'none' }
+ | { type: 'picked'; choice: string; recommended?: string }
+ | { type: 'cleared' }
+ | { type: 'sendFailed' }
+ | { type: 'newFork' };
+
+/**
+ * Each mood on the shared cast-art labels (neutral, happy, amused, thinking, annoyed, surprised) that every
+ * Mind has, so the booth never asks a Mind for art it lacks.
+ */
+export const MOOD_POSE: Record = {
+ idle: 'neutral',
+ neutral: 'neutral',
+ thinking: 'thinking',
+ happy: 'happy',
+ surprised: 'surprised',
+ note: 'thinking',
+ determined: 'thinking',
+ triumph: 'happy',
+ concerned: 'surprised',
+};
+
+export type DeskMood = { mood: Mood; pose: string; line: string };
+
+const say = (mood: Mood, line: string): DeskMood => ({ mood, pose: MOOD_POSE[mood], line });
+
+export const deskMood = (
+ open: number,
+ answered: number,
+ event: DeskEvent = { type: 'none' }
+): DeskMood => {
+ switch (event.type) {
+ case 'sendFailed':
+ return say('concerned', "That one didn't save. Give it another try in a moment?");
+ case 'newFork':
+ return say('surprised', 'New fork on the desk!');
+ case 'cleared':
+ return say('note', 'Pick cleared. Your note can carry the answer on its own.');
+ case 'picked':
+ return event.recommended !== undefined && event.choice === event.recommended
+ ? say('happy', "That's the one I'd have picked too.")
+ : say('surprised', 'Off-script. A line in the note on why helps the next brief.');
+ default:
+ break;
+ }
+ if (open === 0) return say('neutral', "Desk's clear. I'll wave when something lands.");
+ if (answered >= open)
+ return say('triumph', 'All answered! I will carry these back and admit them.');
+ if (answered === 0) {
+ return say(
+ 'thinking',
+ open === 1 ? 'Just one fork on the desk.' : `${open} forks on the desk. No rush.`
+ );
+ }
+ return say('determined', `${open - answered} to go.`);
+};
diff --git a/src/app/features/desk/feedback.ts b/src/app/features/desk/feedback.ts
new file mode 100644
index 00000000..ea3413ab
--- /dev/null
+++ b/src/app/features/desk/feedback.ts
@@ -0,0 +1,70 @@
+/**
+ * The desk's typed view of the feedback projections in docs/mind-feedback-pages.md (sections 5 and 12):
+ * org.gamecult.feedback.question.v0 and org.gamecult.feedback.answer.v0. Bifrost serves them; the page
+ * reads them and stores nothing. `answerer`, `kind` and `weightPermille` are the receiver's stamp from the
+ * verified session; the client never supplies them, so nothing here has a write shape.
+ */
+
+export type Hidden = { by: string; at: string; reason: string };
+
+/** The status is derived in the owning Mind; the page shows it and never writes it. */
+export type QuestionStatus =
+ | { state: 'open' }
+ | { state: 'answered'; rulingId: string }
+ | { state: 'closed' };
+
+export type Question = {
+ /** `:question: