Multiplayer agent harness for work.
fix(web-ui): show incompatible harnesses with an explanation (#1386)
Regan Bell80d63b8ee2b4
diff --git a/plugins/web-ui/src/composer.ts b/plugins/web-ui/src/composer.tsindex f40454206..3bd991127 100644--- a/plugins/web-ui/src/composer.ts+++ b/plugins/web-ui/src/composer.ts@@ -51,6 +51,7 @@ import {defaultModelValue,effortLabel,getModelOptions,+ getHarnessOptions,harnessSupportsEffort,harnessSupportsFastMode,harnessSupportsSteer,@@ -1313,24 +1314,31 @@ export function createComposerSurface(ctx: ConvCtx): ComposerSurface {}${loadoutSection === "harness"- ? compatibleHarnessOptions(getModelOptions(scopeKey()), selected.model.id).map(- (option) =>- html`<button- class="loadout-effort"- type="button"- role="menuitemradio"- aria-checked=${option.harnessId === selected.harnessId ? "true" : "false"}- @click=${() => {- closeLoadoutSection();- selectHarness(option.harnessId, agent);- }}+ ? getHarnessOptions(scopeKey()).map((harness) => {+ const compatible = compatibleHarnessOptions(getModelOptions(scopeKey()), selected.model.id).some(+ (option) => option.harnessId === harness.value,+ );+ const reason = compatible ? "" : `${harness.label} cannot run ${selected.label}.`;+ return html`<button+ class="loadout-effort"+ type="button"+ role="menuitemradio"+ aria-checked=${harness.value === selected.harnessId ? "true" : "false"}+ aria-disabled=${compatible ? "false" : "true"}+ aria-description=${reason || nothing}+ ${tip(reason)}+ @click=${() => {+ if (!compatible) return;+ closeLoadoutSection();+ selectHarness(harness.value, agent);+ }}+ >+ <span class="loadout-harness-option"+ >${modelMark(harness.value, 15) ?? nothing}<span>${harness.label}</span></span>- <span class="loadout-harness-option"- >${modelMark(option.harnessId, 15) ?? nothing}<span>${option.harnessLabel}</span></span- >- ${option.harnessId === selected.harnessId ? icon(Check, 15) : nothing}- </button>`,- )+ ${harness.value === selected.harnessId ? icon(Check, 15) : nothing}+ </button>`;+ }): nothing}${@@ -1369,7 +1377,7 @@ export function createComposerSurface(ctx: ConvCtx): ComposerSurface {}function loadoutHarnessControl(selected: ModelOption): TemplateResult {- const options = compatibleHarnessOptions(getModelOptions(scopeKey()), selected.model.id);+ const options = getHarnessOptions(scopeKey());const value = html`<span class="loadout-harness-option">${modelMark(selected.harnessId, 15) ?? nothing}<span>${selected.harnessLabel}</span></span>`;diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.cssindex f619d2706..095fdfcae 100644--- a/plugins/web-ui/src/shell.css+++ b/plugins/web-ui/src/shell.css@@ -3906,10 +3906,14 @@ qm-markdown .tok-in {.loadout-add.open,.loadout-setting:not([role="menuitemcheckbox"]):not(.loadout-setting-static):hover,.loadout-setting.open,-.loadout-effort:hover,+.loadout-effort:not([aria-disabled="true"]):hover,.loadout-back:hover {background: var(--secondary);}+.loadout-effort[aria-disabled="true"] {+ opacity: 0.45;+ cursor: not-allowed;+}.loadout-setting[role="menuitemcheckbox"]:disabled {opacity: 1;cursor: not-allowed;diff --git a/plugins/web-ui/test/composer-picker.test.ts b/plugins/web-ui/test/composer-picker.test.tsindex 2051157a1..de74a44be 100644--- a/plugins/web-ui/test/composer-picker.test.ts+++ b/plugins/web-ui/test/composer-picker.test.ts@@ -254,8 +254,19 @@ test("the model picker remembers compatible harnesses without duplicating or chaconst choices = [...host.querySelectorAll<HTMLButtonElement>('.loadout-submenu [role="menuitemradio"]')];assert.deepEqual(choices.map((choice) => choice.textContent?.trim()),- ["Pi", "Claude Code", "OpenCode"],+ ["Pi", "Claude Code", "OpenCode", "Codex"],);+ assert.equal(choices[3]!.getAttribute("aria-disabled"), "true");+ assert.equal(choices[3]!.getAttribute("aria-description"), "Codex cannot run Alpha.");+ choices[3]!.dispatchEvent(new MouseEvent("mouseenter"));+ assert.equal(document.querySelector(".qm-tooltip.visible")?.textContent, "Codex cannot run Alpha.");+ const beforeDisabledClick = saved();+ const beforeDisabledUpdates = updates.length;+ choices[3]!.click();+ assert.equal(composer!.currentModelOption()?.value, "claude:alpha");+ assert.deepEqual(saved(), beforeDisabledClick);+ assert.equal(updates.length, beforeDisabledUpdates);+ assert.ok(host.querySelector(".loadout-submenu"));assert.equal(choices[1]!.getAttribute("aria-checked"), "true");assert.equal(document.activeElement, choices[1]);choices[0]!.click();@@ -281,9 +292,19 @@ test("the model picker remembers compatible harnesses without duplicating or chapick("Beta").click();assert.equal(composer!.currentModelOption()?.value, "codex:beta");- assert.equal(host.querySelector('[data-loadout-section="harness"]'), null);- assert.match(host.querySelector(".loadout-setting-static")?.textContent ?? "", /Run with\s*Codex/);- assert.equal(host.querySelector(".loadout-setting-static button"), null);+ button('[data-loadout-section="harness"]').click();+ await tick();+ const betaChoices = [...host.querySelectorAll<HTMLButtonElement>('.loadout-submenu [role="menuitemradio"]')];+ assert.deepEqual(+ betaChoices.map((choice) => choice.getAttribute("aria-disabled")),+ ["true", "true", "true", "false"],+ );+ const claude = betaChoices[1]!;+ claude.focus();+ assert.equal(document.querySelector(".qm-tooltip.visible")?.textContent, "Claude Code cannot run Beta.");+ claude.click();+ assert.equal(composer!.currentModelOption()?.value, "codex:beta");+ button(".loadout-back").click();pick("Alpha").click();assert.equal(composer!.currentModelOption()?.value, "pi:alpha");assert.equal(composer!.state.effortLevel, "high");