Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(settings): show the Jev card only once Jev has been added
vastsa44e46e0ba249
diff --git a/apps/desktop/src/components/settings/JevSettingsCard.tsx b/apps/desktop/src/components/settings/JevSettingsCard.tsxindex 0ba5a909e..58f0ccc5b 100644--- a/apps/desktop/src/components/settings/JevSettingsCard.tsx+++ b/apps/desktop/src/components/settings/JevSettingsCard.tsx@@ -1,12 +1,12 @@/*** Jev on the model configuration page (D625, settings IA).*- * The card is the state of the integration and the way in: whether a TypeSafe- * key is stored, whether the classifier is on for Agent mode, and the actions- * that change either. The key itself is entered in the service dialog, which- * is also where Jev is added from — one place stores a key, and that place- * checks it against TypeSafe first. A field here would be a second way to keep- * a key nothing verified.+ * The card is the state of the integration: whether a TypeSafe key is stored,+ * whether the classifier is on for Agent mode, and the actions that change+ * either. It is only there once Jev has been added — before that it would be a+ * second place to paste a key, and adding stays where every other service is+ * added. The key itself is entered in the service dialog, which checks it+ * against TypeSafe before anything is kept.*/import { useState } from "react";import { useTranslation } from "react-i18next";@@ -39,6 +39,14 @@ export function JevSettingsCard({const [busy, setBusy] = useState<BusyAction>(null);const enabled = settings?.jevEnabled === true;const configured = keyStatus === "configured";+ /*+ Jev is one of the services the user adds from "Add service", so an install+ without it has nothing to show here: a card would only be a second place to+ paste a key. It appears once a key is stored, and it stays while a Host that+ cannot answer refuses to say either way or an enabled setting contradicts a+ missing key — hiding a configured install is the worse failure.+ */+ if (!configured && !enabled && keyStatus !== "unavailable") return null;const fail = (error: unknown) => {showToast(error instanceof Error ? error.message : String(error), {diff --git a/apps/desktop/test/jev-service-setup-user-path.test.mjs b/apps/desktop/test/jev-service-setup-user-path.test.mjsindex ffd97a818..60b278bbe 100644--- a/apps/desktop/test/jev-service-setup-user-path.test.mjs+++ b/apps/desktop/test/jev-service-setup-user-path.test.mjs@@ -124,12 +124,13 @@ function jevDialog(key) {}/**- * The settings page's own wiring: the card opens the dialog, and the dialog's- * report of a stored key is what makes the card read the state again.+ * The settings page's own wiring: the dialog is opened where the service+ * chooser opens it, and the dialog's report of a stored key is what makes the+ * card read the state and appear on the page.*/-function JevSurface() {+function JevSurface({ initiallyOpen = false }) {const settings = useAppStore((state) => state.settings);- const [open, setOpen] = React.useState(false);+ const [open, setOpen] = React.useState(initiallyOpen);const [revision, setRevision] = React.useState(0);return React.createElement(React.Fragment,@@ -178,15 +179,15 @@ window.jevServiceSetupProbe = async () => {const hiddenWhenEditing = !jevTile();const hiddenGroup = !document.body.innerText.includes("Classifiers");- // 3) The card and the dialog, wired the way the settings page wires them:- // adding Jev checks the key, stores it, turns Jev on, and the card reads it.+ // 3) Jev is not added yet, so the page shows no card: this dialog is opened+ // the way the service chooser opens it. Adding the service checks the key,+ // stores it, turns Jev on, and the card appears because the key is there.apiCalls.length = 0;savedKey = undefined;configured = false;jevCheck = { ok: true, status: 200 };- mount(React.createElement(JevSurface));- await waitFor(() => document.body.innerText.includes("API key not configured"), "the card did not read the empty state");- flushSync(() => button("Add key").click());+ mount(React.createElement(JevSurface, { initiallyOpen: true }));+ const cardAbsentBefore = !document.querySelector('[role="switch"][aria-label="Enable Jev for Agent"]');await waitFor(() => !!document.querySelector('input[aria-label="TypeSafe API key"]'), "the Jev form did not open");// The dialog is portaled onto documentElement, so the whole page is read.const privacyNoticeShown = await waitFor(@@ -201,7 +202,8 @@ window.jevServiceSetupProbe = async () => {() => document.body.innerText.includes("API key saved securely"),"the card did not pick up the key the dialog stored",);- const switchOn = document.querySelector('[role="switch"][aria-label="Enable Jev for Agent"]').getAttribute("aria-checked") === "true";+ const cardSwitch = document.querySelector('[role="switch"][aria-label="Enable Jev for Agent"]');+ const switchOn = cardSwitch?.getAttribute("aria-checked") === "true";const dialogClosed = !document.querySelector('input[aria-label="TypeSafe API key"]');// The check, the store and the switch, in that order.const flow = apiCalls.filter((call) => call.channel !== "pi-desktop/secrets/has");@@ -271,6 +273,7 @@ window.jevServiceSetupProbe = async () => {hiddenGroup,privacyNoticeShown,noModelPanes,+ cardAbsentBefore,switchOn,dialogClosed,checkedFirst,@@ -289,7 +292,7 @@ window.jevServiceSetupProbe = async () => {};`;-test("adding Jev checks the key before storing it, enables it on success, and cancels on close", {+test("adding Jev checks the key, enables it, shows the card, and cancels on close", {timeout: 60_000,skip:process.platform === "linux" && !process.env.DISPLAY@@ -377,6 +380,7 @@ app.whenReady().then(async () => {privacyNoticeShown: true,noModelPanes: true,switchOn: true,+ cardAbsentBefore: true,dialogClosed: true,checkedFirst: true,checkedTheTypedKey: true,diff --git a/apps/desktop/test/jev-settings-user-path.test.mjs b/apps/desktop/test/jev-settings-user-path.test.mjsindex f67e4242c..181c7ace3 100644--- a/apps/desktop/test/jev-settings-user-path.test.mjs+++ b/apps/desktop/test/jev-settings-user-path.test.mjs@@ -1,10 +1,12 @@/*** Isolated Electron user path for Jev settings (D625, settings IA).*- * What the card is now: the state of the integration and the way in. It reads- * whether a TypeSafe key is stored, lets the switch move only when one is, and- * sends the user to the service dialog to add or replace the key — it never- * stores a key itself. Removing the key takes the switch down first.+ * What the card is now: the state of the integration, shown only once Jev has+ * been added. An install without it has nothing to show here, because adding+ * happens where every other service is added. It reads whether a TypeSafe key+ * is stored, lets the switch move only when one is, and sends the user to the+ * service dialog to add or replace the key; it never stores a key itself.+ * Removing the key takes the switch down first, and then takes the card away.** The key is written by the service dialog (see the Jev service setup test);* this fixture stands in for that by storing one in the fake Host and@@ -104,55 +106,55 @@ function button(label) {}window.jevSettingsProbe = async () => {- await waitFor(() => document.body.innerText.includes("API key not configured"), "initial key state missing");- const toggle = () => document.querySelector('[role="switch"][aria-label="Enable Jev for Agent"]');- if (!toggle()) throw new Error("the Jev switch is missing");- const initialToggleDisabled = toggle().disabled;-- const addKey = button("Add key");- if (!addKey) throw new Error("the card must offer adding a key");- flushSync(() => addKey.click());+ // 1) With no key stored, Jev has not been added: nothing is shown here.await settle();- const configureOpened = configureClicks === 1;-- // Without a key the switch stays refused, whatever the card offers.- flushSync(() => toggle().click());await settle();- // Pressing a switch that has no key behind it must not write a setting.- const refusedWithoutKey = toggle().getAttribute("aria-checked") === "false"- && !apiCalls.some((call) => call.channel === "pi-desktop/settings/set");+ const hiddenUntilAdded = !document.querySelector('[role="switch"]')+ && !document.body.innerText.includes("Jev");- // A key the service dialog stored is what the next mount reads.+ // 2) The key the service dialog stored is what puts the card on the page.savedKey = "jev-ui-fixture-key";flushSync(() => window.__remount());- await waitFor(() => document.body.innerText.includes("API key saved securely"), "configured state missing");+ await waitFor(+ () => document.body.innerText.includes("API key saved securely"),+ "the card did not appear for a stored key",+ );+ const toggle = () => document.querySelector('[role="switch"][aria-label="Enable Jev for Agent"]');+ if (!toggle()) throw new Error("the Jev switch is missing");+ const toggleReadyWithKey = !toggle().disabled;const replaceOffered = Boolean(button("Replace key"));const removeOffered = Boolean(button("Remove key"));+ // The card's own action is the service dialog, the one place a key is kept.+ flushSync(() => button("Replace key").click());+ await settle();+ const configureOpened = configureClicks === 1;++ // 3) The switch is the setting, and a stored key is what it needs.flushSync(() => toggle().click());await waitFor(() => toggle().getAttribute("aria-checked") === "true", "Jev setting did not turn on");+ // 4) Removing the key takes the switch down first, deletes the key, and the+ // card leaves with it.const remove = button("Remove key");if (!remove) throw new Error("removing the key must stay possible");flushSync(() => remove.click());- await waitFor(() => document.body.innerText.includes("API key not configured"), "removed key state was not shown");+ await waitFor(() => !toggle(), "the card must leave once Jev is not added");- const finalToggle = toggle();const settingsWrites = apiCalls.filter((call) => call.channel === "pi-desktop/settings/set");const lastDisable = apiCalls.findLastIndex((call) => call.channel === "pi-desktop/settings/set" && call.input.jevEnabled === false,);const firstDelete = apiCalls.findIndex((call) => call.channel === "pi-desktop/secrets/delete");return {- initialToggleDisabled,- configureOpened,- refusedWithoutKey,+ hiddenUntilAdded,+ toggleReadyWithKey,replaceOffered,removeOffered,+ configureOpened,enabledSettingPersisted: settingsWrites.some((call) => call.input.jevEnabled === true),- disabledAfterRemoval: finalToggle.getAttribute("aria-checked") === "false",- toggleDisabledAfterRemoval: finalToggle.disabled === true,keyRemovedFromHost: savedKey === undefined,+ cardGoneAfterRemoval: !document.querySelector('[role="switch"]'),removalDisabledFirst: firstDelete !== -1 && lastDisable !== -1 && firstDelete > lastDisable,keyNeverStoredFromTheCard: !apiCalls.some((call) => call.channel === "pi-desktop/secrets/set"),storedKeyNeverInSettings: settingsWrites.every(@@ -162,7 +164,7 @@ window.jevSettingsProbe = async () => {};`;-test("the Jev card reads the key, gates the switch, and disables before removing", {+test("Jev's card appears once the service is added, and leaves with it", {timeout: 60_000,skip:process.platform === "linux" && !process.env.DISPLAY@@ -243,15 +245,14 @@ app.whenReady().then(async () => {assert(line, output.slice(-6000));const result = JSON.parse(line.slice("JEV_SETTINGS_PROBE ".length));assert.deepEqual(result, {- initialToggleDisabled: true,- configureOpened: true,- refusedWithoutKey: true,+ hiddenUntilAdded: true,+ toggleReadyWithKey: true,replaceOffered: true,removeOffered: true,+ configureOpened: true,enabledSettingPersisted: true,- disabledAfterRemoval: true,- toggleDisabledAfterRemoval: true,keyRemovedFromHost: true,+ cardGoneAfterRemoval: true,removalDisabledFirst: true,keyNeverStoredFromTheCard: true,storedKeyNeverInSettings: true,diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.mdindex e8f3aef82..cfc184b9e 100644--- a/docs/spec/04-ux/06-settings-ia.md+++ b/docs/spec/04-ux/06-settings-ia.md@@ -554,11 +554,13 @@ contract modes are intent boundaries, not strict read-only security profiles.action, so an enabled Jev always has a key the Agent can spend and anabandoned dialog never leaves a credential behind. The credential is aTypeSafe API key; this integration has no OAuth path.-- The model configuration page keeps one Jev card: the stored-key state, the- Agent-mode switch, and the actions that add, replace or remove the key. The- key itself is entered only in the service dialog, which is also where it is- checked. It stays in Host secure storage; the renderer only learns whether- one exists.+- The model configuration page shows the Jev card only once Jev has been added:+ an install without it has nothing there to configure, and adding stays in the+ service chooser. The card carries the stored-key state, the Agent-mode switch+ and the actions that replace or remove the key; removing the key takes the+ switch down first, then the card. The key itself is entered only in the+ service dialog, which is also where it is checked. It stays in Host secure+ storage; the renderer only learns whether one exists.- Explain that `JevClassify` sends only the state and questions the Agent passesto TypeSafe, and warn users not to include secrets or personal information.- The tool is on demand and unavailable in Plan and Goal modes. Removing thediff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex f96c5d459..2226f85d5 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -16927,21 +16927,24 @@ host-created files. The full app's file-preview viewer is covered separately.Build workspace JS packages with `pnpm build:js`, then run`pnpm test:e2e:jev`. Do not use a real TypeSafe key or endpoint.- **Steps:** 1) On the service chooser's add path, confirm Jev is offered in- its own Classifiers group and absent when an existing row changes service.- 2) Open the Jev form, paste a sentinel key and Check and save: the fixture- answers the check, the key reaches Host secure storage, Jev is on. 3) Resolve- a session launch with Jev enabled, then disabled and in Plan mode. 4) Through- the runtime's deferred catalog, request Jev in Agent mode and inspect- Plan/Goal catalogs. 5) Call `JevClassify` with one choice, one score and one- boolean question over a small JSON state. 6) Answer a check with 401 for a- second key: nothing is written and Jev stays off. 7) Start a check and close- the dialog while it is still in flight: the key is not stored and Jev stays- off. 8) In the Jev card, switch Jev off and remove the key.+ its own Classifiers group and absent when an existing row changes service,+ and that no Jev card is on the model configuration page yet. 2) Open the Jev+ form, paste a sentinel key and Check and save: the fixture answers the check,+ the key reaches Host secure storage, Jev is on, and the card appears.+ 3) Resolve a session launch with Jev enabled, then disabled and in Plan mode.+ 4) Through the runtime's deferred catalog, request Jev in Agent mode and+ inspect Plan/Goal catalogs. 5) Call `JevClassify` with one choice, one score+ and one boolean question over a small JSON state. 6) Answer a check with 401+ for a second key: nothing is written and Jev stays off. 7) Start a check and+ close the dialog while it is still in flight: the key is not stored and Jev+ stays off. 8) In the Jev card, switch Jev off and remove the key; the card+ leaves with it.- **Expected:** The check runs before any write, in the order check, store, thenenable, so a refused key leaves no secret and no enabled setting behind, and- the refusal is reported with TypeSafe's status. The UI never returns the key- to settings state, and removal disables Jev before deleting it. Only an- enabled Agent launch reads the key and passes it ephemerally to the sidecar.+ the refusal is reported with TypeSafe's status. The card is on the page only+ once Jev has been added, and it leaves when the key does. The UI never returns+ the key to settings state, and removal disables Jev before deleting it. Only+ an enabled Agent launch reads the key and passes it ephemerally to the sidecar.`JevClassify` appears in the Agent's deferred catalog only with a key andnever in Plan or Goal. Closing the dialog cancels an in-flight check the sameway a refused key does: nothing stored, nothing enabled. The fixture receives