← Back to Pull requests

feat: mobile adaptations for options and import/export (#293) #342

Merged
trueline-zcode-agent[bot] merged 16 files (2348 lines) on Nov 27, 2026 04:53 UTC
View on GitHub
trueline-zcode-agent[bot] trueline-zcode-agent[bot] commented on Nov 27, 2026 04:40 UTC
Author

Closes #293.

What

The two mobile-adaptation mockups, applied:

  • Options drafts until Done. Every setting the dialog edits (provider, key and endpoint, model, temperature, theme, language, the four toggles) stages into a draft. Done replays it through the same write path as before (updateProviderOptions still merges, setLocale still persists) and closes; Reset restores the at-open snapshot; every other exit — close, Escape, the sheet's back arrow — discards. The dialog footer says so: "Changes apply when you choose Done." Keys the user has not touched keep following their source (the stored locale loads a tick after open), touched keys belong to the draft alone until Reset. Actions stay immediate: theme upload, the encryption/unlock operations, and the destructive key Clear (which now also clears the staged field, so Done cannot resurrect what Clear removed).

  • The narrow sheets. Below lg both dialogs become the mockups' full-page sheets (#300's composition): a back bar ("Back to bookmarks") over the same body. Options carries the sticky Reset / Done footer and runs the provider row full width (.ui-sheet--options .ui-options-grid); Import & Export draws no footer (the mobile mockup has none) and names the library's size in the app bar, keeping #287's tabbed body. At dialog widths nothing changes — the existing panel cap already keeps both inside the viewport (the issue's acceptance).

  • 44px choice rows. The confirm card's skip-existing checkbox and append/replace radios join .ui-settings-row, the coarse-pointer floor from #291.
  • Notes

  • ImportExportContent.jsx sat at the lint's line ceiling (449 code lines vs 400) once it gained the sheet twin, so the export tab moved out as ExportPanel.jsx — the twin of ImportPanel.jsx — and the sheet chrome became ImportExportSheet.jsx (the DigestSheet pattern). UX-03's memoization moved with the export tab and now computes only while that tab is mounted. BackIcon joined the shared icons.jsx set; the options modal imports it instead of its local copy (the older sheet twins still carry theirs — untouched here).

  • Tests pin the composition they exercise (installViewport, the BookmarkForm convention): the historical suites stay on the dialog, new suites cover the draft model (stage / Done / Reset / Escape-discard), the options sheet, and the IO sheet. Full suite 1358 green; npm run ci green on the landed tree.

  • DESIGN.md records the decision (new "The options draft and the narrow sheets (#293)" section plus an Import/export paragraph); README's behavior list gained the draft model and the two sheets, and its "applies instantly" language claim is corrected. Changeset included (minor).

  • Mockups: bookmarkit_mobile_options_settings 167–291, bookmarkit_mobile_import_export 167–233.
  • <!-- agent-bot-write: ghw_4067c6742a7b8a94 session=ba9070074325 bot=trueline-zcode-agent[bot] -->

    Diff: 2348 lines (+1575 / -773) across 16 files Reviewer: qwts Review duration: 12m
    All Vouch review confidence checks passed
    Residual risk 0.36 = Change Risk (0.72) × (1 − Review Confidence (0.50)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.72 · 2348 lines diff across 16 files
    0.72
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.70 · 5 substantive comment(s)
    0.70
    Model 3 · Review Timing & Attention
    Session adequacy: 21% · Reviewer familiarity: 50%
    49%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    8 items
    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 27, 2026 04:41 UTC
    Bot

    <!-- codex-pull-request-review-summary -->
    <!-- codex-review-state:v1 {"code_review":{"commit_sha":"238901fb08e529cda9d4629aeb956ee4806bd9bc","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->

    <details>
    <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>

    This comment shows the latest Codex review activity on this pull request.

    | Review | Status | Commit | Review trigger |
    | --- | --- | --- | --- |
    | 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-27T04:43:00.147487Z">2026-11-27T04:43:00.147487Z</relative-time> | 238901f | PR opened |

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review" or "@codex security review".
  • Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    </details>

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 27, 2026 04:42 UTC
    Code Review
    src/components/OptionsModal.jsx:1
    @@ -314,536 +428,536 @@ const OptionsModal = ({
       };
     
       const hosted =
    -    provider === LLM_PROVIDERS.GEMINI ||
    -    provider === LLM_PROVIDERS.OPENAI ||
    -    provider === LLM_PROVIDERS.GROK;
    -  const local = provider === LLM_PROVIDERS.OLLAMA || provider === LLM_PROVIDERS.LMSTUDIO;
    -  const modelChange = (e) => onChangeOptions?.({ model: e.target.value });
    -  const clearApiKey = () => onChangeOptions?.({ apiKey: "" });
    +    draft.provider === LLM_PROVIDERS.GEMINI ||
    +    draft.provider === LLM_PROVIDERS.OPENAI ||
    +    draft.provider === LLM_PROVIDERS.GROK;
    +  const local =
    +    draft.provider === LLM_PROVIDERS.OLLAMA || draft.provider === LLM_PROVIDERS.LMSTUDIO;
    +  const modelChange = (e) => patchDraftOptions({ model: e.target.value });
    +  // Clearing the stored key is an action, not a setting (#293): it wipes the
    +  // store now — the destructive path it has always been — and the staged
    +  // field with it, so Done cannot resurrect what Clear removed.
    +  const clearApiKey = () => {
    +    onChangeOptions?.({ apiKey: "" });
    +    patchDraftOptions({ apiKey: "" });
    +  };
     
    -  return (
    -    <>
    -      <Modal
    -        title={t("options.title")}
    -        closeLabel={t("options.closeLabel")}
    -        onClose={onClose}
    -        size="2xl"
    -        footer={
    -          <>
    -            <Typography
    -              variant="body-sm"
    -              style={{ marginInlineEnd: "auto", alignSelf: "center", ...hintStyle }}
    -            >
    -              {t("options.changesSave")}
    -            </Typography>
    -            <Button onClick={onClose}>{t("options.done")}</Button>
    -          </>
    -        }
    -      >
    -        <div style={{ display: "grid", gap: "var(--ui-space-gutter-lg)" }}>
    -          {/* Read-only status: shows what provider + model will actually be
    -              used, as the options-settings screen's active-provider pill. */}
    -          <div>
    -            <span className="ui-pill">
    -              <span
    -                aria-hidden="true"
    -                style={{
    -                  width: 8,
    -                  height: 8,
    -                  borderRadius: "var(--ui-radius-full)",
    -                  background: "var(--ui-success)",
    -                }}
    -              />
    -              {providerOptions.model
    -                ? t("options.activeProviderModel", {
    -                    provider: provider || t("common.none"),
    -                    model: providerOptions.model,
    -                  })
    -                : t("options.activeProvider", { provider: provider || t("common.none") })}
    -            </span>
    -          </div>
    +  // The settings body: one reading for both chromes. Every control edits the
    +  // draft (#293), and the pill reads the draft too — Done is what makes it
    +  // true.
    +  const body = (
    +    <div style={{ display: "grid", gap: "var(--ui-space-gutter-lg)" }}>
    +      {/* Read-only status: shows what provider + model will actually be
    +          used once Done commits, as the options-settings screen's
    +          active-provider pill. */}
    +      <div>
    +        <span className="ui-pill">
    +          <span
    +            aria-hidden="true"
    +            style={{
    +              width: 8,
    +              height: 8,
    +              borderRadius: "var(--ui-radius-full)",
    +              background: "var(--ui-success)",
    +            }}
    +          />
    +          {draft.providerOptions.model
    +            ? t("options.activeProviderModel", {
    +                provider: draft.provider || t("common.none"),
    +                model: draft.providerOptions.model,
    +              })
    +            : t("options.activeProvider", { provider: draft.provider || t("common.none") })}
    +        </span>
    +      </div>
     
    -          <section style={sectionGap} aria-labelledby="options-provider-heading">
    -            <div>
    -              <Typography
    -                variant="headline-sm"
    -                as="h3"
    -                id="options-provider-heading"
    -                style={headingStyle}
    -              >
    -                {t("options.providerHeading")}
    -              </Typography>
    -              <Typography variant="body-sm" style={sublineStyle}>
    -                {t("options.providerSubline")}
    -              </Typography>
    -            </div>
    +      <section style={sectionGap} aria-labelledby="options-provider-heading">
    +        <div>
    +          <Typography
    +            variant="headline-sm"
    +            as="h3"
    +            id="options-provider-heading"
    +            style={headingStyle}
    +          >
    +            {t("options.providerHeading")}
    +          </Typography>
    +          <Typography variant="body-sm" style={sublineStyle}>
    +            {t("options.providerSubline")}
    +          </Typography>
    +        </div>
     
    -            <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
    -              <TokenSelect
    -                label={t("options.llmProviderLabel")}
    -                id="llm-provider"
    -                value={provider}
    -                onChange={(e) => onChange?.(e.target.value)}
    -                options={providerEntries}
    -              />
    -              {/* Provider-specific key field, beside the provider select as on
    -                  the mockup's two-column row. */}
    -              {hosted && (
    -                <ApiKeyField
    -                  label={t("options.apiKeyLabel")}
    -                  id="api-key"
    -                  placeholder={
    -                    encryption.locked ? t("options.lockedPlaceholder") : t("options.enterApiKey")
    -                  }
    -                  value={providerOptions.apiKey || ""}
    -                  disabled={encryption.locked}
    -                  onChange={(e) => onChangeOptions?.({ apiKey: e.target.value })}
    -                  hasApiKey={hasApiKey}
    -                  onClear={clearApiKey}
    -                />
    -              )}
    -              {local && (
    -                <ApiKeyField
    -                  label={t("options.apiKeyOptionalLabel")}
    -                  id="local-api-key"
    +        {/* #293: the dialog's two-column row; the sheet runs the same fields
    +            full width (`.ui-sheet--options .ui-options-grid`). */}
    +        <div className="ui-options-grid grid grid-cols-1 gap-4 sm:grid-cols-2">
    +          <TokenSelect
    +            label={t("options.llmProviderLabel")}
    +            id="llm-provider"
    +            value={draft.provider}
    +            onChange={(e) => patchDraft({ provider: e.target.value })}

    <sub><sub>!P1 Badge</sub></sub> Save options under the newly selected provider

    When the provider is changed while Options is open, this updates only draft.provider; draft.providerOptions remains the bag for the provider that was active when the dialog opened. Moreover, onChangeOptions comes from useLLMSettings and still closes over that old provider when Done invokes it immediately after onChange, so, for example, selecting OpenAI from Gemini and entering an OpenAI key writes that key into Gemini's options while activating an unconfigured OpenAI provider. Keep drafts keyed by provider or otherwise ensure the selected provider's options are loaded and persisted under that provider.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 27, 2026 04:42 UTC
    Code Review
    src/components/OptionsModal.jsx:1
    @@ -228,11 +256,95 @@ const OptionsModal = ({
       const [chosenFileName, setChosenFileName] = useState(null);
       const fileInputRef = useRef(null);
     
    -  const debouncedApiKey = useDebounce(providerOptions.apiKey || "", 600);
    -  const debouncedBaseUrl = useDebounce(providerOptions.baseUrl || "", 600);
    +  // #293: the draft. One snapshot of the at-open settings; every field edits
    +  // the draft, Done replays it through the write path, Reset restores the
    +  // snapshot, and any other way out simply drops it. The modal mounts fresh
    +  // on each open, so the two initializers are the at-open state. A key the
    +  // user has not touched keeps following its source — settings can still be
    +  // arriving after open (the stored locale loads a tick after mount) — while
    +  // a touched key belongs to the draft alone until Reset, so a live prop
    +  // change behind the dialog (an uploaded theme joining the library) never
    +  // clobbers what is staged.
    +  const isDialogViewport = useSidebarViewport();
    +  const sheetRef = useRef(null);
    +  useFocusTrap(sheetRef, !isDialogViewport);
    +  const sheetTitleId = useId();
    +  const dirtyKeys = useRef(new Set());
    +  const [openValues, setOpenValues] = useState(() => ({
    +    provider,
    +    providerOptions: { ...providerOptions },
    +    currentTheme,
    +    localeChoice,
    +    reduceMotion,
    +    effects,
    +    remoteFavicons,
    +    webMcpEnabled,
    +  }));
    +  const [draft, setDraft] = useState(() => ({
    +    provider,
    +    providerOptions: { ...providerOptions },
    +    currentTheme,
    +    localeChoice,
    +    reduceMotion,
    +    effects,
    +    remoteFavicons,
    +    webMcpEnabled,
    +  }));
    +  const patchDraft = (patch) => {
    +    for (const key of Object.keys(patch)) dirtyKeys.current.add(key);
    +    setDraft((prev) => ({ ...prev, ...patch }));
    +  };
    +  const patchDraftOptions = (patch) => {
    +    dirtyKeys.current.add("providerOptions");
    +    setDraft((prev) => ({ ...prev, providerOptions: { ...prev.providerOptions, ...patch } }));
    +  };
    +  const resetDraft = () => {
    +    dirtyKeys.current.clear();
    +    setDraft({ ...openValues, providerOptions: { ...openValues.providerOptions } });

    <sub><sub>!P2 Badge</sub></sub> Prevent Reset from restoring a cleared API key

    If a user clicks Clear, clearApiKey immediately persists an empty key and marks providerOptions dirty, which prevents the subsequent prop update from replacing the original key retained in openValues. Clicking Reset then copies that original key back into the draft, and Done persists it again, so the Clear → Reset → Done sequence resurrects a credential that was documented as cleared immediately. Update the reset snapshot when clearing or otherwise exclude the removed key from restoration.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 27, 2026 04:42 UTC
    Reviewer

    <!-- codex-code-review-finding:v1 -->

    💡 Codex Review

    https://github.com/true-line/bookmarkit/blob/238901fb08e529cda9d4629aeb956ee4806bd9bc/src/components/OptionsModal.jsx#L404-L412
    <sub><sub>!P2 Badge</sub></sub> Refresh models when the draft provider changes

    The model-loading effect depends on the persisted provider prop rather than draft.provider, so changing only the provider selector does not trigger discovery when the key and base URL stay equal. This occurs reliably when switching between default Ollama and LM Studio configurations, where both draft values are empty: the previous provider's model list remains displayed and no request reaches the new endpoint until the user manually presses Refresh. Depend on draft.provider and clear stale results when it changes.

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    trueline-zcode-agent[bot] trueline-zcode-agent[bot] commented on code on Nov 27, 2026 04:52 UTC
    Code Review
    src/components/OptionsModal.jsx:1
    @@ -314,536 +428,536 @@ const OptionsModal = ({
       };
     
       const hosted =
    -    provider === LLM_PROVIDERS.GEMINI ||
    -    provider === LLM_PROVIDERS.OPENAI ||
    -    provider === LLM_PROVIDERS.GROK;
    -  const local = provider === LLM_PROVIDERS.OLLAMA || provider === LLM_PROVIDERS.LMSTUDIO;
    -  const modelChange = (e) => onChangeOptions?.({ model: e.target.value });
    -  const clearApiKey = () => onChangeOptions?.({ apiKey: "" });
    +    draft.provider === LLM_PROVIDERS.GEMINI ||
    +    draft.provider === LLM_PROVIDERS.OPENAI ||
    +    draft.provider === LLM_PROVIDERS.GROK;
    +  const local =
    +    draft.provider === LLM_PROVIDERS.OLLAMA || draft.provider === LLM_PROVIDERS.LMSTUDIO;
    +  const modelChange = (e) => patchDraftOptions({ model: e.target.value });
    +  // Clearing the stored key is an action, not a setting (#293): it wipes the
    +  // store now — the destructive path it has always been — and the staged
    +  // field with it, so Done cannot resurrect what Clear removed.
    +  const clearApiKey = () => {
    +    onChangeOptions?.({ apiKey: "" });
    +    patchDraftOptions({ apiKey: "" });
    +  };
     
    -  return (
    -    <>
    -      <Modal
    -        title={t("options.title")}
    -        closeLabel={t("options.closeLabel")}
    -        onClose={onClose}
    -        size="2xl"
    -        footer={
    -          <>
    -            <Typography
    -              variant="body-sm"
    -              style={{ marginInlineEnd: "auto", alignSelf: "center", ...hintStyle }}
    -            >
    -              {t("options.changesSave")}
    -            </Typography>
    -            <Button onClick={onClose}>{t("options.done")}</Button>
    -          </>
    -        }
    -      >
    -        <div style={{ display: "grid", gap: "var(--ui-space-gutter-lg)" }}>
    -          {/* Read-only status: shows what provider + model will actually be
    -              used, as the options-settings screen's active-provider pill. */}
    -          <div>
    -            <span className="ui-pill">
    -              <span
    -                aria-hidden="true"
    -                style={{
    -                  width: 8,
    -                  height: 8,
    -                  borderRadius: "var(--ui-radius-full)",
    -                  background: "var(--ui-success)",
    -                }}
    -              />
    -              {providerOptions.model
    -                ? t("options.activeProviderModel", {
    -                    provider: provider || t("common.none"),
    -                    model: providerOptions.model,
    -                  })
    -                : t("options.activeProvider", { provider: provider || t("common.none") })}
    -            </span>
    -          </div>
    +  // The settings body: one reading for both chromes. Every control edits the
    +  // draft (#293), and the pill reads the draft too — Done is what makes it
    +  // true.
    +  const body = (
    +    <div style={{ display: "grid", gap: "var(--ui-space-gutter-lg)" }}>
    +      {/* Read-only status: shows what provider + model will actually be
    +          used once Done commits, as the options-settings screen's
    +          active-provider pill. */}
    +      <div>
    +        <span className="ui-pill">
    +          <span
    +            aria-hidden="true"
    +            style={{
    +              width: 8,
    +              height: 8,
    +              borderRadius: "var(--ui-radius-full)",
    +              background: "var(--ui-success)",
    +            }}
    +          />
    +          {draft.providerOptions.model
    +            ? t("options.activeProviderModel", {
    +                provider: draft.provider || t("common.none"),
    +                model: draft.providerOptions.model,
    +              })
    +            : t("options.activeProvider", { provider: draft.provider || t("common.none") })}
    +        </span>
    +      </div>
     
    -          <section style={sectionGap} aria-labelledby="options-provider-heading">
    -            <div>
    -              <Typography
    -                variant="headline-sm"
    -                as="h3"
    -                id="options-provider-heading"
    -                style={headingStyle}
    -              >
    -                {t("options.providerHeading")}
    -              </Typography>
    -              <Typography variant="body-sm" style={sublineStyle}>
    -                {t("options.providerSubline")}
    -              </Typography>
    -            </div>
    +      <section style={sectionGap} aria-labelledby="options-provider-heading">
    +        <div>
    +          <Typography
    +            variant="headline-sm"
    +            as="h3"
    +            id="options-provider-heading"
    +            style={headingStyle}
    +          >
    +            {t("options.providerHeading")}
    +          </Typography>
    +          <Typography variant="body-sm" style={sublineStyle}>
    +            {t("options.providerSubline")}
    +          </Typography>
    +        </div>
     
    -            <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
    -              <TokenSelect
    -                label={t("options.llmProviderLabel")}
    -                id="llm-provider"
    -                value={provider}
    -                onChange={(e) => onChange?.(e.target.value)}
    -                options={providerEntries}
    -              />
    -              {/* Provider-specific key field, beside the provider select as on
    -                  the mockup's two-column row. */}
    -              {hosted && (
    -                <ApiKeyField
    -                  label={t("options.apiKeyLabel")}
    -                  id="api-key"
    -                  placeholder={
    -                    encryption.locked ? t("options.lockedPlaceholder") : t("options.enterApiKey")
    -                  }
    -                  value={providerOptions.apiKey || ""}
    -                  disabled={encryption.locked}
    -                  onChange={(e) => onChangeOptions?.({ apiKey: e.target.value })}
    -                  hasApiKey={hasApiKey}
    -                  onClear={clearApiKey}
    -                />
    -              )}
    -              {local && (
    -                <ApiKeyField
    -                  label={t("options.apiKeyOptionalLabel")}
    -                  id="local-api-key"
    +        {/* #293: the dialog's two-column row; the sheet runs the same fields
    +            full width (`.ui-sheet--options .ui-options-grid`). */}
    +        <div className="ui-options-grid grid grid-cols-1 gap-4 sm:grid-cols-2">
    +          <TokenSelect
    +            label={t("options.llmProviderLabel")}
    +            id="llm-provider"
    +            value={draft.provider}
    +            onChange={(e) => patchDraft({ provider: e.target.value })}

    Fixed in afcdb2fe52874cdfecc8f47b02821fed57ddf3b4.

    Fixed in afcdb2f: updateProviderOptions(changes, forProvider) now writes the patch under the named provider (falling back to the active one for existing callers), and the options dialog stages a provider switch wholesale — the provider select seeds the draft's options from allProviderOptions[nextProvider] (new prop, wired from the hook's keyed options map) and commitDraft passes draft.provider as the target, so the switch and its patch land in one breath under the chosen provider. Covered by new tests in OptionsModal.test.jsx ("seeds the staged options from the chosen provider and commits under it") and useLLMSettings.test.jsx ("writes a named provider's options under that provider, not the active one").

    <!-- agent-bot-write: ghw_5ebe89cb7ff39e91 session=ba9070074325 bot=trueline-zcode-agent[bot] -->

    trueline-zcode-agent[bot] trueline-zcode-agent[bot] commented on code on Nov 27, 2026 04:52 UTC
    Code Review
    src/components/OptionsModal.jsx:1
    @@ -228,11 +256,95 @@ const OptionsModal = ({
       const [chosenFileName, setChosenFileName] = useState(null);
       const fileInputRef = useRef(null);
     
    -  const debouncedApiKey = useDebounce(providerOptions.apiKey || "", 600);
    -  const debouncedBaseUrl = useDebounce(providerOptions.baseUrl || "", 600);
    +  // #293: the draft. One snapshot of the at-open settings; every field edits
    +  // the draft, Done replays it through the write path, Reset restores the
    +  // snapshot, and any other way out simply drops it. The modal mounts fresh
    +  // on each open, so the two initializers are the at-open state. A key the
    +  // user has not touched keeps following its source — settings can still be
    +  // arriving after open (the stored locale loads a tick after mount) — while
    +  // a touched key belongs to the draft alone until Reset, so a live prop
    +  // change behind the dialog (an uploaded theme joining the library) never
    +  // clobbers what is staged.
    +  const isDialogViewport = useSidebarViewport();
    +  const sheetRef = useRef(null);
    +  useFocusTrap(sheetRef, !isDialogViewport);
    +  const sheetTitleId = useId();
    +  const dirtyKeys = useRef(new Set());
    +  const [openValues, setOpenValues] = useState(() => ({
    +    provider,
    +    providerOptions: { ...providerOptions },
    +    currentTheme,
    +    localeChoice,
    +    reduceMotion,
    +    effects,
    +    remoteFavicons,
    +    webMcpEnabled,
    +  }));
    +  const [draft, setDraft] = useState(() => ({
    +    provider,
    +    providerOptions: { ...providerOptions },
    +    currentTheme,
    +    localeChoice,
    +    reduceMotion,
    +    effects,
    +    remoteFavicons,
    +    webMcpEnabled,
    +  }));
    +  const patchDraft = (patch) => {
    +    for (const key of Object.keys(patch)) dirtyKeys.current.add(key);
    +    setDraft((prev) => ({ ...prev, ...patch }));
    +  };
    +  const patchDraftOptions = (patch) => {
    +    dirtyKeys.current.add("providerOptions");
    +    setDraft((prev) => ({ ...prev, providerOptions: { ...prev.providerOptions, ...patch } }));
    +  };
    +  const resetDraft = () => {
    +    dirtyKeys.current.clear();
    +    setDraft({ ...openValues, providerOptions: { ...openValues.providerOptions } });

    Fixed in afcdb2fe52874cdfecc8f47b02821fed57ddf3b4.

    Fixed in afcdb2f: clearApiKey now also clears apiKey in the at-open snapshot (openValues), guarded so it only applies when the snapshot still matches the staged provider. Since providerOptions is marked dirty by then, the source-sync effect can't reach the snapshot itself — without this, Reset restored the pre-Clear key and Done re-persisted it. Covered by the new test "does not resurrect a cleared key at Reset and Done".

    <!-- agent-bot-write: ghw_5ebe89cb7ff39e91 session=ba9070074325 bot=trueline-zcode-agent[bot] -->

    qwts qwts approved these changes on Nov 27, 2026 04:53 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    trueline-zcode-agent[bot] trueline-zcode-agent[bot]
    Labels
    risk: medium confidence: 49.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 71.5% (HIGH) · Higher = larger blast radius
    71.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 49.5% · Lower = rushed or shallow review
    49.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 36.1% · Moderate risk
    36.1%