Skip to content

fix(automations): align model selector with chat under Simple Mode - #3305

Merged
tlgimenes merged 6 commits into
mainfrom
tlgimenes/model-switcher-mismatch
May 7, 2026
Merged

tlgimenes merged 6 commits into
mainfrom
tlgimenes/model-switcher-mismatch

Conversation

@tlgimenes

@tlgimenes tlgimenes commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

What is this contribution about?

The automation model selector diverged from chat's: the picker showed concrete model names instead of Fast/Smart/Thinking tiers under Simple Mode, new automations always saved empty model fields, and the Test button left the chat running on the wrong tier. This PR brings the automation editor to parity with the chat input — same SimpleModeTierDropdown, same Simple-Mode-aware seeding for new rows, same model state when firing a test run.

Also surfaces the Simple Mode section first on the AI Providers settings page (and hides it when no keys are configured) since it's the org-wide model policy.

How to Test

  1. Enable Simple Mode in /$org/settings/ai-providers and configure all three tiers.
  2. Open an automation: the picker shows Fast/Smart/Thinking, not a concrete model name. Switch tiers — the form's saved models.thinking.id updates to the resolved concrete model.
  3. From the automation list, switch the chat tier to thinking, click "New automation": the created row's models.thinking.id matches the thinking slot.
  4. With chat on thinking, open an automation pinned to fast and click Test: the chat tier switches to fast and the test run uses the fast-tier model.
  5. Toggle Simple Mode off: the regular model picker returns and the Test button restores its previous concrete-model behavior. No regression.

Migration Notes

None. Runtime payload shape ({ credentialId, thinking: { id } }) is unchanged; this is a UI/seeding alignment.

Review Checklist

  • PR title is clear and descriptive
  • Changes are tested and working
  • Documentation is updated (if needed)
  • No breaking changes

Summary by cubic

Aligns the Automations model selector with Chat in Simple Mode and fixes tier/test behavior. Also keeps the automation panel and chat visible when a test creates a new thread.

  • Bug Fixes

    • Automation model picker now shows Fast/Smart/Thinking tiers and saves the resolved model to models.thinking.id.
    • Test button syncs chat to the automation’s tier in Simple Mode (setSimpleModeTier); behavior unchanged when off.
    • New automations seed credentialId/modelId from the chat when available.
    • Test runs preserve panel and chat state (keep automation panel open and force-open chat on thread creation).
  • Refactors

    • Extracted SimpleModeTierDropdown to a shared component and reused in chat and automations; removed unused SIMPLE_MODE_TIER_OPTIONS export.
    • Moved the Simple Mode section to the top of the org AI Providers page and hide it when no provider keys exist.

Written for commit 6332e3d. Summary will update on new commits.

tlgimenes and others added 4 commits May 6, 2026 17:58
When Simple Mode is enabled, the chat's selectedModel is resolved from
the active tier and the stored model ref is ignored. Calling setModel
from the Test button therefore had no effect and the chat ran on
whatever tier it happened to be on. Branch on simpleMode.enabled and
call setSimpleModeTier with the automation's current tier, mirroring
the chat input's own picker behavior. When Simple Mode is off,
behavior is unchanged.
Move the tier picker out of input.tsx into its own file so the
automation editor can reuse the exact same dropdown rather than
duplicating the markup.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
buildDefaultAutomationInput accepted no model context, so new
automations always saved empty model fields and never honored Simple
Mode. Thread the chat's already-resolved selectedModel and credentialId
(via useChatPrefs) through AutomationsList.handleCreate so the row
persists a concrete modelId/keyId — exactly what the runtime expects
and the same shape chat sends to /stream. When chatModel hasn't
resolved yet, fall back to empty fields (no regression).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Move SimpleModeSection above the credits hero and provider grid so
admins see the org-wide model policy as the primary action on the AI
Providers page. Hide it entirely when no provider keys are configured —
the form has nothing to bind to in that state.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

🧪 Benchmark

Should we run the Virtual MCP strategy benchmark for this PR?

React with 👍 to run the benchmark.

Reaction Action
👍 Run quick benchmark (10 & 128 tools)

Benchmark will run on the next push after you react.

@github-actions

github-actions Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Release Options

Suggested: Patch (2.308.1) — based on fix: prefix

React with an emoji to override the release type:

Reaction Type Next Version
👍 Prerelease 2.308.1-alpha.1
🎉 Patch 2.308.1
❤️ Minor 2.309.0
🚀 Major 3.0.0

Current version: 2.308.0

Note: If multiple reactions exist, the smallest bump wins. If no reactions, the suggested bump is used (default: patch).

tlgimenes and others added 2 commits May 7, 2026 10:40
navigateToTask rebuilt the search params from scratch and dropped
prev.main and prev.chat, so clicking Test from the automation editor
collapsed the side panel and reset chat visibility. Preserve both keys
mirroring usePanelActions.setTaskId, and force-open chat from
handleRunClick so a collapsed chat panel still surfaces the test run.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The constant is only consumed by SimpleModeTierDropdown in the same
file. Knip flagged the export as dead.
@tlgimenes
tlgimenes merged commit 536e5d9 into main May 7, 2026
16 checks passed
@tlgimenes
tlgimenes deleted the tlgimenes/model-switcher-mismatch branch May 7, 2026 13:54
viktormarinho added a commit that referenced this pull request May 7, 2026
Stop baking the resolved model into the automation row. When the user
saves with Simple Mode enabled, persist a `tier` intent ("fast" /
"smart" / "thinking") inside `automation.models`; `buildStreamRequest`
then looks up the live tier slot from `organization_settings.simple_mode`
and uses that instead of the stored credentialId / thinking.id snapshot.

Effects:
- Dormant automations now pick up org Simple Mode changes the next time
  they fire — no UI visit needed to reconcile.
- The detail page derives the dropdown label from `models.tier` first
  (truthful even after a slot reconfig), falling back to slot-match for
  legacy automations.
- The form clears `tier` whenever the user explicitly picks via the
  ModelSelector fallback, so an explicit override beats the tier intent.
- Legacy automations (no tier persisted) keep using the stored snapshot
  until next save, at which point Simple Mode is enabled they get pinned
  to the matched / default tier.

Tests cover the four resolution paths (override, simple-mode disabled,
tier slot unset, no tier on legacy row).

This builds on the UI work merged in #3305 — that PR aligned the model
selector with the chat input but kept baking the resolved model into the
row, so dormant automations stayed stale until someone opened them.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
viktormarinho added a commit that referenced this pull request May 7, 2026
* feat(automations): resolve simple-mode tier at run time

Stop baking the resolved model into the automation row. When the user
saves with Simple Mode enabled, persist a `tier` intent ("fast" /
"smart" / "thinking") inside `automation.models`; `buildStreamRequest`
then looks up the live tier slot from `organization_settings.simple_mode`
and uses that instead of the stored credentialId / thinking.id snapshot.

Effects:
- Dormant automations now pick up org Simple Mode changes the next time
  they fire — no UI visit needed to reconcile.
- The detail page derives the dropdown label from `models.tier` first
  (truthful even after a slot reconfig), falling back to slot-match for
  legacy automations.
- The form clears `tier` whenever the user explicitly picks via the
  ModelSelector fallback, so an explicit override beats the tier intent.
- Legacy automations (no tier persisted) keep using the stored snapshot
  until next save, at which point Simple Mode is enabled they get pinned
  to the matched / default tier.

Tests cover the four resolution paths (override, simple-mode disabled,
tier slot unset, no tier on legacy row).

This builds on the UI work merged in #3305 — that PR aligned the model
selector with the chat input but kept baking the resolved model into the
row, so dormant automations stayed stale until someone opened them.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* fix(automations): refresh full thinking metadata + safer auto-pin

Address review on PR #3307:

#1 — The previous override only patched `credentialId` and `thinking.id`,
leaving stale `capabilities` / `limits` / `provider` / `title` from the
saved snapshot. Downstream code (`ensureModelCompatibility`, the
max-output-tokens cap, telemetry, prompt headers) consumes those fields,
so a tier whose live slot pointed to a different model would get gated
against the wrong capability set. Replace the patch with a typed
`TierOverride` produced by `resolveTierOverride`, which fetches the full
`ModelInfo` via `ctx.aiProviders.listModels` and translates it into the
`thinking` shape — same translation as the chat path's
`toMetadataModelInfo`. Falls back to a slot-only override (with stored
title) if the provider call throws, so a flaky provider doesn't block
the run.

#2 — Saving any edit on a Simple-Mode-enabled legacy automation (e.g.
just renaming it) used to silently write `tier: "smart"` because
`tierToPersist` fell back to the dropdown's display fallback. After
that, the run path would override the user's original snapshot model
with the org's live "smart" slot. Only auto-pin when `slotMatchedTier`
is truthy — i.e. the saved credential/model actually correspond to a
configured slot. Legacy automations with no slot match stay unpinned
on incidental saves; the user has to explicitly pick a tier via the
dropdown to opt in.

Tests: split build-stream-request tests into "tier override" (verifies
full thinking replacement) and add a new resolve-tier-override.test.ts
that exercises ModelInfo translation, the disabled / unset / no-tier
short-circuits, and the listModels-throws fallback.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

* docs(automations): clarify tier snapshot fallback role

Co-Authored-By: Claude Opus 4.7 <[email protected]>

* fix(settings): persist Simple Mode toggle on first enable

The autosave gated on `formState.isDirty`, but RHF's dirty flag was
cleared before the 250ms debounce fired:
- `handleToggle` calls `form.reset(...)` to seed default tier slots,
  which rebases the dirty baseline (even with keepDirty: true, fields
  that weren't already dirty stay clean).
- `useForm({ values: simpleMode })` re-syncs whenever the React Query
  cache emits a new object reference, which `useSimpleMode`'s select
  does on every render.

By the time the timer fired, `isDirty` was false and `save` bailed,
so the mutation never ran and the row was never inserted. First-time
toggle-on on a fresh org silently no-op'd.

Drop the isDirty gate. Each `schedule()` call is the explicit save
intent — only user actions call it, and nothing inside `save`
re-schedules, so there's no feedback loop.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant