Skip to content

Commit d52b1b1

Browse files
committed
Clarify provider CLI detection source
1 parent ffb8fe5 commit d52b1b1

1 file changed

Lines changed: 56 additions & 22 deletions

File tree

apps/web/src/routes/_chat.settings.tsx

Lines changed: 56 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ const TIMESTAMP_FORMAT_LABELS = {
8282
const PROVIDER_STATUS_AUTO_REFRESH_DEBOUNCE_MS = 300;
8383

8484
type InstallBinarySettingsKey = "claudeBinaryPath" | "codexBinaryPath";
85+
type ProviderCliSource = "override" | "path";
86+
8587
type InstallProviderSettings = {
8688
provider: ProviderKind;
8789
title: string;
@@ -143,6 +145,43 @@ function providerStatusSummary(status: ServerProviderStatus | undefined): string
143145
return "Error";
144146
}
145147

148+
function providerStatusListMessage(status: ServerProviderStatus | undefined): string | null {
149+
if (!status || status.status === "ready" || status.authStatus === "unauthenticated") {
150+
return null;
151+
}
152+
if (!status.available) {
153+
return null;
154+
}
155+
return status.message ?? null;
156+
}
157+
158+
function resolveProviderCliSource(binaryPathValue: string): ProviderCliSource {
159+
return binaryPathValue.trim().length > 0 ? "override" : "path";
160+
}
161+
162+
function providerCliSourceLabel(source: ProviderCliSource): string {
163+
return source === "override" ? "Override" : "PATH";
164+
}
165+
166+
function providerCliDetectionDescription(
167+
status: ServerProviderStatus | undefined,
168+
source: ProviderCliSource,
169+
): string {
170+
if (!status) {
171+
return source === "override"
172+
? "Use Refresh to check whether the configured binary path override is available."
173+
: "Use Refresh to check whether the default CLI is available on your PATH.";
174+
}
175+
if (status.available) {
176+
return source === "override"
177+
? "The configured binary path override was detected and will be used for new sessions."
178+
: "The default CLI was detected on your PATH and will be used for new sessions.";
179+
}
180+
return source === "override"
181+
? "The configured binary path override could not be detected. Check the path below or clear it to fall back to your PATH."
182+
: "The default CLI could not be detected on your PATH.";
183+
}
184+
146185
function shouldShowProviderAlert(status: ServerProviderStatus | undefined): boolean {
147186
if (!status) return false;
148187
return !status.available || status.authStatus === "unauthenticated";
@@ -157,9 +196,12 @@ function providerAlertTitle(status: ServerProviderStatus | undefined): string {
157196
function providerAlertDescription(
158197
providerTitle: string,
159198
status: ServerProviderStatus | undefined,
199+
source: ProviderCliSource,
160200
): string {
161201
if (!status || !status.available) {
162-
return "The default CLI for this provider could not be detected on your PATH. Install it, update your PATH, or use the binary path override below for new sessions.";
202+
return source === "override"
203+
? "The configured binary path override for this provider could not be detected. Update the path below or clear it to fall back to your PATH."
204+
: "The default CLI for this provider could not be detected on your PATH. Install it, update your PATH, or use the binary path override below for new sessions.";
163205
}
164206
if (status.authStatus === "unauthenticated") {
165207
return `Log in to ${providerTitle} to start using its models.`;
@@ -895,6 +937,7 @@ function SettingsRouteView() {
895937
installProviderSettings.binaryPathKey === "claudeBinaryPath"
896938
? claudeBinaryPath
897939
: codexBinaryPath;
940+
const cliSource = resolveProviderCliSource(binaryPathValue);
898941
const isInstallOverrideDirty =
899942
providerSettings.provider === "codex"
900943
? settings.codexBinaryPath !== defaults.codexBinaryPath ||
@@ -928,6 +971,7 @@ function SettingsRouteView() {
928971
refreshProviderStatusMutation.isPending &&
929972
refreshProviderStatusMutation.variables === providerSettings.provider;
930973
const showProviderAlert = shouldShowProviderAlert(providerStatus);
974+
const providerListMessage = providerStatusListMessage(providerStatus);
931975
return (
932976
<Collapsible
933977
key={providerSettings.provider}
@@ -974,11 +1018,7 @@ function SettingsRouteView() {
9741018
</div>
9751019
<p className="mt-1 text-xs text-muted-foreground">
9761020
{isDisabled ? "Disabled" : providerStatusSummary(providerStatus)}
977-
{providerStatus?.message &&
978-
providerStatus.status !== "ready" &&
979-
providerStatus.authStatus !== "unauthenticated" ? (
980-
<> - {providerStatus.message}</>
981-
) : null}
1021+
{providerListMessage ? <> - {providerListMessage}</> : null}
9821022
</p>
9831023
</div>
9841024
<ChevronDownIcon
@@ -1005,7 +1045,11 @@ function SettingsRouteView() {
10051045
{providerAlertTitle(providerStatus)}
10061046
</p>
10071047
<p className="mt-0.5 text-xs opacity-80">
1008-
{providerAlertDescription(providerSettings.title, providerStatus)}
1048+
{providerAlertDescription(
1049+
providerSettings.title,
1050+
providerStatus,
1051+
cliSource,
1052+
)}
10091053
</p>
10101054
</div>
10111055
</div>
@@ -1215,16 +1259,8 @@ function SettingsRouteView() {
12151259
</SettingsRow>
12161260

12171261
<SettingsRow
1218-
title="CLI on PATH"
1219-
description={
1220-
providerStatus == null
1221-
? "Use Refresh to check whether the default CLI is available on your PATH."
1222-
: isCliDetected
1223-
? "The default CLI was detected on your PATH."
1224-
: binaryPathValue.trim().length > 0
1225-
? "The default CLI was not found on your PATH. New sessions can still use the binary path override below."
1226-
: (providerStatus.message ?? "Not found on your PATH.")
1227-
}
1262+
title="CLI detected"
1263+
description={providerCliDetectionDescription(providerStatus, cliSource)}
12281264
control={
12291265
<div className="flex items-center gap-2">
12301266
<span
@@ -1241,10 +1277,8 @@ function SettingsRouteView() {
12411277
{providerStatus == null
12421278
? "Unknown"
12431279
: isCliDetected
1244-
? "Yes"
1245-
: binaryPathValue.trim().length > 0
1246-
? "No (override set)"
1247-
: "No"}
1280+
? `Yes (${providerCliSourceLabel(cliSource)})`
1281+
: `No (${providerCliSourceLabel(cliSource)})`}
12481282
</code>
12491283
</div>
12501284
}
@@ -1253,7 +1287,7 @@ function SettingsRouteView() {
12531287
{isCliDetected && providerStatus?.version ? (
12541288
<SettingsRow
12551289
title="CLI version"
1256-
description="Version reported by the provider CLI."
1290+
description="Version reported by the active provider CLI."
12571291
control={
12581292
<code className="text-xs font-medium text-muted-foreground">
12591293
{providerStatus.version}

0 commit comments

Comments
 (0)