Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: derive pipeline visual "Auto" label from the shared render ladder (#6815)
[._.]/ Adam Eivycd26b78230dd
diff --git a/client/src/components/pipeline/stages/VisualGenSettings.jsx b/client/src/components/pipeline/stages/VisualGenSettings.jsxindex c1dcad17d6..85d9130b4f 100644--- a/client/src/components/pipeline/stages/VisualGenSettings.jsx+++ b/client/src/components/pipeline/stages/VisualGenSettings.jsx@@ -19,7 +19,9 @@ import {getSettings, listImageModels, getProviders,} from '../../../services/api';import { filterSelectableModels } from '../../../utils/providers';-import { deriveAvailableBackends, IMAGE_GEN_MODE } from '../../../lib/imageGenBackends';+import {+ deriveAvailableBackends, IMAGE_GEN_MODE, MODE_LABELS, RENDER_TARGET, imageModeCandidates, pickUsableMode,+} from '../../../lib/imageGenBackends';import BackendChipStrip from '../../media/BackendChipStrip';import ProviderModelSelector from '../../ProviderModelSelector';@@ -41,7 +43,7 @@ const DEFAULT_CONFIG = Object.freeze({// "auto" is the default sentinel — the backend strip displays it as a// dedicated chip that means "follow the server's resolver". The actual-// dispatch happens server-side in visualStages.js#resolveMode.+// dispatch happens server-side in pipeline/visualStageHelpers.js#resolveMode.const AUTO_BACKEND = Object.freeze({ id: 'auto', label: 'Auto', icon: Sparkles });const MODE_BLURB = {@@ -73,32 +75,21 @@ const loadLookups = () => {return promise;};-// Mirror of server-side `visualStages.js#resolveMode`. The "Auto →" label in-// this panel must match what the server will actually dispatch — otherwise-// the modal tells the user "Auto is currently Codex" while the render flows-// to local diffusion (or vice versa). Priority:-// 1. settings.imageGen.mode pinned to 'codex'/'grok' AND enabled → that backend-// 2. settings.imageGen.mode pinned to 'local' → 'local'-// 3. codex enabled, else grok enabled (auto-default) → that backend-// 4. local pythonPath configured → 'local'-// 5. otherwise → not configured-// Mirrors the server's resolveMode in pipeline/visualStageHelpers.js — a-// cloud backend is gated on its enabled flag at every step, so a stale pin-// from before a toggle was turned off resolves as local, not that backend.-const resolveAutoLabel = (s) => {- const codexEnabled = s?.imageGen?.codex?.enabled === true;- const grokEnabled = s?.imageGen?.grok?.enabled === true;- const agyEnabled = s?.imageGen?.agy?.enabled === true;- const pinned = s?.imageGen?.mode;- if (pinned === IMAGE_GEN_MODE.CODEX && codexEnabled) return 'Codex';- if (pinned === IMAGE_GEN_MODE.GROK && grokEnabled) return 'Grok';- if (pinned === IMAGE_GEN_MODE.AGY && agyEnabled) return 'Agy';- if (pinned === IMAGE_GEN_MODE.LOCAL) return 'Local diffusion';- if (codexEnabled) return 'Codex';- if (grokEnabled) return 'Grok';- if (agyEnabled) return 'Agy';- if (s?.imageGen?.local?.pythonPath) return 'Local diffusion';- return 'Local diffusion (not configured)';+// The "Auto →" label in this panel resolves through the SAME shared ladder+// the server dispatches through — `pickUsableMode` + `imageModeCandidates`+// (server/lib/renderModeLadder.js, re-exported via imageGenBackends.js) —+// instead of a hand-copied mirror that can drift from it (#6815): the+// candidate order is `[series pin, pipeline-visual renderDefaults pin,+// settings.imageGen.mode]`, exactly matching+// `pipeline/visualStageHelpers.js#resolveMode`. Local diffusion gets a+// friendlier display name here than `MODE_LABELS` (used by the terser chip+// strip), plus the "(not configured)" suffix when it has no pythonPath.+const AUTO_LOCAL_LABEL = 'Local diffusion';+const autoModeLabel = (mode, s) => {+ if (mode === IMAGE_GEN_MODE.LOCAL) {+ return s?.imageGen?.local?.pythonPath ? AUTO_LOCAL_LABEL : `${AUTO_LOCAL_LABEL} (not configured)`;+ }+ return MODE_LABELS[mode] || mode;};const summarizeMode = (cfg, autoResolution) => {@@ -238,7 +229,11 @@ function VisualGenSettingsBody({ cfg, update, stageLabel, systemSettings, imageM// (mounted inside a Modal that is freshly constructed each open) so users who// enable Codex or swap providers in Settings see the change immediately on the// next modal open without reloading the SPA.-function useVisualGenSettings(value, stageLabel, refreshOnMount = false) {+// `series` — the owning series record, threaded through to `imageModeCandidates`+// so the "Auto →" label honors a series-level render pin (#6815) the same way+// the server's resolver does. Optional: omit it for a caller with no series in+// scope, which just means that candidate never contributes a pin.+function useVisualGenSettings(value, stageLabel, refreshOnMount = false, series = null) {const cfg = { ...DEFAULT_CONFIG, ...(value || {}) };const [systemSettings, setSystemSettings] = useState(null);const [imageModels, setImageModels] = useState([]);@@ -269,7 +264,8 @@ function useVisualGenSettings(value, stageLabel, refreshOnMount = false) {return p ? filterSelectableModels(p.models || [p.defaultModel]) : [];}, [providers, cfg.refineProvider]);- const autoResolution = resolveAutoLabel(systemSettings);+ const autoMode = pickUsableMode(systemSettings, imageModeCandidates(systemSettings, RENDER_TARGET.PIPELINE_VISUAL, series));+ const autoResolution = autoModeLabel(autoMode, systemSettings);const summary = summarizeMode(cfg, autoResolution);const blurb = cfg.imageMode === 'auto'? `Auto follows the server default — currently ${autoResolution}.`@@ -285,8 +281,10 @@ function useVisualGenSettings(value, stageLabel, refreshOnMount = false) {* Chromeless settings panel — just the controls, no accordion wrapper.* Use when embedding inside a Modal or other parent-owned container.*/-export function VisualGenSettingsPanel({ value, onChange, stageLabel = 'Visual stage' }) {- const bag = useVisualGenSettings(value, stageLabel, true);+export function VisualGenSettingsPanel({+ value, onChange, stageLabel = 'Visual stage', series = null,+}) {+ const bag = useVisualGenSettings(value, stageLabel, true, series);const update = (patch) => onChange?.({ ...bag.cfg, ...patch });return <VisualGenSettingsBody {...bag} update={update} />;}@@ -304,8 +302,10 @@ export function summarizeGenConfig(cfg) {return summarizeMode(merged, 'server default');}-export default function VisualGenSettings({ value, onChange, stageLabel = 'Visual stage' }) {- const bag = useVisualGenSettings(value, stageLabel);+export default function VisualGenSettings({+ value, onChange, stageLabel = 'Visual stage', series = null,+}) {+ const bag = useVisualGenSettings(value, stageLabel, false, series);const update = (patch) => onChange?.({ ...bag.cfg, ...patch });const [open, setOpen] = useState(false);diff --git a/client/src/components/pipeline/stages/VisualGenSettings.test.jsx b/client/src/components/pipeline/stages/VisualGenSettings.test.jsxnew file mode 100644index 0000000000..38a6dc35f9--- /dev/null+++ b/client/src/components/pipeline/stages/VisualGenSettings.test.jsx@@ -0,0 +1,68 @@+/**+ * The "Auto → …" label must name the backend that will actually render+ * (#6815). Before this, `resolveAutoLabel` was a hand copy of the server's+ * mode ladder that only ever consulted `settings.imageGen.mode` + the enable+ * flags — it ignored both a `renderDefaults['pipeline-visual']` pin and a+ * series-level render pin, so the label could name one backend while the+ * server dispatched to another. These tests render through the real shared+ * ladder (`pickUsableMode` + `imageModeCandidates`, server/lib/renderModeLadder.js)+ * and assert on the rendered blurb text, not an internal function — the bug+ * lived in a function these tests would happily re-implement.+ */++import { describe, it, expect, vi, beforeEach } from 'vitest';+import { render, screen } from '@testing-library/react';++vi.mock('../../../services/api', () => ({+ getSettings: vi.fn(),+ listImageModels: vi.fn(),+ getProviders: vi.fn(),+}));++import { VisualGenSettingsPanel } from './VisualGenSettings';+import { getSettings, listImageModels, getProviders } from '../../../services/api';++const CODEX_ONLY = { mode: 'codex', codex: { enabled: true }, local: { pythonPath: '/usr/bin/python3' } };++beforeEach(() => {+ vi.clearAllMocks();+ listImageModels.mockResolvedValue([]);+ getProviders.mockResolvedValue({ providers: [] });+});++describe('VisualGenSettings — "Auto →" label (#6815)', () => {+ it('honors a pipeline-visual renderDefaults pin over the install-wide default', async () => {+ getSettings.mockResolvedValue({+ imageGen: CODEX_ONLY,+ renderDefaults: { 'pipeline-visual': { imageMode: 'local' } },+ });+ render(<VisualGenSettingsPanel value={null} onChange={vi.fn()} />);+ expect(await screen.findByText(/currently Local diffusion\./)).toBeInTheDocument();+ });++ it('names the backend a series is pinned to, even when the install default would pick a different enabled backend', async () => {+ // Both codex and agy are enabled, so an unpinned auto-default resolves to+ // codex (CLOUD_IMAGE_GEN_MODES order) — an observed "Agy" can only have+ // come from the series pin.+ getSettings.mockResolvedValue({ imageGen: { codex: { enabled: true }, agy: { enabled: true } } });+ render(<VisualGenSettingsPanel value={null} onChange={vi.fn()} series={{ id: 'ser-1', imageMode: 'agy' }} />);+ expect(await screen.findByText(/currently Agy\./)).toBeInTheDocument();+ });++ it('falls through a series pin on a disabled backend to the pipeline-visual renderDefaults pin', async () => {+ getSettings.mockResolvedValue({+ imageGen: { mode: 'codex', codex: { enabled: true }, agy: { enabled: false }, grok: { enabled: true } },+ renderDefaults: { 'pipeline-visual': { imageMode: 'grok' } },+ });+ render(+ <VisualGenSettingsPanel value={null} onChange={vi.fn()} series={{ id: 'ser-1', imageMode: 'agy' }} />,+ );+ expect(await screen.findByText(/currently Grok\./)).toBeInTheDocument();+ });++ it('keeps the "(not configured)" suffix when Auto resolves to local with no pythonPath set', async () => {+ getSettings.mockResolvedValue({ imageGen: {} });+ render(<VisualGenSettingsPanel value={null} onChange={vi.fn()} />);+ expect(await screen.findByText(/currently Local diffusion \(not configured\)\./)).toBeInTheDocument();+ });+});diff --git a/client/src/lib/imageGenModes.js b/client/src/lib/imageGenModes.jsindex 65c503fdd8..9223ffa273 100644--- a/client/src/lib/imageGenModes.js+++ b/client/src/lib/imageGenModes.js@@ -37,6 +37,12 @@ import {RENDER_TARGET_BACKEND_AUTO,normalizeRenderPinValue,} from '../../../server/lib/renderTargets.js';+import {+ imageModeCandidates,+ isModeUsable,+ pickUsableMode,+ renderTargetDefaults,+} from '../../../server/lib/renderModeLadder.js';import {AGY_IMAGEGEN_DEFAULT_MODEL,AGY_IMAGEGEN_IMAGE_MODEL,@@ -88,6 +94,15 @@ export {maxInputImages,normalizeRenderPinValue,supportsCloudModelOverride,+ // The image-gen mode resolution ladder (#6815) — the SAME resolver every+ // server surface dispatches through, so a client display of "what will Auto+ // resolve to" can't hand-copy the ladder and drift from it. See+ // `server/lib/renderModeLadder.js` for the fall-through semantics (a pin is+ // a preference, not a guarantee) and the candidate-order contract.+ imageModeCandidates,+ isModeUsable,+ pickUsableMode,+ renderTargetDefaults,};// The Settings → Image Gen → Defaults rows for the server's render-target@@ -137,11 +152,14 @@ export const isCloudCliMode = (mode) => CLOUD_IMAGE_GEN_MODES.includes(mode);/*** The client-side counterpart of the server's `renderTargetDefaults`- * (imageGen/cloudProviderConfig.js) — one surface's saved `settings.renderDefaults`- * pin, re-keyed to the flat `imageMode`/`imageModelId` shape `renderPinLadder`- * consumes so a target pin and a record pin are the same kind of thing. Its- * input is the settings payload the client already holds, so this reads that- * object rather than importing a resolver from a service module.+ * (`lib/renderModeLadder.js`, re-exported above) — one surface's saved+ * `settings.renderDefaults` pin, re-keyed to the flat `imageMode`/`imageModelId`+ * shape `renderPinLadder` consumes so a target pin and a record pin are the+ * same kind of thing. Its input is the settings payload the client already+ * holds, so this reads that object directly rather than calling+ * `renderTargetDefaults` itself, which returns the fuller+ * `{imageMode, imageModel, videoMode, videoModel}` shape `pickUsableMode` /+ * `imageModeCandidates` consume — not `renderPinLadder`'s pin-source shape.*/export const renderTargetPin = (settings, target) => ({imageMode: settings?.renderDefaults?.[target]?.imageMode ?? null,diff --git a/client/src/pages/PipelineIssue.jsx b/client/src/pages/PipelineIssue.jsxindex d29c6cdaf2..a56a687313 100644--- a/client/src/pages/PipelineIssue.jsx+++ b/client/src/pages/PipelineIssue.jsx@@ -499,6 +499,7 @@ export default function PipelineIssue() {value={issue.stages?.[stageId]?.genConfig || null}onChange={handleGenConfigChange}stageLabel={VISUAL_STAGE_LABELS[stageId]}+ series={series}/></div></Modal>