Skip to content

Commit 267fed1

Browse files
committed
refactor: route runtime status marker helper
1 parent 2eefa7d commit 267fed1

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

index.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -407,11 +407,6 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
407407
return applyUiRuntimeFromConfig(loadPluginConfig());
408408
};
409409

410-
const getStatusMarker = (
411-
ui: UiRuntimeOptions,
412-
status: "ok" | "warning" | "error",
413-
): string => getRuntimeStatusMarker(ui, status);
414-
415410
const invalidateAccountManagerCache = (): void => {
416411
cachedAccountManager = null;
417412
accountManagerPromise = null;
@@ -3894,7 +3889,7 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
38943889
"",
38953890
formatUiItem(
38963891
ui,
3897-
`${getStatusMarker(ui, "ok")} Switched to ${label}`,
3892+
`${getRuntimeStatusMarker(ui, "ok")} Switched to ${label}`,
38983893
"success",
38993894
),
39003895
].join("\n");
@@ -4309,20 +4304,20 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
43094304
const refreshResult = await queuedRefresh(account.refreshToken);
43104305
if (refreshResult.type === "success") {
43114306
results.push(
4312-
` ${getStatusMarker(ui, "ok")} ${label}: Healthy`,
4307+
` ${getRuntimeStatusMarker(ui, "ok")} ${label}: Healthy`,
43134308
);
43144309
healthyCount++;
43154310
} else {
43164311
results.push(
4317-
` ${getStatusMarker(ui, "error")} ${label}: Token refresh failed`,
4312+
` ${getRuntimeStatusMarker(ui, "error")} ${label}: Token refresh failed`,
43184313
);
43194314
unhealthyCount++;
43204315
}
43214316
} catch (error) {
43224317
const errorMsg =
43234318
error instanceof Error ? error.message : String(error);
43244319
results.push(
4325-
` ${getStatusMarker(ui, "error")} ${label}: Error - ${errorMsg.slice(0, 120)}`,
4320+
` ${getRuntimeStatusMarker(ui, "error")} ${label}: Error - ${errorMsg.slice(0, 120)}`,
43264321
);
43274322
unhealthyCount++;
43284323
}
@@ -4470,7 +4465,7 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
44704465
"",
44714466
formatUiItem(
44724467
ui,
4473-
`${getStatusMarker(ui, "ok")} Removed: ${label}`,
4468+
`${getRuntimeStatusMarker(ui, "ok")} Removed: ${label}`,
44744469
"success",
44754470
),
44764471
remaining > 0
@@ -4536,20 +4531,20 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
45364531
account.accessToken = refreshResult.access;
45374532
account.expiresAt = refreshResult.expires;
45384533
results.push(
4539-
` ${getStatusMarker(ui, "ok")} ${label}: Refreshed`,
4534+
` ${getRuntimeStatusMarker(ui, "ok")} ${label}: Refreshed`,
45404535
);
45414536
refreshedCount++;
45424537
} else {
45434538
results.push(
4544-
` ${getStatusMarker(ui, "error")} ${label}: Failed - ${refreshResult.message ?? refreshResult.reason}`,
4539+
` ${getRuntimeStatusMarker(ui, "error")} ${label}: Failed - ${refreshResult.message ?? refreshResult.reason}`,
45454540
);
45464541
failedCount++;
45474542
}
45484543
} catch (error) {
45494544
const errorMsg =
45504545
error instanceof Error ? error.message : String(error);
45514546
results.push(
4552-
` ${getStatusMarker(ui, "error")} ${label}: Error - ${errorMsg.slice(0, 120)}`,
4547+
` ${getRuntimeStatusMarker(ui, "error")} ${label}: Error - ${errorMsg.slice(0, 120)}`,
45534548
);
45544549
failedCount++;
45554550
}
@@ -4600,7 +4595,7 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
46004595
"",
46014596
formatUiItem(
46024597
ui,
4603-
`${getStatusMarker(ui, "ok")} Exported ${count} account(s)`,
4598+
`${getRuntimeStatusMarker(ui, "ok")} Exported ${count} account(s)`,
46044599
"success",
46054600
),
46064601
formatUiKeyValue(ui, "Path", filePath, "muted"),
@@ -4616,7 +4611,7 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
46164611
"",
46174612
formatUiItem(
46184613
ui,
4619-
`${getStatusMarker(ui, "error")} Export failed`,
4614+
`${getRuntimeStatusMarker(ui, "error")} Export failed`,
46204615
"danger",
46214616
),
46224617
formatUiKeyValue(ui, "Error", msg, "danger"),
@@ -4656,7 +4651,7 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
46564651
"",
46574652
formatUiItem(
46584653
ui,
4659-
`${getStatusMarker(ui, "ok")} Import complete`,
4654+
`${getRuntimeStatusMarker(ui, "ok")} Import complete`,
46604655
"success",
46614656
),
46624657
formatUiKeyValue(ui, "Path", filePath, "muted"),
@@ -4691,7 +4686,7 @@ export const OpenAIOAuthPlugin: Plugin = async ({ client }: PluginInput) => {
46914686
"",
46924687
formatUiItem(
46934688
ui,
4694-
`${getStatusMarker(ui, "error")} Import failed`,
4689+
`${getRuntimeStatusMarker(ui, "error")} Import failed`,
46954690
"danger",
46964691
),
46974692
formatUiKeyValue(ui, "Error", msg, "danger"),

0 commit comments

Comments
 (0)