* chore: remove dead/unreferenced files across ui, vscode Remove 59 unused source files (components, hooks, lib utils, stores, barrels, and orphaned vscode github modules) that are not imported by any entry-reachable code. Also drop a stale test mock for the removed execCommands module. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> * refactor: remove unused exported symbols (types, functions, consts, hooks) Remove exported symbols whose identifier is referenced nowhere in the repository (verified via repo-wide search), across ui types/contracts, lib utilities, sync layer, stores, and components. Also drop the few imports/private helpers orphaned by these removals. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> * refactor: remove more unused exports (desktop, shortcuts, worktree, vscode) Continue removing repo-wide unreferenced exported functions, consts and types across lib/desktop, shortcuts, worktreeSessionCreator, sync, and vscode gitService, with cascading orphaned helpers/imports cleaned up. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> * chore: add dead-code cleanup tooling * refactor: checkpoint dead-code cleanup * refactor: remove dead-code suppressions --------- Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
58 lines
2.1 KiB
TypeScript
58 lines
2.1 KiB
TypeScript
import type { Agent } from '@opencode-ai/sdk/v2';
|
|
import { getProviderModelDisplayName, type DisplayProvider } from '@/lib/modelDisplay';
|
|
|
|
export type MobileControlsPanel = 'model' | 'agent' | 'variant' | null;
|
|
|
|
export const isPrimaryMode = (mode?: string) => mode === 'primary' || mode === 'all' || mode === undefined || mode === null;
|
|
|
|
const getCyclablePrimaryAgents = (agents: Agent[]) => agents.filter((agent) => isPrimaryMode(agent.mode));
|
|
|
|
export const getCycledPrimaryAgentName = (
|
|
agents: Agent[],
|
|
currentAgentName: string | undefined,
|
|
direction: 1 | -1 = 1,
|
|
) => {
|
|
const primaryAgents = getCyclablePrimaryAgents(agents);
|
|
if (primaryAgents.length <= 1) {
|
|
return null;
|
|
}
|
|
|
|
const currentIndex = primaryAgents.findIndex((agent) => agent.name === currentAgentName);
|
|
const safeCurrentIndex = currentIndex >= 0 ? currentIndex : 0;
|
|
const nextIndex = (safeCurrentIndex + direction + primaryAgents.length) % primaryAgents.length;
|
|
return primaryAgents[nextIndex]?.name ?? null;
|
|
};
|
|
|
|
const capitalizeLabel = (value: string) => value.charAt(0).toUpperCase() + value.slice(1);
|
|
|
|
export const getAgentDisplayName = (agents: Agent[], agentName?: string) => {
|
|
if (agentName) {
|
|
const agent = agents.find((entry) => entry.name === agentName);
|
|
return agent ? capitalizeLabel(agent.name) : capitalizeLabel(agentName);
|
|
}
|
|
|
|
const primaryAgents = agents.filter((agent) => isPrimaryMode(agent.mode));
|
|
const buildAgent = primaryAgents.find((agent) => agent.name === 'build');
|
|
const fallbackAgent = buildAgent || primaryAgents[0] || agents[0];
|
|
return fallbackAgent ? capitalizeLabel(fallbackAgent.name) : 'Select agent';
|
|
};
|
|
|
|
export const getModelDisplayName = (
|
|
provider: DisplayProvider,
|
|
modelId: string | undefined,
|
|
fallbackLabel = '',
|
|
) => {
|
|
return getProviderModelDisplayName(provider, modelId, { fallbackLabel });
|
|
};
|
|
|
|
export const formatEffortLabel = (variant?: string) => {
|
|
if (!variant || variant.trim().length === 0) {
|
|
return 'Default';
|
|
}
|
|
const trimmed = variant.trim();
|
|
if (/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
return trimmed;
|
|
}
|
|
return capitalizeLabel(trimmed);
|
|
};
|