refactor(coding-agent): extract /fast status label into a helper
Addresses Copilot review on #2522: the nested ternary building the /fast status label was duplicated across the ACP and TUI handlers. Extracted formatFastModeStatus(session) (a switch over serviceTier) so the wording stays consistent and new tiers/scopes are added in one place. No behavior change.
This commit is contained in:
@@ -62,6 +62,19 @@ function refreshStatusLine(ctx: InteractiveModeContext): void {
|
||||
ctx.ui.requestRender();
|
||||
}
|
||||
|
||||
/** `/fast status` label: "off", "on", or scope-qualified "on (… only)". */
|
||||
function formatFastModeStatus(session: AgentSession): string {
|
||||
if (!session.isFastModeEnabled()) return "off";
|
||||
switch (session.serviceTier) {
|
||||
case "openai-only":
|
||||
return "on (OpenAI only)";
|
||||
case "claude-only":
|
||||
return "on (Claude only)";
|
||||
default:
|
||||
return "on";
|
||||
}
|
||||
}
|
||||
|
||||
/** Scheme-less display form of a browser deep link: accent + underline, OSC-8 linked to the full URL. */
|
||||
function collabWebLinkClickable(webLink: string): string {
|
||||
const display = theme.fg("accent", `\x1b[4m${webLink.replace(/^https?:\/\//, "")}\x1b[24m`);
|
||||
@@ -359,15 +372,7 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
|
||||
return commandConsumed();
|
||||
}
|
||||
if (arg === "status") {
|
||||
const tier = runtime.session.serviceTier;
|
||||
const label = !runtime.session.isFastModeEnabled()
|
||||
? "off"
|
||||
: tier === "openai-only"
|
||||
? "on (OpenAI only)"
|
||||
: tier === "claude-only"
|
||||
? "on (Claude only)"
|
||||
: "on";
|
||||
await runtime.output(`Fast mode is ${label}.`);
|
||||
await runtime.output(`Fast mode is ${formatFastModeStatus(runtime.session)}.`);
|
||||
return commandConsumed();
|
||||
}
|
||||
return usage("Usage: /fast [on|off|status]", runtime);
|
||||
@@ -396,15 +401,7 @@ const BUILTIN_SLASH_COMMAND_REGISTRY: ReadonlyArray<SlashCommandSpec> = [
|
||||
return;
|
||||
}
|
||||
if (arg === "status") {
|
||||
const tier = runtime.ctx.session.serviceTier;
|
||||
const label = !runtime.ctx.session.isFastModeEnabled()
|
||||
? "off"
|
||||
: tier === "openai-only"
|
||||
? "on (OpenAI only)"
|
||||
: tier === "claude-only"
|
||||
? "on (Claude only)"
|
||||
: "on";
|
||||
runtime.ctx.showStatus(`Fast mode is ${label}.`);
|
||||
runtime.ctx.showStatus(`Fast mode is ${formatFastModeStatus(runtime.ctx.session)}.`);
|
||||
runtime.ctx.editor.setText("");
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user