Files
aryx/src/renderer/lib/settingsHelpers.ts
T
David KayaandCopilot fcfc5c9641 refactor: decompose large frontend components into focused modules
Split six monolithic component files into smaller, single-responsibility
modules organized by feature domain:

- ChatPane (1054→~250 lines): extract InlinePills, ApprovalBanner,
  ThinkingDots into chat/ directory
- SettingsPanel (1027→~280 lines): extract McpServerEditor,
  LspProfileEditor, ToolingEditorShell into settings/ directory;
  mutation helpers into lib/settingsHelpers.ts
- PatternEditor: use shared ToggleSwitch from ui/
- App.tsx: extract useTheme and useSidecarCapabilities into hooks/
- Sidebar: extracted accessibility improvements inline

New shared primitives:
- hooks/useClickOutside: replaces 5 duplicated click-outside listeners
- components/ui/: ToggleSwitch, PopoverToggleRow, FormField, TextInput,
  TextareaInput, SelectInput, InfoCallout

Accessibility improvements:
- NewSessionModal: role=dialog, aria-modal, Escape-to-close
- Pill dropdowns: aria-expanded, aria-haspopup, role=listbox/option
- Sidebar context menu: role=menu/menuitem, Escape-to-close
- SessionItem: Space key activation alongside Enter
- ToolbarButton: aria-pressed for toggle state
- ApprovalBanner: role=alert
- QueuedApprovalsList: aria-expanded on toggle
- ThinkingDots: aria-label

No behavioral changes. All 137 tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-25 20:12:36 +01:00

68 lines
1.6 KiB
TypeScript

import type { McpServerDefinition, LspProfileDefinition } from '@shared/domain/tooling';
import { nowIso } from '@shared/utils/ids';
export function updateMcpServer<T extends McpServerDefinition>(
server: T,
patch: Partial<T>,
): T {
return { ...server, ...patch, updatedAt: nowIso() } as T;
}
export function changeMcpTransport(
server: McpServerDefinition,
transport: McpServerDefinition['transport'],
): McpServerDefinition {
if (transport === server.transport) return server;
if (transport === 'local') {
return {
id: server.id,
name: server.name,
transport: 'local',
command: '',
args: [],
cwd: undefined,
tools: server.tools,
timeoutMs: server.timeoutMs,
createdAt: server.createdAt,
updatedAt: nowIso(),
};
}
return {
id: server.id,
name: server.name,
transport,
url: server.transport === 'local' ? '' : server.url,
tools: server.tools,
timeoutMs: server.timeoutMs,
createdAt: server.createdAt,
updatedAt: nowIso(),
};
}
export function updateLspProfile(
profile: LspProfileDefinition,
patch: Partial<LspProfileDefinition>,
): LspProfileDefinition {
return { ...profile, ...patch, updatedAt: nowIso() };
}
export function splitMultiline(value: string): string[] {
return value
.split(/\r?\n/)
.map((item) => item.trim())
.filter((item) => item.length > 0);
}
export function splitTokens(value: string): string[] {
return value
.split(/[\r\n,]+/)
.map((item) => item.trim())
.filter((item) => item.length > 0);
}
export function joinMultiline(value: string[]): string {
return value.join('\n');
}