fix(app): open sole provider model picker directly

Running chats expose one provider, so an intermediate provider screen and back action are redundant. Restore the direct model-list entry behavior while preserving the multi-provider picker.
This commit is contained in:
Mohamed Boudra
2026-08-13 20:34:21 +02:00
parent 6a1cc98fdf
commit a732cc5756
4 changed files with 16 additions and 30 deletions
@@ -70,7 +70,7 @@ describe("model browser initial view", () => {
).toEqual({ kind: "all" });
});
it("keeps the root even when a single provider would otherwise be skipped", () => {
it("opens a sole provider directly regardless of root content", () => {
expect(
resolveInitialModelBrowserView({
providers: [pi],
@@ -78,7 +78,7 @@ describe("model browser initial view", () => {
selectedModel: "pi-pro",
hasProfiles: true,
}),
).toEqual({ kind: "all" });
).toEqual({ kind: "provider", providerId: "pi", providerLabel: "Pi" });
});
it("falls back to the root when the selected provider is gone", () => {
@@ -32,11 +32,7 @@ export function resolveModelBrowserAllView({
return { kind: "searchResults", rows };
}
/**
* Where the picker lands when it opens. Agent profiles live on the root view, so
* a host that has any profile always opens there — including the single-provider
* case, which would otherwise skip the root entirely and hide them.
*/
/** Where the picker lands when it opens. A sole provider skips the redundant root view. */
export function resolveInitialModelBrowserView({
providers,
selectedProvider,
@@ -48,10 +44,6 @@ export function resolveInitialModelBrowserView({
selectedModel: string;
hasProfiles: boolean;
}): ModelBrowserView {
if (hasProfiles) {
return { kind: "all" };
}
const singleProvider = providers.length === 1 ? providers[0] : undefined;
if (singleProvider) {
return {
@@ -61,6 +53,10 @@ export function resolveInitialModelBrowserView({
};
}
if (hasProfiles) {
return { kind: "all" };
}
if (selectedProvider.length > 0 && selectedModel.length > 0) {
const provider = providers.find((entry) => entry.id === selectedProvider);
if (provider) {
@@ -292,9 +292,7 @@ export function useModelBrowser({
setSearchQuery(value);
}, []);
// A pinned profiles section makes the root worth returning to, so the back
// affordance stays even when the drill-down was the only provider.
const singleProviderView = providers.length === 1 && !hasProfiles;
const singleProviderView = providers.length === 1;
const header = useMemo<SheetHeader>(() => {
if (view.kind === "all") {
return {