feat(webui): hire form on the org inbox; a definite hire refusal keeps its code (#1873)

D4, readiness P0-1 and P1-2.

On an org Console, #/inbox now carries the hire, fire and change form
below "Answered today". It posts to the current organization's bus
through the same decision endpoint and verb (hire.start.console); the
organization field is read-only. Inputs carry focus keys, so a poll
repaint keeps the draft, focus and caret.

A hire start the bus definitely refused now keeps its own code. The
model route codes (model-provider-unavailable and its kin) get a next
step. Any other definite code is named, and the message never claims
that nothing was recorded. A lost or unreadable reply is still
outcome-unknown. The templates, confirmation and resolve steps are
unchanged.
This commit is contained in:
jason.woltje committed 2026-11-11 12:45:12 -06:00
1 parent 88a94ddd34
commit c3293ef4ef
6 files changed
+228 -17

No files matched your search

+19 -1
View File
@@ -42,6 +42,18 @@ const BUS_CODES = {
'decision-closed': 'decision-closed', 'decision-stale': 'decision-stale', 'invalid-choice': 'decision-stale',
'invalid-request': 'invalid-request', 'hire-owner-required':'hire-owner-required','right-required':'right-required','decision-expired':'decision-expired','hire-resolution-required':'hire-resolution-required',
};
// D4 (#1873, P1-2): a hire start the bus definitely refused keeps its own code. The broker can
// refuse before it records the decision (a model route the catalogue does not offer) or after
// (a check or apply that fails), so the message never claims that nothing was recorded. A lost
// or unreadable reply stays outcome-unknown. The model route codes get a next step; any other code is named.
const HIRE_START_REFUSALS = {
'model-provider-unavailable': [409, 'The model proxy does not offer this model, or its catalogue is not ready. Pick a model it offers, or ask the owner to check Settings > Model proxy. The hire was not applied.'],
'model-catalogue-unavailable': [503, 'The model catalogue could not be read, so this model could not be checked. Check Settings > Model proxy, then try again. The hire was not applied.'],
'model-harness-incompatible': [409, 'This model does not run on the chosen harness. Pick another model or harness. The hire was not applied.'],
'thinking-unsupported': [409, 'The chosen harness does not apply this thinking level. Clear Thinking or pick a level it applies. The hire was not applied.'],
};
const OPEN = ['outcome-unknown', 'invalid-response', 'response-too-large', 'outcome-unknown-revoked'];
const BUS_CODE = /^[a-z][a-z-]{0,63}$/;
const BODY_MAX = 4096;
const TOKEN = /^[a-f0-9]{64}$/;
const DIGEST = /^[a-f0-9]{64}$/;
@@ -136,7 +148,13 @@ export async function decisionHTTP(req, res, { path, decide, session, live, conf
if(step==='templates' && !Array.isArray(result?.templates))return refuse('confirmation-unavailable');
line(step==='start'?'hire=recorded':'templates=read');
return json(res,200,step==='start'?{id:result.id,op:result.op,choice:result.choice}:result);
} catch(err) {return refuse(busCode(err,step==='start'?'outcome-unknown':'confirmation-unavailable'));}
} catch(err) {
if(step!=='start' || !(err instanceof BusReadError) || BUS_CODES[err.code] || OPEN.includes(err.code) || !BUS_CODE.test(err.code ?? ''))
return refuse(busCode(err,step==='start'?'outcome-unknown':'confirmation-unavailable'));
const [status,message]=HIRE_START_REFUSALS[err.code] ?? [409, `The bus refused this hire (${err.code}). Refresh the inbox to see whether a hire decision is open before trying again.`];
line(`error=${err.code}`);
return json(res,status,{error:err.code,message});
}
}
if (step === 'confirmation') {
if (Object.keys(value).some(k=>!['choice','adjust'].includes(k)) || typeof value.choice !== 'string') return refuse('invalid-request');
+4
View File
@@ -60,6 +60,10 @@ table.s1-roles td,table.s1-roles th { overflow-wrap:normal; word-break:normal; }
table.s1-roles { min-width: 0; width: 100%; table-layout: fixed; }
table.s1-roles td, table.s1-roles th { overflow-wrap: anywhere; }
}
/* D4 (#1873): the hire form on the org-mode workspace inbox. */
html[data-organizations] #hire-start.ws-hire{margin-top:22px}
html[data-organizations] #hire-start.ws-hire h2{margin:0 0 4px;font-size:16px}
html[data-organizations] #hire-start.ws-hire select{min-height:40px;padding:6px 10px;border:1px solid var(--border);border-radius:6px;background:var(--surface);color:var(--text);font:inherit;max-width:100%}
/* A4: use the Console's controls for authority proposals and keep grant labels beside their checkboxes. */
#hire-start form,#hire-adjust{max-width:680px}
#hire-start form>label,#hire-adjust>label{display:grid;gap:5px;margin:12px 0;color:var(--text)}
+20 -14
View File
@@ -427,20 +427,26 @@
route:{harness:$('hire-route-harness').value.trim(),model:$('hire-route-model').value.trim(),...(thinking?{thinking}:{})}};
}
const HIRE_START_LABEL='Record and approve';
let hireDraft={op:'hire',level:'org'},hireTemplates=[],hireBusy=false,hireStatus='';
let hireDraft={op:'hire',level:'org'},hireTemplates=[],hireBusy=false,hireStatus='',hireCode='';
// D4 (#1873, P0-1): an org Console shows this form on the workspace inbox. Its posts go to the
// current organization's bus (display.js), so the organization is that one and is not editable.
const hireOrg=()=>window.MosaicOrg?.id ?? null;
function hireStartHtml() {
if(!canDecide)return '';
const d=hireDraft,off=hireBusy?' disabled':'';
const input=(key,label,extra='')=>`<label>${label} <input data-hire-field="${key}" value="${esc(d[key]??'')}" maxlength="${key==='reason'?500:200}" ${extra}${off}></label>`;
return `<section class="panel" id="hire-start"><h2>Hire, fire or change an agent</h2><form id="hire-start-form">
${input('business','Organization','required')}<button type="button" class="btn" data-hire-load${off}>Read role templates</button>
<label>Operation <select data-hire-field="op"${off}>${['hire','fire','change'].map(v=>`<option${d.op===v?' selected':''}>${v}</option>`).join('')}</select></label>
<label>Level <select data-hire-field="level"${off}>${['org','project','root'].map(v=>`<option${d.level===v?' selected':''}>${v}</option>`).join('')}</select></label>
const org=hireOrg(),d=hireDraft,off=hireBusy?' disabled':'';
const input=(key,label,extra='')=>`<label>${label} <input data-hire-field="${key}" data-focus-key="hire:${key}" value="${esc(d[key]??'')}" maxlength="${key==='reason'?500:200}" ${extra}${off}></label>`;
const select=(key,label,options)=>`<label>${label} <select data-hire-field="${key}" data-focus-key="hire:${key}"${off}>${options}</select></label>`;
const business=org?`<label>Organization <input value="${esc(org)}" readonly aria-describedby="hire-start-org"></label><p class="small muted" id="hire-start-org">This hire goes to ${txt(org)}'s bus. Switch organization to hire elsewhere.</p>`:input('business','Organization','required');
const status=`${txt(hireStatus)}${hireCode?` (<code>${txt(hireCode)}</code>)`:''}`;
return `<section class="${org?'ws-panel ws-hire':'panel'}" id="hire-start" aria-labelledby="hire-start-h"><h2 id="hire-start-h">Hire, fire or change an agent</h2><form id="hire-start-form">
${business}<button type="button" class="btn" data-hire-load data-focus-key="hire:load"${off}>Read role templates</button>
${select('op','Operation',['hire','fire','change'].map(v=>`<option${d.op===v?' selected':''}>${v}</option>`).join(''))}
${select('level','Level',['org','project','root'].map(v=>`<option${d.level===v?' selected':''}>${v}</option>`).join(''))}
${input('project','Project (project level only)')}${input('name','Agent name','required')}
<label>Role template <select data-hire-field="template"${off}><option value="">Choose a template</option>${hireTemplates.map(t=>`<option value="${esc(t.name)}"${d.template===t.name?' selected':''}>${txt(t.name)}</option>`).join('')}</select></label>
${select('template','Role template',`<option value="">Choose a template</option>${hireTemplates.map(t=>`<option value="${esc(t.name)}"${d.template===t.name?' selected':''}>${txt(t.name)}</option>`).join('')}`)}
${input('harness','Harness')}${input('model','Model')}${input('thinking','Thinking (optional)')}${input('reason','Reason','required')}
<p>Submitting raises and approves one decision. Flagged grants and credentials require the owner; root agents require the instance owner.</p>
<button type="submit" class="btn primary"${off}>${hireBusy?'Working…':HIRE_START_LABEL}</button><p id="hire-start-status" role="status">${txt(hireStatus)}</p></form></section>`;
<button type="submit" class="btn primary" data-focus-key="hire:submit"${off}>${hireBusy?'Working…':HIRE_START_LABEL}</button><p id="hire-start-status" role="status">${status}</p></form></section>`;
}
function paintHireStart() {const e=$('hire-start');if(e)e.outerHTML=hireStartHtml();}
document.addEventListener('input',e=>{const f=e.target.closest?.('[data-hire-field]');if(f)hireDraft[f.dataset.hireField]=f.value;});
@@ -448,15 +454,15 @@
async function hireSubmit(templatesOnly=false) {
if(hireBusy || out() || !canDecide)return;
const d={...hireDraft},template=hireTemplates.find(t=>t.name===d.template);
if(!templatesOnly && d.op!=='fire' && !template){hireStatus='Read and choose a role template first.';paintHireStart();return;}
if(!templatesOnly && d.op!=='fire' && !template){hireStatus='Read and choose a role template first.';hireCode='';paintHireStart();return;}
const thinking=d.thinking?.trim(),hire={op:d.op,level:d.level,name:d.name,reason:d.reason,...(d.level==='project'?{project:d.project}:{}),...(d.op==='fire'?{}:{role:{template:template?.name,sha256:template?.sha256},route:{harness:d.harness,model:d.model,...(thinking?{thinking}:{})}})};
hireBusy=true;hireStatus='';paintHireStart();
const {res,json}=await decidePost(`/api/decisions/hire/${templatesOnly?'templates':'start'}`,{business:d.business,...(templatesOnly?{}:{hire})});
hireBusy=true;hireStatus='';hireCode='';paintHireStart();
const {res,json}=await decidePost(`/api/decisions/hire/${templatesOnly?'templates':'start'}`,{business:hireOrg() ?? d.business,...(templatesOnly?{}:{hire})});
hireBusy=false;
if(res?.type==='opaqueredirect'){signOut();return;}
if(res?.ok && templatesOnly && Array.isArray(json?.templates)){hireTemplates=json.templates;hireStatus=hireTemplates.length?'Templates read.':'No templates available.';}
else if(res?.ok && !templatesOnly && json?.op==='resolved'){hireStatus=`Recorded decision ${json.id}.`;}
else hireStatus=decideRefusal(res,json,templatesOnly?'confirmation-unavailable':'outcome-unknown').message;
else {const r=decideRefusal(res,json,templatesOnly?'confirmation-unavailable':'outcome-unknown');hireStatus=r.message;hireCode=r.code;}
paintHireStart();
}
document.addEventListener('click',e=>{if(e.target.closest?.('[data-hire-load]'))hireSubmit(true);});
@@ -1524,7 +1530,7 @@
if (n === 0 && window.MosaicOrg) return window.MosaicWorkspace.home();
if (a === 'projects' && n === 1 && window.MosaicOrg) return window.MosaicWorkspace.projectsPage(q);
if (a === 'organization' && n === 1 && window.MosaicOrg) return window.MosaicWorkspace.dashboard();
if (a === 'inbox' && n === 1 && window.MosaicOrg) return window.MosaicWorkspace.inboxPage(q);
if (a === 'inbox' && n === 1 && window.MosaicOrg) return configRead.then(() => window.MosaicWorkspace.inboxPage(q, { hire: hireStartHtml() }));
if (a === 'tasks' && n === 1 && window.MosaicOrg) return window.MosaicTasksBoard.view();
if (a === 'inbox' && n === 1) return inboxView(get);
if (a === 'inbox' && n === 2) return SAFE.test(b) ? decisionView(get, b, current) : notFound(`${txt(b)} is not a decision id.`);
+4 -2
View File
@@ -663,7 +663,8 @@
}
// ---- inbox across organizations (sample 05) ----
async function inboxPage(q) {
// `opts.hire`: the hire, fire and change form bus.js builds for the current organization (D4, P0-1).
async function inboxPage(q, opts = {}) {
const org = listParam(q, 'org', id => ORG_ID.test(id));
const want = String(q?.get?.('d') || '');
let body, all;
@@ -722,7 +723,8 @@
${unread}
<div class="ws-ibx-grid${insp ? ' with-insp' : ''}"><div class="ws-ibx-list">${table}
${secH('Answered today', 'kept for 24 hours, then in the trail')}
<p class="ws-panel tight note" data-ws-answered>Answered and expired items are not built yet.</p></div>
<p class="ws-panel tight note" data-ws-answered>Answered and expired items are not built yet.</p>
${typeof opts?.hire === 'string' ? opts.hire : ''}</div>
${insp}
</div>
</section>`;
@@ -292,3 +292,55 @@ test('A4 confirmation holds the exact human adjustment, so resolve cannot substi
const r=await s.resolve({choice:'new/autonomous',confirmation:c.json().confirmation});
assert.equal(r.status,200,r.text);assert.deepEqual(s.calls[1].args.adjust,adjust);
});
// D4 (#1873, P1-2): a hire start the bus definitely refused keeps its own code and a next step; a
// lost or unreadable reply is still outcome-unknown, and the other steps keep their mapping.
const START_HIRE={op:'hire',level:'org',name:'scout',reason:'Need help',role:{template:'coder',sha256:DIGEST},route:{harness:'pi',model:'gone-model'}};
const startWith=async err=>{
const s=setup({resolve:()=>{throw err;}});
const r=await s.run('/api/decisions/hire/start',request({body:{business:'demo',hire:START_HIRE}}));
assert.equal(s.calls.length,1,'one bus call, never retried');
return {r,s};
};
test('D4 hire start: model-provider-unavailable keeps its code and names Settings > Model proxy',async()=>{
const {r,s}=await startWith(new BusReadError('model-provider-unavailable'));
assert.equal(r.status,409,r.text);
const body=r.json();
assert.equal(body.error,'model-provider-unavailable');
assert.match(body.message,/Settings > Model proxy/);
assert.match(body.message,/not applied/);
assert.equal(r.headers['cache-control'],'no-store');
assert.match(s.lines.at(-1),/step=start error=model-provider-unavailable$/);
});
test('D4 hire start: the other model route codes keep their code with a next step',async()=>{
for(const [code,status] of [['model-catalogue-unavailable',503],['model-harness-incompatible',409],['thinking-unsupported',409]]) {
const {r}=await startWith(new BusReadError(code));
assert.equal(r.status,status,`${code}: ${r.text}`);assert.equal(r.json().error,code);assert.match(r.json().message,/not applied/);
}
});
test('D4 hire start: any other definite code is named and never claims nothing was recorded',async()=>{
const {r}=await startWith(new BusReadError('definition-not-hireable'));
assert.equal(r.status,409,r.text);
assert.deepEqual(r.json(),{error:'definition-not-hireable',message:'The bus refused this hire (definition-not-hireable). Refresh the inbox to see whether a hire decision is open before trying again.'});
});
test('D4 hire start: a lost or unreadable reply is still outcome-unknown',async()=>{
for(const err of [new BusReadError('outcome-unknown'),new BusReadError('invalid-response'),new BusReadError('response-too-large'),new BusReadError('outcome-unknown-revoked'),new BusReadError('Not A Code'),new BusReadError(''),new Error('socket closed'),Object.assign(new Error('x'),{code:'model-provider-unavailable'})])
refused((await startWith(err)).r,'outcome-unknown');
// A reply that does not say the hire resolved yes is not a refusal either.
const s=setup({resolve:()=>({id:'new-hire',op:'resolved',choice:'no'})});
refused(await s.run('/api/decisions/hire/start',request({body:{business:'demo',hire:START_HIRE}})),'outcome-unknown');
});
test('D4 hire start: the bus codes the endpoint already names keep their refusal',async()=>{
refused((await startWith(new BusReadError('unauthenticated'))).r,'human-required');
refused((await startWith(new BusReadError('right-required'))).r,'right-required');
refused((await startWith(new BusReadError('hire-owner-required'))).r,'hire-owner-required');
});
test('D4 templates, confirmation and resolve keep their open mapping for a definite unnamed code',async()=>{
const t=setup({resolve:()=>{throw new BusReadError('model-provider-unavailable');}});
refused(await t.run('/api/decisions/hire/templates',request({body:{business:'demo'}})),'confirmation-unavailable');
const c=setup({answer:()=>{throw new BusReadError('model-provider-unavailable');}});
refused(await c.confirm('yes'),'confirmation-unavailable');
const s=setup({resolve:()=>{throw new BusReadError('model-provider-unavailable');}});
const ok=await s.confirm('yes');assert.equal(ok.status,200);
refused(await s.resolve({choice:'yes',confirmation:ok.json().confirmation}),'outcome-unknown');
});
@@ -0,0 +1,129 @@
// D4 (#1873, readiness P0-1 and P1-2): on an org Console the hire, fire and change form is on the
// workspace inbox (#/inbox), posts through the real decision endpoint to the current organization's
// bus, and shows a definite refusal by its own code and next step. A lost reply stays outcome-unknown.
// The bus is a fake decision transport behind the real server, page code and decision endpoint.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { mkdir } from 'node:fs/promises';
import { join } from 'node:path';
import { startServer } from '../src/serve.mjs';
import { createDevOwner } from '../src/dev-owner.mjs';
import { BusReadError } from '../src/bus.mjs';
import { browser } from './browser.mjs';
import { close } from './fixture.mjs';
const waitFor = b => expression => b.evaluate(`(async()=>{for(let i=0;i<200;i++){if(${expression})return;await new Promise(r=>setTimeout(r,30))}throw Error(${JSON.stringify(expression)})})()`);
const SHA = 'b'.repeat(64);
const DECISION = 'dec-acme-0001';
// One running organization. `decide` gives it the send and decision transports a --send Console has.
function organizations({ decide, calls }) {
const LIST = [{ id: 'acme', label: 'Acme Studio', theme: 'cobalt', busHealthy: true }];
const inbox = [{ id: DECISION, question: 'Ship the hero?', class: 'gated', blocking: false, raised_by_role: 'coder', at: new Date(Date.now() - 600000).toISOString(), options: [{ key: 'yes', text: 'Ship it' }, { key: 'no', text: 'Hold' }] }];
const reads = { inbox: async () => inbox, agents: async () => [], 'thread.claims': async () => [], tasks: async () => [], usage: async () => ({}), limits: async () => ({}), decisions: async () => [] };
// The model name picks the bus answer: a refusal before the decision exists, a lost reply, or a hire.
const decisionWrite = async (verb, args, ctx) => {
calls.push({ verb, args, ctx });
if (verb === 'hire.templates.console') return { templates: [{ name: 'coder', sha256: SHA }] };
if (verb !== 'hire.start.console') throw new BusReadError('decision-not-found');
if (args.route?.model === 'gone-model') throw new BusReadError('model-provider-unavailable');
if (args.route?.model === 'lost-model') throw new BusReadError('outcome-unknown');
return { id: 'dec-hire-1', op: 'resolved', choice: 'yes' };
};
return {
list: async () => LIST,
members: async () => LIST.map(org => ({ id: org.id, doc: { appearance: { theme: org.theme } }, status: async () => ({ healthy: true, pid: 4242, boot: null }), options: () => ({ bus: reads, chat: { threads: async () => [], projects: async () => [] } }) })),
resolve: async id => id !== 'acme' ? null : {
busHealthy: true,
reads: { business: async () => ({ business: { id, human: 'jason', projects: [] } }), settings: async () => ({}), queue: async () => ({ rows: [] }), busStatus: async () => ({}) },
bus: { messages: async () => ({ messages: [], unread: 0 }), agents: async () => [], 'thread.claims': async () => [], inbox: async () => inbox.map(d => ({ ...d, business: id, raised_by_run: 'run', routed_to: 'human' })), tasks: async () => [], instances: async () => ({ business: id, instances: {} }) },
chat: { projects: async () => [], threads: async () => [] },
...(decide ? { send: async () => ({}), decisionWrite } : {}),
},
};
}
async function setup(t, { decide = true, viewport = [1440, 900] } = {}) {
const calls = [];
const server = await startServer({ port: 0, sso: createDevOwner(), organizations: organizations({ decide, calls }), log: () => {} });
t.after(() => close(server));
const b = await browser({ machine: false }); t.after(() => b.close());
await b.viewport(...viewport);
const base = `http://127.0.0.1:${server.address().port}`;
await b.navigate(`${base}/#/orgs/acme/inbox`);
return { b, calls, wait: waitFor(b), text: sel => b.evaluate(`document.querySelector(${JSON.stringify(sel)})?.innerText ?? null`) };
}
// MOSAIC_UX_SHOTS=<dir> also saves light and dark shots; `at` is the element centred in view.
const shots = async (b, name, width, at) => {
const dir = process.env.MOSAIC_UX_SHOTS;
if (!dir) return;
await mkdir(dir, { recursive: true });
for (const mode of ['light', 'dark']) {
await b.evaluate(`document.documentElement.dataset.mode=${JSON.stringify(mode)};document.querySelector(${JSON.stringify(at)}).scrollIntoView({block:'center'})`);
await b.screenshot(join(dir, `inbox-hire-${name}-${width}-${mode}.png`));
}
};
const fill = (b, values) => b.evaluate(`for (const [k, v] of Object.entries(${JSON.stringify(values)})) { const e = document.querySelector('[data-hire-field="' + k + '"]'); e.value = v; e.dispatchEvent(new Event('input', { bubbles: true })); }`);
for (const [width, height] of [[1440, 900], [390, 844]]) test(`D4 the org-mode inbox at ${width}px starts a hire on the current organization's bus, and a definite refusal keeps its code`, { timeout: 120000 }, async t => {
const { b, calls, wait, text } = await setup(t, { viewport: [width, height] });
await wait('document.querySelector("[data-ws-inbox] [data-ws-item]")');
// P0-1: the form is on the workspace inbox, beside the cross-organization list, not a separate page.
await wait('document.querySelector("[data-ws-inbox] #hire-start #hire-start-form")');
assert.match(await text('#hire-start h2'), /Hire, fire or change an agent/);
// The organization is the current one and is not editable: the posts go to its bus.
assert.equal(await b.evaluate('document.querySelector("[data-hire-field=business]")'), null);
assert.deepEqual(await b.evaluate('(e => [e.value, e.readOnly])(document.querySelector("#hire-start input[readonly]"))'), ['acme', true]);
assert.match(await text('#hire-start-org'), /acme's bus/);
await b.evaluate('document.querySelector("[data-hire-load]").click()');
await wait('document.querySelector("[data-hire-field=template] option[value=coder]")');
assert.deepEqual(calls.map(c => [c.verb, c.ctx.business]), [['hire.templates.console', 'acme']]);
assert.equal(await b.evaluate('document.documentElement.scrollWidth <= innerWidth'), true);
await shots(b, 'form', width, '#hire-start h2');
// P1-2: the bus refuses before it records anything; the page shows that code and its next step.
await fill(b, { name: 'scout', template: 'coder', harness: 'pi', model: 'gone-model', reason: 'Need a coder' });
await b.evaluate('document.querySelector("#hire-start-form").requestSubmit()');
await wait('document.querySelector("#hire-start-status code")');
assert.equal(await text('#hire-start-status code'), 'model-provider-unavailable');
assert.match(await text('#hire-start-status'), /Settings > Model proxy/);
assert.doesNotMatch(await text('#hire-start-status'), /may have reached the bus/);
const start = calls.filter(c => c.verb === 'hire.start.console');
assert.equal(start.length, 1, 'one start, never retried');
assert.equal(start[0].ctx.business, 'acme');
assert.deepEqual(start[0].args, { op: 'hire', level: 'org', name: 'scout', reason: 'Need a coder', role: { template: 'coder', sha256: SHA }, route: { harness: 'pi', model: 'gone-model' } });
assert.equal(await b.evaluate('document.documentElement.scrollWidth <= innerWidth'), true);
await shots(b, 'refused', width, '#hire-start-status');
// A lost reply is still outcome-unknown.
await fill(b, { model: 'lost-model' });
await b.evaluate('document.querySelector("#hire-start-form").requestSubmit()');
await wait('document.querySelector("#hire-start-status code")?.textContent === "outcome-unknown"');
assert.match(await text('#hire-start-status'), /may have reached the bus/);
// And a hire the bus records.
await fill(b, { model: 'fixture-model' });
await b.evaluate('document.querySelector("#hire-start-form").requestSubmit()');
await wait('document.querySelector("#hire-start-status")?.textContent.includes("Recorded decision dec-hire-1")');
assert.equal(await b.evaluate('document.querySelector("#hire-start-status code")'), null);
assert.equal(calls.filter(c => c.verb === 'hire.start.console').length, 3);
});
test('D4 a poll repaint of the inbox keeps the hire draft, focus and caret', { timeout: 120000 }, async t => {
const { b, wait } = await setup(t);
await wait('document.querySelector("#hire-start-form")');
await fill(b, { name: 'scout', reason: 'Need a coder' });
await b.evaluate('(e => { e.focus(); e.setSelectionRange(2, 2); })(document.querySelector("[data-hire-field=name]"))');
await b.evaluate('window.__marker = document.querySelector("[data-ws-inbox]"); document.dispatchEvent(new CustomEvent("mosaic-workspace-render"))');
await wait('document.querySelector("[data-ws-inbox]") && document.querySelector("[data-ws-inbox]") !== window.__marker');
assert.equal(await b.evaluate('document.activeElement?.dataset.focusKey'), 'hire:name');
assert.deepEqual(await b.evaluate('[document.activeElement.value, document.activeElement.selectionStart]'), ['scout', 2]);
assert.equal(await b.evaluate('document.querySelector("[data-hire-field=reason]").value'), 'Need a coder');
});
test('D4 without decision answers (no --send) the org-mode inbox shows no hire form', { timeout: 120000 }, async t => {
const { b, calls, wait } = await setup(t, { decide: false });
await wait('document.querySelector("[data-ws-inbox] [data-ws-item]")');
assert.equal(await b.evaluate('document.querySelector("#hire-start")'), null);
assert.equal(calls.length, 0);
});