Repository navigation
Description
Summary
Follow-up to #302 (PR #700). Two related items in views/Settings.vue worth bundling into one refactor:
- Complete the tab-as-component extraction — only
McpKeysTab.vuewas extracted in Refactor Settings page with tabbed layout and absorb API Keys #302; the other 4 tabs (General, Access, Integrations, Agents) remain inlinev-ifsections inSettings.vue. The file is currently ~3,000 lines. - Rewrite URL on tab-fallback — when a non-admin user navigates to
/settings?tab=integrations, the URL stays as typed but the active tab silently resolves tomcp-keys. URL ↔ content mismatch is confusing.
Both surface in the same file and have similar shape (Settings.vue refactor), which is why they're bundled.
Background — what shipped in #302
PR #700 delivered:
- ✅ Tabbed nav with
?tab=URL param, role-gated - ✅ MCP Keys absorbed from
/api-keys(extracted tocomponents/settings/McpKeysTab.vue) - ✅ NavBar Keys link removed;
/api-keysredirects to/settings?tab=mcp-keys - ✅ Backend security boundary unchanged (
require_adminenforced server-side) ⚠️ Partially met: "Each tab a separate Vue component (no 2,600-line monolith)" — only 1 of 5 tabs extracted
The other 4 tabs remain as <div v-if="activeTab === 'general'" class="...">...</div> inline blocks in Settings.vue.
Item 1 — Extract remaining 4 tabs
Target structure
src/frontend/src/components/settings/
├── McpKeysTab.vue # ✅ already exists
├── GeneralTab.vue # NEW — Platform, Trinity Prompt, Default Avatars
├── AccessTab.vue # NEW — Email Whitelist, User Management, SSH Access
├── IntegrationsTab.vue # NEW — API Keys (Anthropic+GitHub), Slack, Subscriptions
└── AgentsTab.vue # NEW — Agent Quotas, Skills Library, GitHub Templates
After extraction, Settings.vue becomes a thin shell (~300 lines):
<template>
<div class="...">
<NavBar />
<main>
<h1>Settings</h1>
<!-- Tab strip — unchanged -->
<div role="tablist">...</div>
<!-- Tab content — one component each -->
<GeneralTab v-if="activeTab === 'general'" />
<AccessTab v-if="activeTab === 'access'" />
<IntegrationsTab v-if="activeTab === 'integrations'" />
<McpKeysTab v-if="activeTab === 'mcp-keys'" />
<AgentsTab v-if="activeTab === 'agents'" />
</main>
</div>
</template>Each tab component is self-contained: own state (refs, reactives), own loaders (axios calls), own methods (save, delete, etc.), own modals.
Why this is a real refactor (not a five-minute change)
Each tab pulls in chunks of state and methods that are currently global to Settings.vue:
- GeneralTab:
trinityPrompt,originalPrompt,publicUrl,defaultAvatars,loadPublicUrl,loadDefaultAvatars,saveTrinityPrompt,generateDefaultAvatars, etc. - AccessTab:
emailWhitelist,users,sshAccess,loadEmailWhitelist,loadUsers,addEmail,removeEmail,updateUserRole, etc. - IntegrationsTab:
anthropicKey,githubPat,slackSettings,slackTransportStatus,subscriptions,loadApiKeyStatus,loadSlackSettings,saveAnthropic,saveGithubPat,connectSlack, etc. - AgentsTab:
agentQuotas,skillsLibraryUrl,githubTemplates,loadAgentQuotas,loadSkillsLibrarySettings,loadGithubTemplates, etc.
The Settings.vue loadAdminOnlySettings() function currently fires all these loaders on watch(isAdmin, ..., immediate: true). After extraction, each tab's onMounted triggers its own loaders — which is actually cleaner because non-admin users never mount admin tabs at all (no wasted API calls).
Acceptance — Item 1
-
Settings.vueis < 400 lines (down from ~3,000) - 4 new components:
GeneralTab.vue,AccessTab.vue,IntegrationsTab.vue,AgentsTab.vue - Each component owns its state, loaders, methods, and modals
- All 13 sections functional (regression-safe — covered by existing F1 test in
e2e/settings-tabs.spec.js) - All save buttons still work (Anthropic key save, GitHub PAT save, Trinity Prompt save, Email Whitelist add/remove, User role change, Agent Quotas save, Skills Library URL, GitHub Templates add/remove, etc.)
- No regression in role-based gating (admin sees 5 tabs, non-admin sees 1)
- No regression in URL deep-linking, browser back/forward, ConfirmDialog flows
- Existing 23 e2e tests still pass
Item 2 — Rewrite URL on tab-fallback
Current behavior
Settings.vue has:
const activeTab = ref(resolveTabFromQuery(route.query.tab))
watch(() => route.query.tab, (newTab) => {
activeTab.value = resolveTabFromQuery(newTab) // resolves to default if invalid
})- Non-admin pastes
/settings?tab=integrations→ URL stays?tab=integrations, content shows MCP Keys (the resolved fallback) - Anyone pastes
/settings?tab=foobar→ URL stays?tab=foobar, content shows default tab
URL ↔ content mismatch.
Proposed fix
watch(() => route.query.tab, (newTab) => {
const resolved = resolveTabFromQuery(newTab)
activeTab.value = resolved
// Rewrite URL to match resolved tab when input was invalid/inaccessible
if (newTab !== undefined && newTab !== resolved) {
router.replace({ query: { ...route.query, tab: resolved } })
}
}, { immediate: true }) // also fires for the initial-mount caseTradeoff acknowledged
Pro — URL always matches displayed content. Non-confusing. Bookmarks work.
Con — sharing /settings?tab=integrations from non-admin to admin no longer works (URL gets rewritten on the non-admin's side before they share). This is theoretical; "share my settings URL" is rarely a real use case.
Acceptance — Item 2
- Non-admin pasting
/settings?tab=integrations→ URL becomes/settings?tab=mcp-keys, MCP Keys content shows - Anyone pasting
/settings?tab=foobar→ URL becomes/settings?tab=<default>, default content shows - Admin pasting
/settings?tab=integrations→ URL stays/settings?tab=integrations(valid), Integrations content shows - Existing behavior 3 test (
?tab=foobarfalls back) updated to also assert URL rewrite - New test pinning non-admin URL rewrite
Test changes required
Update src/frontend/e2e/settings-tabs.spec.js:
- Update behavior 3 (
unknown ?tab=foobar falls back to default) — addawait expect(page).toHaveURL(/\/settings\?.*tab=general/)after the existing assertion - Add new test — non-admin URL rewrite to
mcp-keys - Update F1 (every section appears under expected tab) — sections may have moved; update selectors if needed
- Verify all 23 existing tests still pass after the component extraction
Out of scope (file as separate issues if desired)
- Save-button regression tests (F7-F9 — Trinity Prompt save, Whitelist add/remove, MCP Server URL save). Discussed but deferred — could be added either before or after this refactor.
- v-show vs v-if for modal-state preservation across tab switches (informational item I3 in Refactor Settings page with tabbed layout and absorb API Keys #302 review)
- Vitest unit-test infra (frontend has only Playwright e2e)
References
- Refactor Settings page with tabbed layout and absorb API Keys #302 (parent issue, merged via refactor(settings): tabbed layout with role-gated MCP Keys absorption (#302) #700)
- PR test(settings): harden #302 e2e coverage + manual test plan #716 (test follow-up — adds 6 e2e tests + manual runbook for Refactor Settings page with tabbed layout and absorb API Keys #302)
docs/planning/302-settings-test-list.md(Canon TDD test list from Refactor Settings page with tabbed layout and absorb API Keys #302)docs/testing/302-settings-tabbed-layout-manual-test-plan.md(manual runbook from PR test(settings): harden #302 e2e coverage + manual test plan #716)
Suggested labels & priority
enhancement,frontend,priority-p2- Tier: P1b or P1c (refactor without user-visible bug; nice-to-have)
Activity
feat: subscription usage observability + live headroom — 5h/7d window…