Skip to content

fix(desktop): keep image generation model row visible without candidates - #2568

Merged
Tioit-Wang merged 3 commits into
vastsa:mainfrom
skyler-developer:fix/image-model-row-visible-2563
Nov 25, 2026
Merged

Tioit-Wang merged 3 commits into
vastsa:mainfrom
skyler-developer:fix/image-model-row-visible-2563

Conversation

@skyler-developer

Copy link
Copy Markdown
Contributor

Summary / 概要

The built-in GenerateImages error (IMAGE_NOT_CONFIGURED) sends the user to Settings → Models → Image generation model, but that settings block hid itself entirely while no image-capable model existed: ModelConfigPage gated the section on imageGenerationCandidates.length > 0 and ImageGenerationModelRow returned null for an empty candidate list. The error pointer landed on nothing (#2563, reported on Windows; the logic is platform-independent).

Changes:

  • Render the image generation model section unconditionally; with no candidates the row stays visible and shows an explicit "no image generation model available" state (same model-default-empty pattern the row already uses for an unset default), pointing at where to mark a model.
  • Add the imageModelNoneAvailable copy to all nine locales.
  • IMAGE_NOT_CONFIGURED now also states that MCP image tools are separate tools and cannot back the built-in tool, so an installed MCP image service no longer reads as a broken backend.
  • New Electron-harness test image-generation-row-empty-state.test.mjs pins both states (empty list → visible row, no picker; real candidates → normal picker).

Out of scope: a formal provider protocol for MCP image services to back the built-in tool (product decision requested in the issue).

Requirement link / 需求关联

  • Linked requirement issue / 已关联对应的需求 Issue:Closes #2563
  • Issue explains the background and the expected outcome / Issue 已说明需求背景和期望效果
  • UI changes carry a fitting reference: screenshot, sketch, or demo / 涉及 UI 的改动已提供合适的截图、设计参考或 Demo
  • UI changes include before / after screenshots, uploaded to the PR (not committed to the repo) / UI 变更已附修改前后截图(直接上传到 PR,不要提交进仓库)

(The two UI boxes are left unchecked: I could not run the app locally to capture before/after screenshots; the rendered empty-state markup is pinned by the new test.)

Validation / 验证

Task candidate: branch fix/image-model-row-visible-2563, HEAD c0f6df855, based on origin/main 8ac4a9f495d5b1e5fa7957acdf157aa9567462bc (merge-base --is-ancestor verified).

  • pnpm build:js — pass
  • pnpm --filter @pi-desktop/desktop typecheck — pass
  • pnpm lint — pass
  • node --test test/image-generation.test.mjs test/provider-model-config.test.mjs test/settings-general.test.mjs — 54/54 pass
  • node --test test/model-advanced-capabilities.test.mjs — 18/18 pass (its source assertion pinning the old hidden-row behavior was updated to pin the new empty-state behavior)
  • node --test test/image-generation-row-empty-state.test.mjs — NOT RUN locally: the Electron binary is missing because dependencies were installed with --ignore-scripts; the test code was verified by bundling it with the same esbuild config (0 errors) and by a throwaway react-dom/server render of the row component asserting both states. It will run in CI.
  • An independent code review pass approved the change after its one blocking finding (the outdated source assertion) was fixed.

Rollback / 回滚

Single commit; revert it to restore the previous conditional rendering and error copy.

The GenerateImages IMAGE_NOT_CONFIGURED error sends the user to
Settings > Models > Image generation model, but both the settings page
and the row hid themselves while no image-capable model existed, turning
the pointer into a dead end (vastsa#2563). Render the section unconditionally
and show an explicit no-candidates state in the row; the row already had
the same pattern for an unset default. The error copy now also states
that MCP image tools are separate and never back the built-in tool.
@Tioit-Wang

Copy link
Copy Markdown
Collaborator

@pi review code

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Pi finished @Tioit-Wang's task —— View job


Verdict

Direction is right and the zero-candidate fix is correct, but I would not merge this as-is: the fix leaves the same dead end reachable, contradicts the pinned E2E scenario doc, and the new test almost certainly cannot run (it was never executed locally).

Blocking

1. The row still disappears when candidates exist but none are runnable — the same #2563 dead end

apps/desktop/src/components/settings/ImageGenerationModelRow.tsx:86 still bails out with

if (!options.some((option) => !option.disabled)) return null;

ImageGenerationModelRow.tsx:36-38 claims "The row never disappears", but it does whenever imageGenerationPickerCandidates returns entries that are all unavailable. That is a realistic state: imageGenerationBindingAvailable (image-generation-default.ts:42-52) requires an enabled provider with a base URL plus credential, so a user who marked a model and then disabled the provider, cleared its key, or blanked the base URL sees no image row at all. And that state is exactly what the runtime points here for — image-generation-service.ts:57-60 returns IMAGE_MODEL_UNAVAILABLE with "Update Settings > Models > Image generation model". model-advanced-capabilities.test.mjs:113 keeps pinning this contrast (all-disabled → return null) while lines 114-118 pin "must not vanish", so the two rules now coexist. Reuse the empty-state branch here too (render the row with the select disabled and imageModelUnavailable/imageModelNoneAvailable), rather than unmounting it.

2. The behavior change contradicts the E2E scenario doc

docs/spec/06-delivery/e2e/conversation.md documents the old behavior in three places: :390-391 "verify the image summary row is absent", :400 "The unconfigured state renders no image summary", :409 "the image row stays hidden". AGENTS.md §13 requires the corresponding E2E scenario doc to be updated in the same change. I checked scripts/e2e-image-generation-ui.mjs for ImageGenerationModelRow/imageModel/.model-image-row references and found none, so no script breaks — this is documentation drift, not a red gate, but it must not land as-is.

3. apps/desktop/test/image-generation-row-empty-state.test.mjs imports node:assert/strict into a browser bundle

The fixture string at image-generation-row-empty-state.test.mjs:38-42 imports node:assert/strict and is bundled with platform: "browser" (:73), where esbuild cannot resolve Node built-ins. Every other Electron-harness test in this repo keeps node:assert on the Node/Electron-main side and uses a local check() helper inside the page — see turn-changes-disclosure-user-path.test.mjs:48, plugin-settings-json-user-path.test.mjs:40, editable-context-menu-user-path.test.mjs:40-41 (the only node:assert inside an injected bundle, in the Electron-main bundle). Since the PR states the test was never executed, this is the first thing to fix. Cleanest form: have the page return a probe object ({rowVisible, text, hasPicker}) and assert it on the Node side with assert.match(output, ...), so a failure reports a readable diff instead of only console text.

Non-blocking

  • Copy vs. actual control name. imageModelNoneAvailable (e.g. packages/i18n/src/locales/en/index.ts:1133) says "Mark a model as image-capable in a provider's model settings", but the control is labelled Set as image model (en locale :1136) inside Model Advanced. Using the button's own wording makes the pointer actually followable. The empty row also offers no action (no button or scroll-to-provider), which is optional but cheap.
  • Test robustness. stdout/stderr are concatenated without setEncoding("utf8") (other harness tests set it), and the inner child.kill() at 30 s vs timeout: 60_000 means a timeout failure reports a signal rather than a useful message. Assertions inside the page also lose diff quality (see above).
  • Agent-facing message. image-generation-service.ts:47 now appends the MCP clarification. That text is model-facing guidance, not just UI copy — the intent matches the issue, but call it out in the PR as a prompt/tool-surface change; nothing in docs/ pins the old string, so it is safe.
  • UI screenshots. Both UI template boxes are unchecked. This change alters what the Settings → Models page renders in the unconfigured state; the template asks for before/after captures, and the new harness test does not substitute for that.

What I verified as sound

  • All nine locales carry the new key with no parity gap (packages/i18n/src/locales/*/index.ts), placed next to the existing imageModel* keys.
  • Removing the imageGenerationCandidates.length > 0 gate in ModelConfigPage.tsx leaves no dead code: the memo is still used for providerReady, afterSaved, firstModelId and the imageModelIds prop.
  • The section order assertion in provider-model-config.test.mjs:42-50 (services → catalog → Jev → image row) still holds after the gate removal.
  • No test pins the old "Do not substitute another model." string, and IMAGE_NOT_CONFIGURED is not quoted in docs/, so the copy edit does not break specs.
  • ModelConfigPage renders the section with providers.length === 0 too; that reads as intended (the "no providers" empty state is above it), just worth an explicit screenshot.
Run details · 2m 23s · 835.2k tokens · ≈$0.063
  • Executor: pi-agent-action
  • Model: deepseek/deepseek-v4.1-flash (high)
  • Duration: 2m 23s (22 turns)
  • Tokens: 835.2k (141.5k input, 680.3k cached, 13.4k output)
  • Estimated cost: ≈$0.063 (deepseek-flash: $0.006/M cached, $0.30/M input, $1.20/M output)

v_wyxgwang and others added 2 commits November 25, 2026 10:21
Keep the settings row visible when every marked model is unavailable.
Exercise the empty, unavailable, and runnable states in Electron CI and
update the settings scenario to match the actual navigation and UI.
@Tioit-Wang
Tioit-Wang merged commit 649c345 into vastsa:main Nov 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants