Repository navigation
Studio: name a connected model the provider dropped instead of its raw id - #8470
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e594b7300
ℹ️ 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".
| if (externalModels.some((option) => option.id === selected)) { | ||
| return null; |
There was a problem hiding this comment.
Distinguish disabled models from provider-dropped models
When a user edits a connection, unchecks the currently selected model, and saves while leaving another model enabled, chat-providers-dialog.tsx removes that ID from provider.models even though it may remain in availableModels. Because externalModels contains only those enabled models, this check treats the intentionally disabled selection as provider-dropped and the picker falsely displays “ · no longer offered.” Use the available catalog or a neutral disabled/unavailable state rather than inferring provider removal solely from the enabled-option list.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed, and it is reachable. models holds the enabled set while availableModels holds the full fetched catalog, both persisted separately by the save path, and toggleModel does not protect the currently active selection. So unchecking the selected model leaves it in availableModels but out of models, and the picker would call a model the provider still offers "no longer offered". Fixing by consulting the cached catalog so a user-disabled selection gets its own neutral state.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fdd3bfb258
ℹ️ 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".
| (catalog != null && | ||
| catalog.length > 0 && | ||
| !catalog.includes(parsed.modelId)); |
There was a problem hiding this comment.
Treat removed manual model IDs as user-disabled
When the active model was manually entered for a catalog-capable connection such as Ollama, vLLM, llama.cpp, or OpenRouter, removing that ID and saving while leaving another model enabled reaches this condition with a non-empty catalog that never contained the manual ID. The new availableModels check therefore still labels the model as “no longer offered,” although chat-providers-dialog.tsx deliberately persists manual IDs only in models, not in availableModels. Preserve whether an ID was manually configured, or avoid interpreting catalog absence as provider withdrawal for connections that allow manual IDs.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct, and reproduced. Fixed in 0c3c974.
The asymmetry is exactly as you describe: modelsToSave unions the ticked ids with the manual ones (chat-providers-dialog.tsx:555-565) while availableModels is written as the fetched catalogue alone (:599-602 create, :727-730 update). Driving those shapes through the real helper: save Ollama with llama3.2 ticked and kimi-k2.5 typed, and the row is models: [llama3.2, kimi-k2.5], availableModels: [llama3.2]; delete the manual id and save, and the label comes back state: dropped for the user's own edit.
The scope is slightly wider than the manual box. OpenRouter is model_list_mode: curated (core/inference/providers.py:345), so the dialog takes the manualOnly branch and persists available_models: [], and sync-external-providers.ts:200-207 then backfills the registry's default_models. That shortlist was never a fetch result, so every model outside it read as withdrawn.
I took your second suggestion, phrased as the principle rather than a provider list: claim a withdrawal only when the catalogue could have carried the id in the first place, which is every connection whose dialog has no manual model-ID box beside the fetched list. allowsManualModelIdsWithCatalog is exactly that set.
I simulated the other two before choosing, and both lose on correctness rather than on size. Folding the manual ids into availableModels does fix the label, but the dialog reseeds by splitting models on catalogue membership (:810-826), so the id moves out of the textarea into the ticked list, and loadModels (:496-512) then drops it on the next Fetch Models: the user silently loses an id they typed. A persisted manual_models field does not fix the reported case at all, since the same save that removes the id from the textarea removes it from the new field; it would have to be an append-only tombstone of every id ever typed.
The cost, stated plainly: a model genuinely removed with ollama rm now reads "not enabled" rather than "no longer offered", and likewise for vLLM, llama.cpp, custom OpenAI-compatible and OpenRouter. The distinction survives for catalogue-only connections and for a connection that is gone entirely. That is the right side to err on, since "not enabled" is true whenever the id is absent from models, while "no longer offered" was sometimes a false accusation against a third party.
Six tests added, and the two existing dropped-state tests moved onto a catalogue-only fixture with their assertions intact rather than weakened, so 19 to 25 with none dropped. Reverting just the helper fails three of them. Full suite 1978 passed, typecheck clean, i18n:check:strict parity clean (no locale change was needed, both key pairs already existed).
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c3c974751
ℹ️ 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".
| // directly; an empty catalogue is unknown rather than empty, since a connection with no | ||
| // enabled models never gets one written. | ||
| const dropped = | ||
| connection == null || |
There was a problem hiding this comment.
Treat a removed connection separately from a dropped model
When the active connection is deleted, deleteProvider removes it from the providers store while the checkpoint remains intact—the clearing effect in chat-page.tsx only handles disabling Connections globally. Consequently connection == null is reached here and the picker claims the model is “no longer offered,” even though the user removed the entire connection and the provider may still offer the model. Classify this as a removed/disabled connection rather than a provider withdrawal.
Useful? React with 👍 / 👎.
| const catalogCoversEveryId = !allowsManualModelIdsWithCatalog( | ||
| connection?.providerType, |
There was a problem hiding this comment.
Treat Hugging Face's capped catalog as non-exhaustive
For a Hugging Face connection, this marks the catalog as exhaustive even though studio/backend/core/inference/providers.py sets model_id_limit to 15 and studio/backend/routes/providers.py explicitly returns the unsorted first 15 matches. If a previously selected, still-available model moves beyond that cutoff on a later fetch and the user saves another selection, it disappears from availableModels and is falsely labeled “no longer offered.” Exclude capped/filtered shortlist providers from the withdrawal inference just as OpenRouter is excluded.
Useful? React with 👍 / 👎.
…w id Fixes #8405. Fetch Models replaces a connection's model list wholesale and nothing reconciles the active pick against it, so a model the provider dropped leaves the picker's option list while its id stays in params.checkpoint. The picker trigger's fallback then ran modelDisplayName on that id, which is an exact identity function for external::<connectionId>::<modelId>: the id is neither path-shaped nor a org/name repo id, and buildExternalModelId percent-encodes the model id so there is no slash to split on. The chat header showed external::6235be0905af4221::kimi-k2.5. The trigger now parses the id, so it reads the model the user picked, and says the model is gone. A tidy name on its own would hide that the model cannot be loaded until the next send. The connection's display name comes from any sibling model still listed under the same connection id. Two other surfaces reach a raw external id and get the same treatment: the compare toasts, whose panes accept connected models and whose local split("/") helper returned the id whole, and the audio-attachment toast, which names the checkpoint when it cannot find a row in store.models.
The French pair dropped the mandatory ne, so "Plus proposé" carried no negative marker at all and read as the positive "more suggested", the opposite of what the line means. proposer is also the ordinary verb for "to suggest", and a picker is exactly where a user expects to see suggested models, so the misreading is available rather than theoretical. German, Spanish and Italian each said "no longer available" in the standalone form and "no longer offered" in the by-provider one. Those are different claims: unavailable reads as a transient outage the user should wait out, but the model was withdrawn from the connection's catalogue and waiting will not bring it back. The standalone fires when the connection dropped every model, which is still the provider's doing, so both forms now make the one claim the English source makes.
…opped The connection dialog saves the ticked model ids to `models` and the fetched catalogue to `availableModels`, and the picker's option list is flat-mapped from `models` alone. Unticking the active model while leaving another enabled therefore takes its option away exactly the way a withdrawal does, and the trigger said "<provider> · no longer offered" about a model the provider still offers and the user had merely turned off. `missingExternalModel` now also takes the connections, so it can read the cached catalogue, and it claims a withdrawal only on positive evidence: a catalogue that was stored, is non-empty, and does not list the model. A pick the catalogue still lists reads "<provider> · not enabled", which is the weaker claim and is true whenever the id is out of `models`. That weaker claim is also the fallback when the evidence is missing. A connection saved before `availableModels` existed carries no catalogue at all, and inferring a withdrawal from a list that never described the provider's catalogue is what produced the wrong label in the first place. A connection that is not in the list at all keeps the reading it has always had, since there is no connection left to attribute the state to. The compare toasts and the audio-attachment toast were checked and are unaffected: both only shorten the id to the model name and make no claim about whether the model is still on offer.
Ollama, vLLM, llama.cpp and OpenRouter take typed-in model IDs beside the fetched list, and the connection dialog saves those to `models` only: `modelsToSave` unions the ticked ids with the manual ones while `availableModels` is written as the fetched catalogue alone. Deleting such an ID and saving therefore reached the new catalogue check with a non-empty list that never carried the ID, and the picker read the user's own edit as "no longer offered". Claim a withdrawal only when the catalogue could have listed the model in the first place, which is every connection whose dialog has no manual model-ID box.
0c3c974 to
009515c
Compare
…8534) * Studio: drop the duplicated HubModelPicker import in model-selector model-selector.tsx imports HubModelPicker and hasDownloadedModels twice, identically, at lines 46 and 53. #8470 added the second copy. A repeated named import binds the same identifier twice in module scope, which is a hard error rather than a lint nit: tsc reports TS2300 Duplicate identifier, and the equivalent ESM is a SyntaxError, SyntaxError: Identifier 'readFileSync' has already been declared so the bundler rejects it too. That fails the frontend build during studio setup, before any test runs, which is why unrelated jobs have been red on every studio branch. Removing the earlier line rather than the later one keeps the import grouped with the other ./model-selector/* imports it belongs with. * Security audit: baseline the five reopened scan-packages findings openai 3.0.0 landed on the extras shard and pulled in httpx2 (the Pydantic-maintained httpx fork), and botocore/httpsession.py picked up a timeout kwarg, so five reviewed heuristic matches came back with new evidence hashes and failed all three pip scan-packages shards. Each one was re-reviewed against the published archive, and every flagged file was diffed byte-for-byte against its upstream source repo before being suppressed: - httpx2 2.10.0 httpx2/_models.py, "Enumerates filesystem AND makes network calls": RE_FS_ENUM's `history.*read` alternative matching the `history: list[Response] | None = None` Response kwarg, plus the urllib.request cookie-compat shim. All 30 .py files in the wheel are identical to pydantic/httpx2 v2.10.0. - openai 3.0.0 openai/_base_client.py, "C2 polling/beaconing loop": `while True:` in SyncPage.iter_pages, the pagination generator. - openai 3.0.0 openai/auth/_workload.py, "Accesses cloud metadata / IMDS endpoints": the Azure managed-identity and GCP instance-identity token providers behind workload identity federation. This file was already baselined under the combined IMDS+network check; it now fires the standalone IMDS check because RE_NETWORK does not recognise `httpx2.` calls. - unsloth-zoo 2026.8.10 unsloth_zoo/device_map_planner.py, "Advanced obfuscation + exec/eval": `__import__` of two literal module paths in the compute_module_sizes lookup, and `model.eval()`, which is the PyTorch eval mode, not eval(). - botocore 1.43.69 botocore/httpsession.py, "Harvests environment variables/secrets AND makes network calls": the standard SSLKEYLOGFILE support plus urlopen in URLLib3Session.send. The evidence changed because the urlopen call now takes **extra_kwargs for the per-request timeout. - pandas 2.3.3 pandas/tests/io/test_pickle.py, "Creates archive with sensitive data AND makes network calls": tarfile.open in the compression test helper plus a monkeypatched urllib.request.urlopen. The six entries are appended by hand with evidence_hash computed by scan_packages._evidence_hash over the scanner's own evidence, so the existing 218 entries are untouched (218 -> 224). Verified locally with `scan_packages.py --with-deps` over the CI-identical audit-reqs files: extras and hf-stack now exit 0.
model-selector.tsx imports HubModelPicker and hasDownloadedModels twice from ./model-selector/pickers, so tsc fails with TS2300 Duplicate identifier and the vite build exits 2. That takes down the Tauri Linux debug build, and both the linux and mac install jobs, which run studio setup and hit the same npm run build. Introduced by #8470, which added the second copy above the pill-tabs import while the first was already sitting above the missing-external-model import. Keep the copy that sits in the existing alphabetical order inside the ./model-selector/ group and remove the stray one.
Seven times now a whole-file scan has been reported for calling valid TypeScript a duplicate: source quoted inside a test fixture, a backtick inside a regex pairing with a later template, a code sample rendered as JSX text, a module-level JSX initializer with no wrapping parentheses, a nested template, and JSX text after an expression container. Each fix was correct and the next hole was already there. The shape of the problem is that reading TypeScript as raw text needs a lexer, and half a lexer keeps finding new ways to be wrong in the direction that stops other people's work, since this gate runs unconditionally on Source lint. So the scan is bounded instead. It reads the import prologue, meaning the run of imports, comments and directives at the top of the file, and stops at the first statement that is not one. A prologue cannot contain a template, a regex or JSX, so nothing that merely looks like an import can appear in it, and all seven become impossible rather than handled. The masking, the regex recogniser, the bracket-depth rule and the statement-boundary rule all go with it: 362 lines removed, 125 added. The cost is stated rather than hidden. An import written after other top-level code is not read, so a duplicate involving one is missed: 611 of 9801 import declarations here, across 19 files. That is a false negative, which leaves the build where it was before this check existed and which tsc still catches. A false positive fails CI on correct code. Given the choice, this misses those. 19 self-test cases. The six false positives above are kept as cases, so a later change that widens the scan fails here rather than in CI, and so is the stated cost, so it stays a decision rather than a surprise. The #8470 regression is still caught verbatim, the live tree is clean across 2238 files, and a real duplicate planted in a file full of fixtures is still reported on the right line.
…8548) * Remove the duplicate import that fails every frontend build unslothai#8470 added a second import { HubModelPicker, hasDownloadedModels } from "./model-selector/pickers"; to model-selector.tsx, seven lines below the one already there. tsc rejects it with TS2300 Duplicate identifier, so npm run build fails, so the Build frontend step fails, and every job that builds the frontend goes red behind it: Chat UI Tests, GGUF inference smoke, Tool calling, Unsloth API and Auth, the wheel build, the no-Visual-Studio install, and the rest. On main and on every open PR. Nothing caught it earlier. eslint is not run in CI at all, and its config does not enable no-duplicate-imports in any case, so the first sign was a tsc error inside the slowest job in the matrix. scripts/lint_no_duplicate_ts_imports.py is the cheap version of that check, wired into Source lint next to the other safety nets: it scans the import prologue of every committed .ts/.tsx file and reports any local binding name introduced twice. No npm, no node, no type information. It parses the four binding forms (default, namespace, named, aliased), treats import type as binding the same way a value import does, and skips side-effect imports, which bind nothing. Two imports of the same module under different names stay legal, so the module path is not what it compares. --self-test covers ten cases including this regression verbatim, and reverting the one-line fix turns the scan red on exactly the two names. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Scan every TypeScript project the frontend build compiles The gate only looked at studio/frontend/src, but npm run build is tsc -b and npm run typecheck adds tsc -p tsconfig.test.json, so vite.config.ts (tsconfig.node.json) and tests (tsconfig.test.json) compile too. A duplicate import in either passed this step and still failed the frontend build, which is the failure the step exists to catch first. Scan the frontend root instead; node_modules, dist and build are already skipped, and the 1398 files it now covers are clean. * Drop comments from an import clause before reading its bindings * Read a wrapped alias and a relative scan path correctly * Trim the duplicate-import lint comments to the rationale * Trim the lint step comments in the workflow * Read a type modifier followed by any whitespace The inline and clause-level `type` modifiers were stripped with a literal "type " prefix test, so a specifier wrapped as `type\n Foo` kept its modifier and `piece.split()[0]` recorded `type` as the binding. Two of those in one file report `type` as a duplicate and fail Source lint on a file tsc compiles cleanly, and a wrapped modifier also hid a real duplicate, since the binding recorded was never the imported name. tsc 7.0.2 accepts all three shapes (`type` + newline, `type` + tab, and `import type` + newline before the brace) with exit 0 and no TS2300; any whitespace is legal after the modifier. Both strips now go through one `^type\s+` pattern. Three self-test cases cover the two false positives and the missed duplicate. * Do not read a quoted TypeScript fixture as an import The scan read the raw file, so a test fixture holding TypeScript inside a template literal was read as imports of the enclosing file. Two fixtures quoting the same module then looked like a duplicate, and on today's main the gate reports six of these across two frontend test files, all of them source held as data. A gate that fails CI on code tsc accepts is worse than no gate, so this had to be fixed before the gate could land. Comment and string bodies are blanked before the scan, with the character count and every newline kept so the reported line numbers still point at the real source. Module specifiers survive as whitespace inside their quotes and still match, so the masking cannot hide a genuine import. A block comment is covered for the same reason: commented-out imports are not imports. Five self-test cases, including a real duplicate sitting after a fixture, a backtick inside an ordinary string, and an escaped backtick that does not close its template. 21 cases in total, and the live tree is clean across 2238 files. * Recognise regex literals, which did not fail open as claimed The masker left regex literals out and the comment said that could only miss a duplicate. That was wrong. `const BACKTICK = /`/g;` is real code in studio/frontend/src/lib/release-notes-preview.ts, and an unrecognised backtick there pairs with the opener of the next real template, so the masking lands on the gap between them and leaves the fixture exposed. The gate then invents a duplicate on a file tsc accepts, which is the failure direction that matters for something wired into an unconditional lint gate. Telling a regex from a division needs the previous token, since `/` is both. The usual test: after a value, so an identifier, a literal or a closing bracket, it divides; anywhere else it opens a regex, with the operator keywords that end in identifier characters listed by name. A character class can hold an unescaped `/`, so the scan tracks `[...]`, and a regex that reaches a newline is treated as a division after all rather than masking to the end of the file. Six more self-test cases covering both directions, 27 in total. The live tree stays clean across 2238 files and a real duplicate in real code is still caught. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Do not read a declaration where the language would not allow one A component can render a code sample as element text: export function Sample() { return ( <pre> import Widget from "a"; </pre> ); } TypeScript reads those lines as JSX text and accepts the file, and they are unindented because indentation would show up in what the page renders, so anchoring to the start of the line does not separate them from real imports. An import declaration is only legal at the top level of a module, so what does separate them is that these sit inside the function body and the parenthesised return. Brackets are counted over the masked source, where strings, comments and regexes are already gone, and a match inside any bracket is skipped. This is not JSX recognition and does not pretend to be. It declines to read a declaration anywhere the grammar would not allow one, which covers the reported case and leaves real imports untouched. Two more self-test cases, 29 in total: the sample above, and a real duplicate sitting after such a component. Live tree clean across 2238 files. * Require an import to start a statement, and read a control head's parens Two more ways to be read as an import while tsc reads something else. Bracket depth does not separate a module-level JSX initializer written without wrapping parentheses, because JSX tags are not brackets: `const sample = <pre>` followed by import-shaped text leaves the depth at zero. What does separate it is that those lines start no statement. The character before a real import, once trivia is skipped, is the start of the file, the end of a previous statement, or the closing quote of a module specifier, which is how the previous import ends in a file that omits semicolons. JSX text is preceded by `>`, which ends nothing. Measured against the tree before adopting it: of the 9801 imports the scanner accepts today, that rule keeps 9801 and rejects none. A regex after an unbraced control head, `if (ok) /`/.test(text);`, was read as a division because of the closing paren. A control statement's parentheses produce no value, so the scan now walks back to the matching `(` and reads the word in front of it. Five more self-test cases, 34 in total, including a division after a call, a file that omits semicolons, and an import after a function declaration, so the new rule cannot be satisfied by quietly ignoring more. Live tree clean across 2238 files. * Read only the import prologue, and stop hand-lexing TypeScript Seven times now a whole-file scan has been reported for calling valid TypeScript a duplicate: source quoted inside a test fixture, a backtick inside a regex pairing with a later template, a code sample rendered as JSX text, a module-level JSX initializer with no wrapping parentheses, a nested template, and JSX text after an expression container. Each fix was correct and the next hole was already there. The shape of the problem is that reading TypeScript as raw text needs a lexer, and half a lexer keeps finding new ways to be wrong in the direction that stops other people's work, since this gate runs unconditionally on Source lint. So the scan is bounded instead. It reads the import prologue, meaning the run of imports, comments and directives at the top of the file, and stops at the first statement that is not one. A prologue cannot contain a template, a regex or JSX, so nothing that merely looks like an import can appear in it, and all seven become impossible rather than handled. The masking, the regex recogniser, the bracket-depth rule and the statement-boundary rule all go with it: 362 lines removed, 125 added. The cost is stated rather than hidden. An import written after other top-level code is not read, so a duplicate involving one is missed: 611 of 9801 import declarations here, across 19 files. That is a false negative, which leaves the build where it was before this check existed and which tsc still catches. A false positive fails CI on correct code. Given the choice, this misses those. 19 self-test cases. The six false positives above are kept as cases, so a later change that widens the scan fails here rather than in CI, and so is the stated cost, so it stays a decision rather than a surprise. The unslothai#8470 regression is still caught verbatim, the live tree is clean across 2238 files, and a real duplicate planted in a file full of fixtures is still reported on the right line. --------- Co-authored-by: danielhanchen <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…8548) * Remove the duplicate import that fails every frontend build unslothai#8470 added a second import { HubModelPicker, hasDownloadedModels } from "./model-selector/pickers"; to model-selector.tsx, seven lines below the one already there. tsc rejects it with TS2300 Duplicate identifier, so npm run build fails, so the Build frontend step fails, and every job that builds the frontend goes red behind it: Chat UI Tests, GGUF inference smoke, Tool calling, Unsloth API and Auth, the wheel build, the no-Visual-Studio install, and the rest. On main and on every open PR. Nothing caught it earlier. eslint is not run in CI at all, and its config does not enable no-duplicate-imports in any case, so the first sign was a tsc error inside the slowest job in the matrix. scripts/lint_no_duplicate_ts_imports.py is the cheap version of that check, wired into Source lint next to the other safety nets: it scans the import prologue of every committed .ts/.tsx file and reports any local binding name introduced twice. No npm, no node, no type information. It parses the four binding forms (default, namespace, named, aliased), treats import type as binding the same way a value import does, and skips side-effect imports, which bind nothing. Two imports of the same module under different names stay legal, so the module path is not what it compares. --self-test covers ten cases including this regression verbatim, and reverting the one-line fix turns the scan red on exactly the two names. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Scan every TypeScript project the frontend build compiles The gate only looked at studio/frontend/src, but npm run build is tsc -b and npm run typecheck adds tsc -p tsconfig.test.json, so vite.config.ts (tsconfig.node.json) and tests (tsconfig.test.json) compile too. A duplicate import in either passed this step and still failed the frontend build, which is the failure the step exists to catch first. Scan the frontend root instead; node_modules, dist and build are already skipped, and the 1398 files it now covers are clean. * Drop comments from an import clause before reading its bindings * Read a wrapped alias and a relative scan path correctly * Trim the duplicate-import lint comments to the rationale * Trim the lint step comments in the workflow * Read a type modifier followed by any whitespace The inline and clause-level `type` modifiers were stripped with a literal "type " prefix test, so a specifier wrapped as `type\n Foo` kept its modifier and `piece.split()[0]` recorded `type` as the binding. Two of those in one file report `type` as a duplicate and fail Source lint on a file tsc compiles cleanly, and a wrapped modifier also hid a real duplicate, since the binding recorded was never the imported name. tsc 7.0.2 accepts all three shapes (`type` + newline, `type` + tab, and `import type` + newline before the brace) with exit 0 and no TS2300; any whitespace is legal after the modifier. Both strips now go through one `^type\s+` pattern. Three self-test cases cover the two false positives and the missed duplicate. * Do not read a quoted TypeScript fixture as an import The scan read the raw file, so a test fixture holding TypeScript inside a template literal was read as imports of the enclosing file. Two fixtures quoting the same module then looked like a duplicate, and on today's main the gate reports six of these across two frontend test files, all of them source held as data. A gate that fails CI on code tsc accepts is worse than no gate, so this had to be fixed before the gate could land. Comment and string bodies are blanked before the scan, with the character count and every newline kept so the reported line numbers still point at the real source. Module specifiers survive as whitespace inside their quotes and still match, so the masking cannot hide a genuine import. A block comment is covered for the same reason: commented-out imports are not imports. Five self-test cases, including a real duplicate sitting after a fixture, a backtick inside an ordinary string, and an escaped backtick that does not close its template. 21 cases in total, and the live tree is clean across 2238 files. * Recognise regex literals, which did not fail open as claimed The masker left regex literals out and the comment said that could only miss a duplicate. That was wrong. `const BACKTICK = /`/g;` is real code in studio/frontend/src/lib/release-notes-preview.ts, and an unrecognised backtick there pairs with the opener of the next real template, so the masking lands on the gap between them and leaves the fixture exposed. The gate then invents a duplicate on a file tsc accepts, which is the failure direction that matters for something wired into an unconditional lint gate. Telling a regex from a division needs the previous token, since `/` is both. The usual test: after a value, so an identifier, a literal or a closing bracket, it divides; anywhere else it opens a regex, with the operator keywords that end in identifier characters listed by name. A character class can hold an unescaped `/`, so the scan tracks `[...]`, and a regex that reaches a newline is treated as a division after all rather than masking to the end of the file. Six more self-test cases covering both directions, 27 in total. The live tree stays clean across 2238 files and a real duplicate in real code is still caught. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Do not read a declaration where the language would not allow one A component can render a code sample as element text: export function Sample() { return ( <pre> import Widget from "a"; </pre> ); } TypeScript reads those lines as JSX text and accepts the file, and they are unindented because indentation would show up in what the page renders, so anchoring to the start of the line does not separate them from real imports. An import declaration is only legal at the top level of a module, so what does separate them is that these sit inside the function body and the parenthesised return. Brackets are counted over the masked source, where strings, comments and regexes are already gone, and a match inside any bracket is skipped. This is not JSX recognition and does not pretend to be. It declines to read a declaration anywhere the grammar would not allow one, which covers the reported case and leaves real imports untouched. Two more self-test cases, 29 in total: the sample above, and a real duplicate sitting after such a component. Live tree clean across 2238 files. * Require an import to start a statement, and read a control head's parens Two more ways to be read as an import while tsc reads something else. Bracket depth does not separate a module-level JSX initializer written without wrapping parentheses, because JSX tags are not brackets: `const sample = <pre>` followed by import-shaped text leaves the depth at zero. What does separate it is that those lines start no statement. The character before a real import, once trivia is skipped, is the start of the file, the end of a previous statement, or the closing quote of a module specifier, which is how the previous import ends in a file that omits semicolons. JSX text is preceded by `>`, which ends nothing. Measured against the tree before adopting it: of the 9801 imports the scanner accepts today, that rule keeps 9801 and rejects none. A regex after an unbraced control head, `if (ok) /`/.test(text);`, was read as a division because of the closing paren. A control statement's parentheses produce no value, so the scan now walks back to the matching `(` and reads the word in front of it. Five more self-test cases, 34 in total, including a division after a call, a file that omits semicolons, and an import after a function declaration, so the new rule cannot be satisfied by quietly ignoring more. Live tree clean across 2238 files. * Read only the import prologue, and stop hand-lexing TypeScript Seven times now a whole-file scan has been reported for calling valid TypeScript a duplicate: source quoted inside a test fixture, a backtick inside a regex pairing with a later template, a code sample rendered as JSX text, a module-level JSX initializer with no wrapping parentheses, a nested template, and JSX text after an expression container. Each fix was correct and the next hole was already there. The shape of the problem is that reading TypeScript as raw text needs a lexer, and half a lexer keeps finding new ways to be wrong in the direction that stops other people's work, since this gate runs unconditionally on Source lint. So the scan is bounded instead. It reads the import prologue, meaning the run of imports, comments and directives at the top of the file, and stops at the first statement that is not one. A prologue cannot contain a template, a regex or JSX, so nothing that merely looks like an import can appear in it, and all seven become impossible rather than handled. The masking, the regex recogniser, the bracket-depth rule and the statement-boundary rule all go with it: 362 lines removed, 125 added. The cost is stated rather than hidden. An import written after other top-level code is not read, so a duplicate involving one is missed: 611 of 9801 import declarations here, across 19 files. That is a false negative, which leaves the build where it was before this check existed and which tsc still catches. A false positive fails CI on correct code. Given the choice, this misses those. 19 self-test cases. The six false positives above are kept as cases, so a later change that widens the scan fails here rather than in CI, and so is the stated cost, so it stays a decision rather than a surprise. The unslothai#8470 regression is still caught verbatim, the live tree is clean across 2238 files, and a real duplicate planted in a file full of fixtures is still reported on the right line. --------- Co-authored-by: danielhanchen <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fixes #8405.
The bug
Select a model from a connection, then go to Connections and Fetch Models on that provider at a point where it no longer offers the selected model. The chat header shows:
Why
Fetch Models replaces a connection's model list wholesale and nothing reconciles the active pick against it.
chat-page.tsxclears an external checkpoint only when Connections are turned off, so the id survives inparams.checkpointwith no catalog entry behind it, and the picker trigger falls through to its generic fallback inmodel-selector.tsx.That fallback is
modelDisplayName, which is an exact identity function for this input.buildExternalModelIdpercent-encodes the model id, so the string holds no literal/:isHubRepoIdis false,looksLikeModelPathis false, andclean.slice(clean.lastIndexOf("/") + 1)returns the whole thing.The fix
The trigger parses the id before naming it, so the pill reads the model the user actually picked, and it says the model is gone. A tidy name on its own would be worse than the raw id: the model cannot be loaded, so the failure would stay hidden until the next send. The connection's display name comes from any sibling model still listed under the same connection id; a connection that dropped every model falls back to "No longer offered".
Deliberately not changed: the loaded tick stays, because it is also the eject control, and clearing a dead selection in one click is the useful action here. Nor does this prune the stale checkpoint on refresh: a provider fetch that errors or returns partial results would then silently destroy the user's pick.
Two other surfaces reach a raw
external::id and get the same treatment:shared-composer.tsx). The compare pane headers accept connected models and the send path has no external guard, so the localid.split("/")helper returned the id whole. Replaced with a shared helper that parses first.store.models, so "<model> cannot accept audio" named the raw checkpoint.The transformers-upgrade and remote-code toasts use the same helper but are not reachable with an external id: they need a successful
/api/inference/validate, which 400s on anexternal::identifier.Before and after
Captured on two isolated installs, the merge base and this branch, with an Ollama connection registered through
/api/providers/whose model list does not contain the selected model.BEFORE: the pill prints
external::dafd9a8e229f474b::kimi-k2.5.AFTER: the pill reads
kimi-k2.5withOllama · no longer offered.Tests
studio/frontend/tests/external-model-selection-label.test.ts, 12 new cases: the frontend suite goes 1953 to 1965, all passing. They cover the parse, the sibling lookup for the connection name, the connection that dropped every model, percent-encoded ids, the still-offered case, non-external selections left to the generic helper, and the wiring at each of the three call sites. Reverting any single source file in this PR turns one of them red.npm run typecheckandnpm run i18n:check:strictare clean; the two newpicker.*strings are translated in all 12 locales, as check-parity requires.