Skip to content

feat(chat): pick the model and effort in the composer's model menu (W4-02) - #2031

Merged
gkhngyk merged 16 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-model-menu
Nov 4, 2026
Merged

gkhngyk merged 16 commits into
ansvisor:mainfrom
cihan-gyk:feature/chat-model-menu

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Chat's model menu in the composer (CHAT-16 §A–C, Wave 4 plan W4-02; mockup #s-limits). The model button under the message box, which only said "Auto · Haiku reads, Sonnet writes" until now, opens the menu.

  • Models:
    • Auto comes first, marked Default ("Haiku 5.5 reads, Sonnet 5.5 writes", 1x).
    • Then the offered (tested) models: Claude Haiku 5.5 and Sonnet 5.5 at launch; Opus 5.5 stays hidden until its real test run passes (Wave 4 decision 1 B). Each shows its multiplier against Auto, green under 1x and amber from 3x.
    • ✓ marks the chat's pick.
    • Under the list: "Prices from OpenRouter, updated today. 1x = Auto."
    • No dollar anywhere (the 2026-10-27 decision): the data comes from feat(chat): answer Chat's model menu with each model's multiplier and tone, never a price (W4-01) #2030.
  • Effort: Normal, High, Max, with "High and Max use your limit faster".
  • Use your own API key:
    • Enterprise: "Included in your plan" (Settings › AI Providers).
    • A kept key: "Works until {date}".
    • Other plans: "Own API keys come with Enterprise · you're on {plan}". W4-06 turns the Enterprise row into the Your API keys window.
  • Monthly AI usage: the percent and "Resets {date}", then Your plan with See plans.
  • The pick goes with each message of the chat (model, effort on POST /api/chat/runs) and is kept on its run (chat_runs.model, effort; no migration). A chat opens on its latest run's pick; a new chat starts on Auto.
  • Plan lock (Wave 4 decision 2 B): in the free trial only Auto at Normal is open; the menu says so. The server checks the pick again as the run starts:
    • a model that isn't offered (not tested, or dropped), a pick kept from before included, runs Auto; a value that isn't a model id is refused with 400 invalid;
    • in the trial, the run starts on Auto at Normal.
  • If the catalog dropped the chat's model, the menu says so and shows Auto ticked.
  • Help: new help/chat/models.md (approved: false).

Merges together with W4-01 and W4-03: the engine reads the pick in W4-03. Stacked on #2030 (which is on #2006).

Related issue

None. Chat Wave 4 plan, W4-02.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Open Chat and click the model button under the box. You see Auto ticked, Haiku 5.5 and Sonnet 5.5 with their multipliers, the prices line, Effort, the own-key row, AI usage and your plan.
  2. Pick Sonnet 5.5 and High: the button reads "Sonnet 5.5 · High". Send a message, reload the chat: the button still reads it.
  3. In a free-trial workspace the models and High/Max are greyed out, with the trial line.
  4. cd web && yarn vitest run src/components/chat/composer src/lib/chat/model-menu.test.ts src/app/api/chat/models src/lib/chat/engine.test.ts -t "model"

Screenshots (light and dark, 1024 px): the model menu.

No migration. No new environment variables.

Checklist

  • Branch follows the naming convention
  • Commits follow Conventional Commits
  • yarn lint passes
  • yarn typecheck passes
  • yarn format:check passes
  • Changes are focused — one concern per PR
  • Help article updated under help/ (or no user-visible change)

Screens: shown to the owner in a local preview (1024px, light and dark) and approved on 2026-11-02.

CI passed on this branch (0e26184), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41525028933): schema is up to date; web format:check, lint, typecheck, all tests and yarn build pass; server lint, format:check and all tests pass.

🤖 Generated with Claude Code

cihan-gyk and others added 11 commits November 2, 2026 09:12
…3-DB, 00457–00459)

Chat's Wave 3 tables in one PR (one DB PR per wave), behind CHAT_AGENTIC:
nothing reads or writes them while the flag is off. Tables, types, tests
and the demo's coverage only; the code that uses them comes in W3-01,
W3-06 and W3-11. Every new table has row level security on; members only
ever read, anon gets nothing, and every write is the server's.

- 00457: chat_schedules (CHAT-12): once, recurring or a follow-up check;
  run at / ready by, due and next run, the RRULE and time zone; title,
  prompt or skill, the brand fixed at creation, the creator it acts as and
  its own chat; delivery to chat and/or email, recipients only people of
  the workspace (a trigger checks), change-only with the last fingerprint;
  mode, model, effort; on/off with the reason, failures in a row, the one
  retry; a follow-up check's target, metric and who set it (card or
  full_auto, the latter only for follow-up checks). A job whose brand or
  creator is deleted turns off (missing_source, owner_role) instead of
  running on without them. chat_schedule_runs: slot and attempt (unique,
  so a slot never runs twice), Run now, the Chat run and answer, status,
  parts done, fingerprint, usage as a share, email outcome.
  chat_conversations.schedule_id with origin 'schedule' (one live chat per
  job; it stays the creator's), prompt_improve_usage.schedule_id, and
  reserve_chat_ai_usage taking p_schedule_id (default null, old calls still
  match): the row is named by the chat's job, a job that isn't the chat's
  is refused. Creator and Admins read a job, within their brands.
- 00458: chat_skills (CHAT-13): name unique in the workspace in the
  format's rules, body up to 50 KB, licenses MIT, Apache-2.0,
  BSD-2-Clause, BSD-3-Clause, ISC (an import needs one), source user or
  import with the pinned commit and checksum, scan and removed parts,
  review status (only an approved skill can be on), private or workspace.
  Private or unapproved: creator and Admins; approved workspace skills:
  every member. chat_settings.disabled_skills for library skills.
- 00459: chat_memory_items (CHAT-14): Me, brand and workspace lines, 1–300
  characters, at most 4,000 a scope (a trigger under a lock per scope,
  deleted lines left out), one profile line a person, deleted_at for Undo;
  brand lines go with the brand, Me lines with the account and when the
  person leaves the workspace (trigger on profiles). Me: only its person;
  brand lines: brand access; workspace lines: every member.
  chat_settings.memory_enabled and chat_user_prefs.memory_enabled, both on.

web/src/types/supabase.ts carries the new tables and columns; schema.test.ts
checks the Wave 3 policies, limits, vocabularies, triggers and the hold's
signature from the SQL; brand-access-policies.test.js lists the new tables;
the demo coverage skips chat_schedules and chat_memory_items.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	server/src/lib/brand-access-policies.test.js
#	web/src/types/supabase.ts
…brary, agent calls and outside e-mails (W4-DB, 00462–00467)

- 00462: the price catalog's supported_parameters and context_length, and
  prompt_improve_usage.units for image rows.
- 00463: content_drafts.origin and conversation_id; drafts with an action
  become action_center without touching updated_at; a member may say editor
  or chat and name only a chat of their own.
- 00464: chat_whats_new_reads, a person's own rows.
- 00465: chat_skills source library, library_ref and update_checked_at;
  00458's unnamed pin rule named and widened.
- 00466: chat_agent_versions.can_call and agent-called runs, one level deep,
  at most 3 a run.
- 00467: chat_schedules.external_recipients and chat_outbound_emails, each
  sent only with a click.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	server/src/lib/brand-access-policies.test.js
#	supabase/schema.sql
#	web/src/lib/chat/schema.test.ts
#	web/src/types/supabase.ts
… tone, never a price (W4-01)

- The daily price sync keeps each model's supported parameters and context
  length (00462).
- The API server answers GET /api/internal/chat/models with the offered
  models' multiplier labels, a tone (green under 1x, amber from 3x), whether
  the price moves by the hour, whether the catalog dropped a model, the count
  of chat models that can call tools and the last sync. CRON_SECRET only,
  not counted by the per-IP limiter.
- The web offers Claude's three tested models (lib/chat/models.ts, Wave 4
  decision 1 B) and answers GET /api/chat/models, with "Your key" on the own
  key's models; it still lists them when the API server doesn't answer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…4-02)

- The model button opens the menu: Auto (Default, Haiku 5.5 reads, Sonnet
  5.5 writes, 1x), the offered models with their multipliers (green under
  1x, amber from 3x), "Prices from OpenRouter, updated today. 1x = Auto.",
  Effort (Normal, High, Max), the own-key row, the month's AI usage with its
  reset, and the plan. No dollar anywhere.
- The pick goes with each message of the chat and is kept on its run; a
  chat opens on its latest run's pick, a new one on Auto.
- The server checks it again as the run starts: an offered model only, and
  Auto at Normal in the free trial (Wave 4 decision 2 B).
- Help: help/chat/models.md (approved: false).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…un, Opus 5.5 hidden for now (W4-01)

Each model Chat may run is listed with `tested`; only tested ones are
offered in the menu, asked of the price catalog, or accepted by the engine,
and a chat or agent that picked one not tested runs Auto. At launch that is
Haiku 5.5 and Sonnet 5.5; Opus 5.5 waits for its run of the test set (owner,
2026-11-02).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Opus 5.5 hidden until tested: a pick of a model not offered, kept from
before, now runs Auto instead of being refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…their own mounts (W4-01)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Nov 2, 2026
cihan-gyk and others added 4 commits November 3, 2026 04:55
…ature/chat-model-catalog

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…talog, keeping the branch's tree

The squash's tree equals feature/chat-wave4-db's final head, merged just before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…at-model-menu

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

# Conflicts:
#	web/src/components/chat/composer/chat-composer.tsx
#	web/src/lib/chat/engine.ts
@github-actions github-actions Bot removed the needs-migration Adds or edits a migration — apply it to the hosted database label Nov 3, 2026
gkhngyk
gkhngyk previously approved these changes Nov 3, 2026
@gkhngyk

gkhngyk commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

This PR now conflicts with main: #2030 was squash-merged, so its commits are on main under new hashes. Could you merge main into this branch (or rebase it onto main) and resolve the conflicts? Once CI is green I'll merge it.

Stacked on it and needing the same, in order: #2032 → #2033 → #2036 → #2038 → #2039 → #2065. Updating each after the one below it has merged keeps the conflicts small.

…menu

# Conflicts:
#	web/src/app/api/chat/models/route.test.ts
#	web/src/app/api/chat/models/route.ts
#	web/src/components/chat/composer/chat-composer.tsx
#	web/src/lib/chat/engine.ts
#	web/src/lib/chat/model-menu.test.ts
#	web/src/lib/chat/models.ts
@gkhngyk
gkhngyk merged commit f5c26ed into ansvisor:main Nov 4, 2026
7 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