Skip to content

feat(settings): preview saved model suitability and estimated cost - #8461

Open
AmirrezaFarnamTaheri wants to merge 5 commits into
tinyhumansai:mainfrom
AmirrezaFarnamTaheri:upstream/feat-saved-model-suitability-preview-20261027
Open

AmirrezaFarnamTaheri wants to merge 5 commits into
tinyhumansai:mainfrom
AmirrezaFarnamTaheri:upstream/feat-saved-model-suitability-preview-20261027

Conversation

@AmirrezaFarnamTaheri

@AmirrezaFarnamTaheri AmirrezaFarnamTaheri commented Oct 27, 2026 •

Copy link
Copy Markdown

Summary

  • Add an opt-in, collapsed-by-default, read-only model suitability preview to Settings → AI → Routing, extracted from fork PR Update quote in README.md #19 without importing its credential fleets or provider routing changes.
  • Compare the saved model registry against user-supplied input/output context, cached-input volume, vision requirement, and optional estimated cost ceiling.
  • Clearly distinguish models excluded by known constraints from models with unknown metadata, including zero/missing prices; never claim live pricing, provider eligibility, key health, or quota.
  • Keep model selection and persistence untouched. No inference calls, new network requests, backend schema changes, additional dependencies, or secrets.
  • Bring upstream-focused unit and UI tests for sorting, hard constraints, cached-input pricing, invalid inputs, pagination and filtering.

Problem

When comparing configured models, the UI has no local way to evaluate context, vision and approximate cost requirements together. Users may mistakenly treat missing/zero price as verified free, or confuse a catalog entry with a live model authorization. Moving the fork's entire fleet/settings implementation upstream would mix this useful UX improvement with incompatible credential and provider contracts.

Solution

The new pure modelFeasibility.ts module ranks only saved metadata and labels every assumption; ModelFeasibilityPreview.tsx renders it in a collapsed, advisory section. The section appears only in Settings, not the embedded onboarding settings. The calculator uses no remote API. Hard constraint exclusions precede ranking by estimated saved-price cost. Cached input is priced separately and must not exceed input volume.

Submission Checklist

  • Tests added/updated (happy, failure, edge): modelFeasibility.test.ts and ModelFeasibilityPreview.test.tsx.
  • Diff coverage ≥80% — exact-head CI Fast #40561048958 measured 89% across 113 changed executable lines.
  • Coverage matrix: N/A — advisory view of existing configured models, no new runtime capability.
  • Affected feature IDs: model registry and AI workload routing UI (existing).
  • No new external network dependencies or side effects.
  • Release manual smoke checklist: N/A, no installer/release scope; manual Settings review recommended.
  • Linked issue: N/A, no verified issue to close.

Impact

Frontend only (web/desktop). No credential writes, provider switches, routing updates, changes to the inference backend, or network egress. The disclosure control is collapsed by default to avoid cluttering existing routing UX. Display is based on saved metadata and does not verify runtime availability or current vendor prices.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A — no issue supplied.
  • URL: N/A.

Commit & Branch

  • Branch: AmirrezaFarnamTaheri:upstream/feat-saved-model-suitability-preview-20261027
  • Commit SHA: 692b65fbc51a7fc89181cea072ac224aa094415d

Validation Run

  • Exact-head CI Fast: run #40561048958 passed on 692b65fbc51a7fc89181cea072ac224aa094415d.
  • Frontend typecheck, Prettier and repository-gated frontend tests passed in hosted CI.
  • Focused tests: pnpm --filter openhuman-app exec vitest run src/components/settings/panels/ai/modelFeasibility.test.ts src/components/settings/panels/ai/ModelFeasibilityPreview.test.tsx covered by full hosted Vitest suite.
  • Rust fmt/check: N/A, no Rust changes.
  • Tauri fmt/check: N/A, no Tauri changes.

Validation Blocked

  • Local desktop/browser acceptance remains outstanding. Hosted CI passed; retain draft until any required manual acceptance and maintainer review finish.

Behavior Changes

  • Intended: metadata-only advisory comparison for configured models.
  • User-visible: optional expanded view with input/cached/output token constraints, vision, cost ceiling, filter, search and paged results.

Parity Contract

  • Legacy behavior preserved: all cloud providers, auth profiles, model registry persistence, route selection and ongoing inference remain unchanged.
  • Guard/fallback/dispatch: no runtime dispatch; unknown metadata is never interpreted as live eligible/free.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none found in open upstream contributions for model suitability preview.
  • Canonical PR: this scoped frontend feature.
  • Resolution: fork-specific credential fleets, API-key rotation and custom provider presets remain outside this PR until a stable upstream ownership contract exists.

Review readiness (2026-10-28)

  • Exact-head CI Fast and PR Quality passed; changed-line coverage 89%.
  • No unresolved review threads. Manual preview/device acceptance and maintainer approval remain open.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 5 billable files and costs up to $1.25.

Or wait 49 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: caf60593-18e0-4d5d-bc5c-cbd8613c910d
Commits

Reviewing files that changed from the base of the PR and between 9d5a06c and 692b65f.

Files selected for processing: 5
  • app/src/components/settings/panels/AIPanel.tsx
  • app/src/components/settings/panels/ai/ModelFeasibilityPreview.test.tsx
  • app/src/components/settings/panels/ai/ModelFeasibilityPreview.tsx
  • app/src/components/settings/panels/ai/modelFeasibility.test.ts
  • app/src/components/settings/panels/ai/modelFeasibility.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T09:25:58.034013Z 692b65f Draft marked ready
ℹ️ About Codex in GitHub

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.

@tinysweeper

tinysweeper Bot commented Oct 28, 2026

Copy link
Copy Markdown

Tiny Sweeper review

⏳ Reviewing 692b65fbc51a now. The last completed report, when available, remains below until this pass finishes.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 692b65fbc5

ℹ️ About Codex in GitHub

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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +54 to +57
export function assessModelFeasibility<T extends FeasibilityModel>(
models: readonly T[],
requirements: ModelRequirements
): ModelFeasibilityReport<T> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move model feasibility policy into the Rust core

In the desktop Settings routing view, assessModelFeasibility now decides hard exclusions, unknown-price semantics, and rank order entirely in TypeScript. Those are model/cost business rules, so other hosts cannot reuse them and the result can already disagree with core accounting: crates/openhuman-core/src/agent/cost.rs::is_free_model recognizes :free as a known zero-cost route, while the new positive-price checks classify every consumed zero price as unknown. Expose this assessment from a core operation/RPC and keep React responsible only for presentation.

AGENTS.md reference: AGENTS.md:L53-L56

Useful? React with 👍 / 👎.

Comment on lines +15 to +18
const reasonLabels: Record<ModelFitReason, [string, string]> = {
context_too_small: [
'settings.ai.feasibility.contextTooSmall',
'Context smaller than input + output tokens',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Localize the entire feasibility surface

For any non-English locale, a repo-wide search of app/src/lib/i18n finds none of the new settings.ai.feasibility.* keys, so useT() resolves every new label and reason to these English fallbacks; positive costs also remain the literal English Est. $ emitted by formatEstimatedModelCost. Add real entries for every locale and localize the formatted output, otherwise switching locale leaves the whole new section in English.

AGENTS.md reference: AGENTS.md:L318-L319

Useful? React with 👍 / 👎.

<div className="grid grid-cols-2 gap-2 md:grid-cols-3 lg:grid-cols-5">
<label className="space-y-1 text-xs text-content-secondary">
<span>{t('settings.ai.feasibility.input', 'Estimated input tokens')}</span>
<input

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Build the preview with shared UI primitives

In the Settings routing panel this starts a set of raw <input> controls, followed by a raw checkbox, <select>, <button>, and hand-rolled bordered surfaces, despite existing TextField, Checkbox, NativeSelect, Button, Card, and accordion/collapsible primitives. This bypasses shared focus, sizing, theme, and accessibility behavior, so fixes to those primitives will not reach the new panel; rebuild it from the shared UI layer.

AGENTS.md reference: AGENTS.md:L327-L331

Useful? React with 👍 / 👎.

{t('settings.ai.feasibility.title', 'Model suitability and cost preview')}
</summary>
<div className="p-3 pt-0">
<ModelFeasibilityPreview models={draft.modelRegistry} />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Register the preview in the capability catalog

about_app is the source used by capability search and the About catalog, but the inspected settings.configure_ai entry in crates/openhuman-core/src/platform/about_app/catalog_localai_settings_mobile.rs:69-78 still mentions only providers and routing and gives no way to discover this model preview. Update that capability's description/how-to text or add a dedicated capability when adding this surface, otherwise the product capability catalog remains stale.

AGENTS.md reference: AGENTS.md:L385-L385

Useful? React with 👍 / 👎.

/>
))}
</WorkloadTable>
{!embedded && (

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add end-to-end coverage for the settings flow

The new Settings → LLM → Routing disclosure is only exercised by isolated Vitest renders; a repo-wide search of app/test/e2e/specs found no feasibility or suitability flow. Add a mocked browser/desktop test that navigates to this entry point, expands it, edits constraints, and confirms the embedded onboarding surface excludes it, because mounting the component alone does not verify the real route and tab integration.

AGENTS.md reference: AGENTS.md:L186-L187

Useful? React with 👍 / 👎.

export function formatEstimatedModelCost(cost: number | null): string {
if (cost === null || !Number.isFinite(cost) || cost < 0) return 'Cost unknown';
if (cost > 0 && cost < 0.0001) return '<$0.0001';
return 'Est. $' + cost.toFixed(4);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid rounding over-budget estimates down

When an estimate is only slightly above a user-entered budget—for example, 1,004 input tokens at $10/1M produces $0.01004 against a $0.01 limit—the row is marked excluded, but this formatter renders Est. $0.0100, making the displayed amount appear equal to the limit. Preserve enough precision or round upward so the shown cost explains why the model was excluded.

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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