From af1bbf7859abc36b6e2daed280dd4290c4ee0a06 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Thu, 19 Nov 2026 17:38:47 -0600 Subject: [PATCH] =?UTF-8?q?feat(webui):=20settings-s4=20nav=20and=20addres?= =?UTF-8?q?ses:=20Settings=20nav=20in=20four=20groups=20(You;=20Your=20mod?= =?UTF-8?q?els=20with=20Model=20setup=20and,=20for=20the=20instance=20owne?= =?UTF-8?q?r,=20Triage;=20All=20organizations;=20This=20organization=20wit?= =?UTF-8?q?h=20an=20organization=20picker=20above=20Models,=20Agents,=20La?= =?UTF-8?q?unch=20limits,=20Token=20use,=20Assistant=20and=20Organization?= =?UTF-8?q?=20file);=20an=20organization's=20pages=20live=20at=20#/setting?= =?UTF-8?q?s/=3Forg=3D=20and=20the=20old=20#/orgs//settings/?= =?UTF-8?q?=20form=20lands=20there;=20#/settings/model-proxy=20opens?= =?UTF-8?q?=20Model=20setup=20at=20#/settings/model-setup;=20the=20phone?= =?UTF-8?q?=20section=20button=20reads=20"=20=C2=B7=20";=20the?= =?UTF-8?q?=20breadcrumb=20names=20the=20organization=20on=20its=20Setting?= =?UTF-8?q?s=20pages;=20no=20Members=20row=20(#1873,=20lane=20settings-s4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/webui/src/public/brand.js | 4 +- packages/webui/src/public/bus.js | 55 ++++++++++++++----- packages/webui/src/public/display.js | 31 +++++++++-- packages/webui/src/public/triage-settings.js | 2 +- .../tests/agent-levels-edit-browser.test.mjs | 2 +- .../webui/tests/org-switch-browser.test.mjs | 9 ++- .../webui/tests/settings-s1-browser.test.mjs | 12 ++-- .../tests/triage-settings-browser.test.mjs | 2 +- packages/webui/tests/views.test.mjs | 3 +- 9 files changed, 86 insertions(+), 34 deletions(-) diff --git a/packages/webui/src/public/brand.js b/packages/webui/src/public/brand.js index 9c729f475..02a8d9e9c 100644 --- a/packages/webui/src/public/brand.js +++ b/packages/webui/src/public/brand.js @@ -183,7 +183,9 @@ function breadcrumbs() { draw(); // SP1: every page inside an organization says which one, after the dashboard: Dashboard / Acme / ... - const box = $('breadcrumbs'), org = /^#\/orgs\/[^/?]+/.test(location.hash) ? window.MosaicOrg : null; + // #1873 settings slice 4: an organization's Settings page names it with ?org=, so it says which one too. + const page = /^#\/settings\/([^/?]+)/.exec(location.hash)?.[1], orgSettings = !!page && !!window.MosaicOrg?.orgPage?.(page) && /[?&]org=/.test(location.hash); + const box = $('breadcrumbs'), org = /^#\/orgs\/[^/?]+/.test(location.hash) || orgSettings ? window.MosaicOrg : null; if (box && org?.id && !box.querySelector('[data-crumb-org]') && !/^#\/orgs\/[^/?]+\/organization(?:[/?]|$)/.test(location.hash)) box.insertAdjacentHTML('afterbegin', `Dashboard${escape(org.label)}`); // SP7: a trail with nothing above the page only repeats the page's heading, so the heading names it once. if (!box) return; diff --git a/packages/webui/src/public/bus.js b/packages/webui/src/public/bus.js index f7cb69ae7..5e4082fea 100644 --- a/packages/webui/src/public/bus.js +++ b/packages/webui/src/public/bus.js @@ -1329,7 +1329,7 @@ const cause=window.MosaicConsole?.catalogueCause?.(label,catalogue?.notices,catalogue?.reason)??null; const words=!cause?'':cause.plain?`
Technical details

${txt(cause.detail)}

`:`

${txt(cause.detail)}

`; const plain=cause?.plain?` ${txt(cause.plain)}`:''; - const setupLink=text=>`${text}`; + const setupLink=text=>`${text}`; if(!proxyOn)return `

${lead}${plain} ${thinking}

${words}`; if(owner)readService(); const recheck=''; @@ -1478,21 +1478,36 @@ }); // Organizations is writable when the server allows org setup, which it does in organization mode where send is off. const readonlyPage = page => !['appearance','business','console','triage'].includes(page) && !(page === 'organizations' && orgSetup) && !canSend && !isTester; - const settingsPages = [['appearance','Appearance'],['business',window.MosaicOrg ? 'Organization' : 'Business'],['limits','Launch limits'],['organizations','Organizations'],['routing','Routing'],['agents','Agents'],['assistant','Assistant'],['tokens','Token use'],['model-proxy','Model setup'],['triage','Triage'],['console','Console'],['about','About']]; - function markSettingsDraft(page,dirty){const link=document.querySelector(`#settings-nav a[href="#/settings/${page}"]`), dot='unsaved changes';if(link && dirty && !link.querySelector('.settings-dot'))link.insertAdjacentHTML('beforeend',dot);const button=$('settings-disclosure');if(dirty && link?.getAttribute('aria-current')==='page' && button && !button.querySelector('.settings-dot'))button.querySelector('strong').insertAdjacentHTML('beforeend',dot);} + const settingsPages = [['appearance','Appearance'],['business',window.MosaicOrg ? 'Organization' : 'Business'],['limits','Launch limits'],['organizations','Organizations'],['routing','Routing'],['agents','Agents'],['assistant','Assistant'],['tokens','Token use'],['model-setup','Model setup'],['triage','Triage'],['console','Console'],['about','About']]; + function markSettingsDraft(page,dirty){const link=document.querySelector(`#settings-nav a[href^="#/settings/${page}"]`), dot='unsaved changes';if(link && dirty && !link.querySelector('.settings-dot'))link.insertAdjacentHTML('beforeend',dot);const button=$('settings-disclosure');if(dirty && link?.getAttribute('aria-current')==='page' && button && !button.querySelector('.settings-dot'))button.querySelector('strong').insertAdjacentHTML('beforeend',dot);} + // #1873 settings slice 4 (DESIGN.md section 2): four groups. You; Your models; All organizations; + // This organization, whose heading holds the organization picker. An organization's own pages carry + // ?org= so the address base never changes with the organization. Testers keep their short list. + const ORG_SETTINGS = ['routing','agents','limits','tokens','assistant','business','names']; function settingsShell(page, body, helper='') { - const pages=isTester ? [['appearance','Appearance'],['business','Business'],['routing','Routing'],['agents','Agents'],['names','Seat names']] : settingsPages.filter(([id])=>id!=='triage'||triageOwner); - const label=pages.find(([id])=>id===page)?.[1] || 'Appearance'; + const org = window.MosaicOrg, orgId = org?.id ?? null, orgName = orgId ? (org.label || orgId) : null; + const scoped = id => ORG_SETTINGS.includes(id); + const href = id => `#/settings/${id}${orgId && scoped(id) ? `?org=${enc(orgId)}` : ''}`; + const labels = isTester ? Object.fromEntries([['appearance','Appearance'],['business','Business'],['routing','Routing'],['agents','Agents'],['names','Seat names']]) : { appearance:'Appearance', 'model-setup':'Model setup', triage:'Triage', organizations:'Organizations', console:'Console', about:'About', routing: org ? 'Models' : 'Routing', agents:'Agents', limits:'Launch limits', tokens:'Token use', assistant:'Assistant', business: org ? 'Organization file' : 'Business' }; + const label = labels[page] || 'Appearance'; const isDirty=id=>(id==='routing'&&routesDraft)||(id==='limits'&&settingsInputs)||(id==='assistant'&&(Object.keys(assistantDrafts).length||Object.keys(nameDrafts).length))||(id==='agents'&&(instanceDrafts.add||instanceDrafts.change||window.MosaicAgentLevels?.hasDraft()))||(id==='triage'&&window.MosaicTriageRoute?.hasDraft()); const dot='unsaved changes'; - const links=pages.map(([id,name],i)=>`${i===0?'
Your browser
':i===1?'
This instance
':''}${name}${isDirty(id)?dot:''}`).join('') + (!isTester ? '
Members and invites not built
' : ''); - return `${head('Settings','Your browser and this instance.')}

${label}

${helper}

${readonlyPage(page)?'

Read only. Saving requires signed-in send mode.

':''}${body}
`; + const a = id => `${labels[id]}${isDirty(id)?dot:''}`; + const group = (title, ids) => ids.length ? `
${title}
${ids.map(a).join('')}` : ''; + const rows = org ? org.rows() : []; + const picker = org && rows.length ? `
` : `
${org ? 'This organization' : 'This business'}
`; + const links = isTester ? group('Settings', ['appearance','business','routing','agents','names']) + : group('You', ['appearance']) + group('Your models', ['model-setup', ...(triageOwner ? ['triage'] : [])]) + group(org ? 'All organizations' : 'This instance', ['organizations','console','about']) + + picker + ['routing','agents','limits','tokens','assistant','business'].map(a).join(''); + const where = orgName && scoped(page) ? `${txt(orgName)} · ` : ''; + const title = org && page === 'routing' && orgName ? `${txt(orgName)}'s models` : label; + return `${head('Settings','Your models, your organizations and this browser.')}

${title}

${helper}

${readonlyPage(page)?'

Read only. Saving requires signed-in send mode.

':''}${body}
`; } async function settingsView(get, page='appearance') { if (page==='business') return businessView(get); if (page==='appearance') return settingsShell(page,appearance(),'These choices apply in this browser only.'); if (page==='organizations') { await configRead; return settingsShell(page,window.MosaicOrgCreate.markup,'Create an organization from the template, edit it, and finish its setup. Each step names the command it equals.'); } - if (page==='model-proxy') { await configRead; return settingsShell(page,window.MosaicProxy.markup,'Your model service, the accounts it uses and their priority, and the keys agents use to reach it.'); } + if (page==='model-setup') { await configRead; return settingsShell(page,window.MosaicProxy.markup,'Your model service, your accounts and the models they offer. Every organization uses them, including organizations you add later, unless it sets up its own.'); } // #1873 triage-settings: Settings > Triage (triage-settings.js), the instance owner's only; anyone else gets no page. if (page==='triage') { await configRead; if (!triageOwner || !window.MosaicTriageRoute) return notFound(); return settingsShell(page,await window.MosaicTriageRoute.section(),'The model Triage uses, what runs it, and its daily token limit. Only the instance owner sees this page.'); } // F3: Settings > Console (console-restart.js). The server checks the owner, Origin and trail. @@ -1508,12 +1523,20 @@ if (page==='routing') { await window.MosaicConsole?.ready; try { [routes] = await get('routes'); } catch (err) { if (err.status === 403 || err.code === 'signed-out') throw err; } } if (page==='tokens' && s.launch && !s.launch.refused) takeSnapshot(s.launch); const notify = typeof n.binding==='string' ? `${txt(n.binding)}` : n.refused ? `Could not be read: ${txt(n.refused)}` : 'None set'; - const contents={limits:()=>launchForm(s.launch),routing:()=>routesSection(routes,instances),agents:()=>agentsSection(instances)+agentLevels,assistant:()=>assistantSection(s.launch,names),tokens:()=>tokenLimits(limitRows,limitsRefused)+tokenUsage(usage),names:()=>testerNames(names,instances),about:()=>`
Address
${txt(s.address)||'unknown'}
Release
${txt(s.release)||'unknown'}
Business
${txt(s.business)||none}
Board
${txt(s.board)||'unknown'}
Notifier binding
${notify}
`, 'model-proxy':()=>'
Open Model setup
'}; + const contents={limits:()=>launchForm(s.launch),routing:()=>routesSection(routes,instances),agents:()=>agentsSection(instances)+agentLevels,assistant:()=>assistantSection(s.launch,names),tokens:()=>tokenLimits(limitRows,limitsRefused)+tokenUsage(usage),names:()=>testerNames(names,instances),about:()=>`
Address
${txt(s.address)||'unknown'}
Release
${txt(s.release)||'unknown'}
Business
${txt(s.business)||none}
Board
${txt(s.board)||'unknown'}
Notifier binding
${notify}
`}; const helpers={limits:'Leave a limit blank for no limit. Zero stops new launches. Running sessions keep running when limits or models change.',routing:"Each agent’s harness, model and thinking, and the fallback a launch takes when the primary harness fails its preflight. A fallback sets all three or none. Running sessions keep their route. The next launch reads the change. A harness is the program that runs the model. Preflight is the check a launch makes before it starts.",agents:'Each agent with its definition, launch membership and runs. A launch refuses until the agent has a route in Routing.',assistant:'The definition stays an assistant one. Holder and credentials stay hand edits.',tokens:'Token limits the bus checks, and token use read from session transcripts.'}; return settingsShell(page,contents[page](),`${get.oldest()?`Read ${when(get.oldest())}.`: 'Reading…'} ${helpers[page]||''}`); } let settingsFocusDisclosure=false; - document.addEventListener('change', e => { if (e.target.id === 'org-picker') window.MosaicOrg?.switchTo(e.target.value); }); + document.addEventListener('change', e => { if (e.target.id === 'org-picker') window.MosaicOrg?.switchTo(e.target.value); else if (e.target.id === 'org-pick') pickSettingsOrg(e.target.value); }); + // Slice 4: the picker re-reads the page in place. An organization's page keeps its page with the new + // ?org=; any other Settings page stays where it is and its organization links follow the pick. + function pickSettingsOrg(id) { + const org = window.MosaicOrg; if (!org || !id) return; + const [path, query = ''] = routeOf().split('?'), page = path.split('/')[2] || 'appearance'; + const rest = query.split('&').filter(p => p && !p.startsWith('org=')); + location.hash = ORG_SETTINGS.includes(page) ? `#/settings/${page}?${[`org=${enc(id)}`, ...rest].join('&')}` : `#/orgs/${enc(id)}${path}${query ? `?${query}` : ''}`; + } document.addEventListener('click', e=>{const b=e.target.closest?.('#settings-disclosure');if(b){b.setAttribute('aria-expanded',String(b.getAttribute('aria-expanded')!=='true'));return;} if(e.target.closest?.('#settings-nav a')) { const b=$('settings-disclosure'); if(b?.getAttribute('aria-expanded')==='true') {b.setAttribute('aria-expanded','false');settingsFocusDisclosure=true;b.focus();} }}); document.addEventListener('keydown', e=>{if(e.key==='Escape' && $('settings-disclosure')?.getAttribute('aria-expanded')==='true'){e.preventDefault();$('settings-disclosure').setAttribute('aria-expanded','false');$('settings-disclosure').focus();}}); @@ -1739,7 +1762,7 @@ const why = window.MosaicConsole?.orgDownReason?.(id, label, v => { const p = document.querySelector(`[data-org-down="${CSS.escape(id)}"] [data-org-down-why]`); if (p) { p.innerHTML = whyText(v); p.hidden = !p.innerHTML; } }) ?? null; // settings-p3 (re-check 3 P3-4): after a refusal a restart can't clear, Restart is not the primary. const restart = window.MosaicConsole?.orgRestartButton?.(id, { name: label, primary: !(window.MosaicConsole?.orgRefusal?.(id)?.restart === false || why?.restart === false) }) || ''; - return settingsShell(page, `

This instance's own pages still work: Appearance, Model setup${triageOwner ? ', Triage' : ''} and Console.

`); + return settingsShell(page, `

This instance's own pages still work: Appearance, Model setup${triageOwner ? ', Triage' : ''} and Console.

`); } return settingsShell(page, ``); } @@ -1881,7 +1904,7 @@ // On the cross-organization pages a filter or selection changes only the query: that is a // repaint of the same page, not a navigation (no loading view, focus and scroll kept). const samePage = drawerPage(path) && typeof shown === 'string' && shown.split('?')[0] === path; - if (path !== '/settings/model-proxy' && proxyCleanup) {proxyCleanup();proxyCleanup=null;} + if (path !== '/settings/model-setup' && proxyCleanup) {proxyCleanup();proxyCleanup=null;} if ((navigated || path !== '/settings/organizations') && orgCleanup) {orgCleanup();orgCleanup=null;} // Leaving a decision discards its confirmation immediately, including a preview in flight. if (answer && (navigated || path !== (answer.org ? '/inbox' : `/inbox/${answer.id}`))) answer = null; @@ -1897,6 +1920,8 @@ window.MosaicChat?.leave(chatPath); if (path === '/business') { location.replace('#/settings/business'); return; } if (path === '/settings/display') { location.replace('#/settings/appearance'); return; } + // #1873 settings slice 4: the owner's page is Model setup; its old address lands there, query kept. + if (path === '/settings/model-proxy') { location.replace(`#/settings/model-setup${query ? `?${query}` : ''}`); return; } // #1873 SP6: the Assistant page draws its own thread panes (assistant.js); every other page // stops their polling. It is a system page: an organization's address for it, and the old // Side by side address, land on `#/assistant`. @@ -1979,7 +2004,7 @@ sections(path); schedule(); return; } - if (path === '/settings/model-proxy' && shown === route && !navigated) return; + if (path === '/settings/model-setup' && shown === route && !navigated) return; if (path === '/settings/triage' && shown === route && !navigated) return; if (path === '/settings/organizations' && shown?.split('?')[0] === path && !navigated) return; if (($('agent-dialog')?.open || document.querySelector('.agent-more[aria-expanded=true]')) && !navigated) { schedule(); return; } @@ -1987,7 +2012,7 @@ let html, state = 'fresh'; const live = reader(true); try { - if (path !== '/organization' && !wsPage(path) && !(path === '/agents' && window.MosaicOrg) && path !== '/messages' && !['/settings','/settings/appearance','/settings/model-proxy','/settings/triage','/settings/organizations'].includes(path)) { + if (path !== '/organization' && !wsPage(path) && !(path === '/agents' && window.MosaicOrg) && path !== '/messages' && !['/settings','/settings/appearance','/settings/model-setup','/settings/triage','/settings/organizations'].includes(path)) { try { await live('messages'); } catch (err) { messageCount = null; if (err.status === 403 || err.code === 'signed-out') throw err; } } @@ -2013,7 +2038,7 @@ if (path.startsWith('/docs/')) paintDoc(); if (path === '/organization') window.MosaicConsole?.attachBus(document.querySelector('[data-dashboard-bus]')); if ($('bus-view').querySelector('[data-org-down]')) { const down = $('bus-down'); if (down) down.hidden = true; } - if (path === '/settings/model-proxy') proxyCleanup=window.MosaicProxy.mount(); + if (path === '/settings/model-setup') { proxyCleanup?.(); proxyCleanup=window.MosaicProxy.mount(); } if (path === '/settings/organizations') orgCleanup=window.MosaicOrgCreate.mount(); sections(path); const h1 = $('bus-view').querySelector('h1'); diff --git a/packages/webui/src/public/display.js b/packages/webui/src/public/display.js index 7c9812507..2ca821ae2 100644 --- a/packages/webui/src/public/display.js +++ b/packages/webui/src/public/display.js @@ -17,7 +17,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date( // #1873 settings slice 1 (section 5): a fix link goes only to a Settings page that exists for this viewer. // Settings > Triage exists only where /api/config says proxyAdmin (bus.js triageOwner); Model setup always does. const TRIAGE_FIX = { href: '#/settings/triage', label: 'Open Triage settings' }; - const SERVICE_FIX = { href: '#/settings/model-proxy', label: 'Open Model setup' }; + const SERVICE_FIX = { href: '#/settings/model-setup', label: 'Open Model setup' }; const pageExists = fix => fix !== TRIAGE_FIX || config?.proxyAdmin === true; const fixLink = fix => { const a = el('a', 'triage-fix', fix.label); a.href = fix.href; a.addEventListener('click', () => close()); return a; }; // An organization's name from the Console's own list, or its id when the list does not hold it. @@ -369,7 +369,12 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date( (() => { const nativeFetch = window.fetch.bind(window); // SP13: the organization segment stops at `/` or `?`, so `#/orgs/?agent=…` names . - const orgOf = hash => /^#\/orgs\/([^/?]+)/.exec(hash)?.[1] ?? null; + // #1873 settings slice 4: Settings pages keep one base, #/settings/. An organization's own + // pages name it with ?org=; the old #/orgs//settings/ form still lands there. + const ORG_PAGES = new Set(['routing', 'agents', 'limits', 'tokens', 'assistant', 'business', 'names']); + const settingsOf = hash => /^#\/(?:orgs\/[^/?]+\/)?settings\/([^/?]+)/.exec(hash)?.[1] ?? null; + const orgParam = hash => { const q = hash.split('?')[1]; const v = q ? new URLSearchParams(q).get('org') : null; return v ? encodeURIComponent(v) : null; }; + const orgOf = hash => /^#\/orgs\/([^/?]+)/.exec(hash)?.[1] ?? (/^#\/settings\//.test(hash) ? orgParam(hash) : null); const atLoad = orgOf(location.hash); if (!atLoad && !document.documentElement.hasAttribute('data-organizations')) return; // current: the scoping organization as its hash segment. settled: false only while the first @@ -390,9 +395,23 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date( // organization's agents; `#/orgs//agents` is that table for one organization. SP4: `#/tasks` is // one task board for every organization; `#/orgs//tasks` is that board, scoped to one. // SP6: `#/assistant` is the Assistant page, threads of any organization side by side. - const system = hash => { const bare = tail(hash).split('?')[0]; return bare === '/dashboard' || (!orgOf(hash) && (bare === '/inbox' || bare === '/agents' || bare === '/tasks' || bare === '/assistant')); }; + // A Settings page that is not an organization's is a system page at #/settings/. The old + // #/orgs//settings/ form of one keeps its organization, as it did before slice 4. + const system = hash => { const bare = tail(hash).split('?')[0], page = settingsOf(hash); return bare === '/dashboard' || bare === '/settings' || (page !== null && !ORG_PAGES.has(page) && !/^#\/orgs\//.test(hash)) || (!orgOf(hash) && (bare === '/inbox' || bare === '/agents' || bare === '/tasks' || bare === '/assistant')); }; + // An organization page's query gets org= first; the prefix, when there is one, wins over ?org=. + const withOrg = (query, seg) => [`org=${seg}`, ...query.split('&').filter(p => p && !p.startsWith('org='))].join('&'); const normalize = (hash, seg = current) => { const path = tail(hash), bare = path.split('?')[0], named = /^#\/orgs\/([^/?]+)$/.exec(hash.split('?')[0])?.[1]; + const page = settingsOf(hash); + if (bare === '/settings') return `#/settings${path.slice(bare.length)}`; + if (page !== null && /^\/settings\/[^/?]+$/.test(bare)) { + const query = path.slice(bare.length + 1), prefix = /^#\/orgs\/([^/?]+)/.exec(hash)?.[1]; + // An old prefix on a system page still names an organization (a switch, or Organizations' + // finish-setup link), and Organizations reads its own ?org=, so that address is kept as it is. + if (!ORG_PAGES.has(page)) return prefix ? hash : `#/settings/${page}${query ? `?${query}` : ''}`; + const org = prefix ?? orgParam(hash) ?? seg; + return org ? `#/settings/${page}?${prefix || !orgParam(hash) ? withOrg(query, org) : query}` : `#/settings/${page}${query ? `?${query}` : ''}`; + } if (named) return `#/orgs/${named}/organization${hash.slice(hash.split('?')[0].length)}`; if (bare === '/' || bare === '/dashboard') return `#/dashboard${path.slice(bare.length)}`; return orgOf(hash) || !seg || system(hash) ? hash : `#/orgs/${seg}${path}`; @@ -501,7 +520,7 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date( dialog.innerHTML = '

You have an unsaved draft. Stay here or discard it and continue.

'; document.body.append(dialog); const close = () => { dialog.close(); dialog.remove(); }; - const stay = () => { const picker = document.getElementById('org-picker'); if (picker && current) picker.value = decodeURIComponent(current); close(); }; + const stay = () => { for (const picker of document.querySelectorAll('#org-picker, #org-pick')) if (current) picker.value = decodeURIComponent(current); close(); }; dialog.querySelector('[data-stay]').onclick = stay; dialog.querySelector('[data-discard]').onclick = () => { close(); discard(); skipGuard = true; location.hash = next; }; dialog.addEventListener('cancel', e => { e.preventDefault(); stay(); }); @@ -537,10 +556,12 @@ window.MosaicLocalTime = value => Number.isFinite(Date.parse(value)) ? new Date( // SP3: whether this address is a system page (no organization's), for the shell's theme scope. system: () => system(location.hash), switchTo: next => { const path = route().split('?')[0]; location.hash = `#/orgs/${encodeURIComponent(next)}${path === '/dashboard' || path === '/' ? '/organization' : route()}`; }, + // Slice 4: whether this Settings page is an organization's own (it carries ?org=). + orgPage: page => ORG_PAGES.has(page), }); Object.defineProperty(window, 'MosaicOrg', { configurable: true, enumerable: true, get: () => (current || !settled ? api : undefined) }); })(); -if (document.documentElement.hasAttribute('data-settings-proxy-document') && !location.hash) location.hash = '#/settings/model-proxy'; +if (document.documentElement.hasAttribute('data-settings-proxy-document') && !location.hash) location.hash = '#/settings/model-setup'; /* Browser-local sidebar density. No authority or project data is stored here. */ (() => { // #1873 SP1: the key follows the open organization, read again when it changes. diff --git a/packages/webui/src/public/triage-settings.js b/packages/webui/src/public/triage-settings.js index 6af4d58ce..6a63be4b8 100644 --- a/packages/webui/src/public/triage-settings.js +++ b/packages/webui/src/public/triage-settings.js @@ -55,7 +55,7 @@ + (d.harness && !hs.includes(d.harness) ? `` : '') + hs.map(h => ``).join(''); const status = data?.choices?.status; - const catalogue = status === 'ready' ? '' : `

No organization can show your models right now, so no route can be saved. Open Model setup to see why each organization can't see your models.

`; + const catalogue = status === 'ready' ? '' : `

No organization can show your models right now, so no route can be saved. Open Model setup to see why each organization can't see your models.

`; const conflictButton = conflict ? ' ' : ''; return `${catalogue}
` + `` diff --git a/packages/webui/tests/agent-levels-edit-browser.test.mjs b/packages/webui/tests/agent-levels-edit-browser.test.mjs index 31c661bdd..663fa1872 100644 --- a/packages/webui/tests/agent-levels-edit-browser.test.mjs +++ b/packages/webui/tests/agent-levels-edit-browser.test.mjs @@ -125,7 +125,7 @@ test('both drafts survive a refresh render and the other form\'s save; a draft k assert.equal(await b.evaluate('getComputedStyle(document.querySelector("#agent-levels-root-form .filters")).display'), 'grid', 'the level forms keep the Settings form layout'); await type(b, 'agent-levels-root-form', { name: 'drafted', vars: 'limits.network=none' }); await type(b, 'agent-levels-project-form', { name: 'helper', form: 'narrow', vars: 'limits.tools=read' }); - assert.equal(await b.evaluate('!!document.querySelector("#settings-nav a[href$=\'settings/agents\'] .settings-dot")'), true, 'the nav marks unsaved changes'); + assert.equal(await b.evaluate('!!document.querySelector("#settings-nav a[href^=\'#/settings/agents\'] .settings-dot")'), true, 'the nav marks unsaved changes'); // A full Settings render, as the ten-second poll does: the edit box is a new node, the drafts are in it. await b.evaluate('document.getElementById("agent-levels-edit").dataset.old = "1"; document.getElementById("refresh").click()'); await wait('document.getElementById("agent-levels-edit") && !document.getElementById("agent-levels-edit").dataset.old'); diff --git a/packages/webui/tests/org-switch-browser.test.mjs b/packages/webui/tests/org-switch-browser.test.mjs index 223721882..ba6760b1f 100644 --- a/packages/webui/tests/org-switch-browser.test.mjs +++ b/packages/webui/tests/org-switch-browser.test.mjs @@ -145,7 +145,8 @@ test('sidebar lists organizations and navigating changes the route and header', await b.evaluate(`(async()=>{for(let i=0;i<150;i++){if(document.querySelectorAll('[data-workspace-org]').length===2 && document.querySelector('#settings-page-title'))return;await new Promise(r=>setTimeout(r,30))}throw Error('Organizations did not appear')})()`); await b.evaluate(`(async()=>{for(let i=0;i<150;i++){if(document.querySelector('#breadcrumbs [data-crumb-org]')?.textContent==='Alpha')return;await new Promise(r=>setTimeout(r,30))}throw Error('organization crumb missing')})()`); assert.equal(await b.evaluate(`document.querySelector('#current-organization')`), null, 'the header does not name an organization'); - assert.equal(await b.evaluate(`document.querySelector('#settings-page-title').textContent`), 'Organization'); + // settings slice 4: the page's nav label and title is Organization file. + assert.equal(await b.evaluate(`document.querySelector('#settings-page-title').textContent`), 'Organization file'); await b.evaluate('window.__sameDocument = true'); assert.equal(await b.evaluate(`!!document.querySelector('#org-picker')`), false); assert.deepEqual(await b.evaluate(`[...document.querySelectorAll('[data-workspace-org]')].map(o=>o.dataset.workspaceOrg)`), ['alpha', 'beta']); @@ -194,7 +195,8 @@ test('a chat draft is kept on Stay and discarded on an organization switch', asy await b.evaluate(`document.querySelector('[data-workspace-org=beta] a').click()`); await wait('!!document.querySelector("dialog[open] [data-stay]")'); await b.evaluate(`document.querySelector('[data-stay]').click()`); - assert.match(await b.evaluate('location.hash'), /^#\/orgs\/alpha\//); + // settings slice 4: an organization's Settings page names it with ?org=. + assert.equal(await b.evaluate('location.hash'), '#/settings/business?org=alpha'); assert.equal(await b.evaluate(`window.MosaicOrg.id`), 'alpha'); await b.evaluate(`location.hash='#/chat/threads/${thread}'`); await wait('!!document.querySelector("#chat-body")'); @@ -204,7 +206,8 @@ test('a chat draft is kept on Stay and discarded on an organization switch', asy await b.evaluate(`document.querySelector('[data-discard]').click()`).catch(() => {}); let switched = false; for (let i = 0; i < 150 && !switched; i++) { - try { switched = await b.evaluate(`location.hash.startsWith('#/orgs/beta/') && document.querySelector('#breadcrumbs [data-crumb-org]')?.textContent === 'Beta'`); } catch {} + // settings slice 4: the old address lands on the organization's Settings page with ?org=, and its crumb names it. + try { switched = await b.evaluate(`location.hash === '#/settings/business?org=beta' && document.querySelector('#breadcrumbs [data-crumb-org]')?.textContent === 'Beta'`); } catch {} if (!switched) await new Promise(r => setTimeout(r, 30)); } assert.equal(switched, true); diff --git a/packages/webui/tests/settings-s1-browser.test.mjs b/packages/webui/tests/settings-s1-browser.test.mjs index 37bbf5f28..813a3f5da 100644 --- a/packages/webui/tests/settings-s1-browser.test.mjs +++ b/packages/webui/tests/settings-s1-browser.test.mjs @@ -170,7 +170,7 @@ test('settings-s1 B1: a model-key-collision catalogue says two models share a na assert.match(line, /Two of your models get the same short name, so Acme Studio can't tell them apart\. A restart won't change that\./); assert.doesNotMatch(line, /Restart Acme Studio|model proxy/i); assert.equal(await b.evaluate('document.querySelector("#routes-catalogue [data-org-restart]")'), null, 'a restart comes back to the same state'); - assert.equal(await b.evaluate('document.querySelector("#routes-catalogue a[href=\'#/settings/model-proxy\']")?.textContent'), 'Open Model setup'); + assert.equal(await b.evaluate('document.querySelector("#routes-catalogue a[href=\'#/settings/model-setup\']")?.textContent'), 'Open Model setup'); }); test('settings-s1 B1: a set fence reads as a restart to finish, not as a stopped service; a status read that fails offers Check again', { timeout: 90000 }, async t => { @@ -180,7 +180,7 @@ test('settings-s1 B1: a set fence reads as a restart to finish, not as a stopped const line = await text('#routes-catalogue'); assert.match(line, /Your model service is waiting for a restart to finish\. Open Model setup to finish it\./); assert.doesNotMatch(line, /not running/); - assert.equal(await b.evaluate('document.querySelector("#routes-catalogue a").getAttribute("href")'), '#/settings/model-proxy'); + assert.equal(await b.evaluate('document.querySelector("#routes-catalogue a").getAttribute("href")'), '#/settings/model-setup'); assert.equal(await b.evaluate('document.querySelector("#routes-catalogue [data-org-restart]")'), null); await b.close(); } @@ -192,8 +192,8 @@ test('settings-s1 B1: a set fence reads as a restart to finish, not as a stopped test('settings-s1 B1: with the model service not set up or not running, Routing links to its page and offers no Restart', { timeout: 90000 }, async t => { for (const [service, expect, href] of [ - [SERVICE.fresh, /Your model service isn't set up yet\. Set up the model service\./, '#/settings/model-proxy'], - [SERVICE.stopped, /The model service is not running\. Open Model setup\./, '#/settings/model-proxy'], + [SERVICE.fresh, /Your model service isn't set up yet\. Set up the model service\./, '#/settings/model-setup'], + [SERVICE.stopped, /The model service is not running\. Open Model setup\./, '#/settings/model-setup'], ]) { const { b, wait, text } = await setup(t, { path: '/#/orgs/acme/settings/routing', init: stub({ service }) }); await wait('document.querySelector("#routes-catalogue a")'); @@ -235,9 +235,9 @@ test('settings-s1 B6: a stopped organization keeps its refused restart on screen await b.evaluate('location.hash = "#/orgs/gamma/settings/routing"'); await wait('document.querySelector("[data-org-down=gamma]:not([data-old]) [data-org-restart=gamma]")'); assert.equal(await b.evaluate(primary), false, 'still not primary after rendering again'); const links = await b.evaluate('[...document.querySelectorAll("[data-org-down=gamma] a")].map(a => [a.textContent, a.getAttribute("href")])'); - assert.deepEqual(links, [['Appearance', '#/settings/appearance'], ['Model setup', '#/settings/model-proxy'], ['Triage', '#/settings/triage'], ['Console', '#/settings/console']]); + assert.deepEqual(links, [['Appearance', '#/settings/appearance'], ['Model setup', '#/settings/model-setup'], ['Triage', '#/settings/triage'], ['Console', '#/settings/console']]); // A link from the stopped page opens an instance page. - await b.evaluate('document.querySelector("[data-org-down=gamma] a[href=\'#/settings/model-proxy\']").click(); true'); + await b.evaluate('document.querySelector("[data-org-down=gamma] a[href=\'#/settings/model-setup\']").click(); true'); await wait('document.querySelector("#proxy-setup") || document.querySelector("h1")?.textContent === "Model setup"'); assert.notEqual(await text('h1'), 'Not found'); }); diff --git a/packages/webui/tests/triage-settings-browser.test.mjs b/packages/webui/tests/triage-settings-browser.test.mjs index aff0022e2..0b3f81f7e 100644 --- a/packages/webui/tests/triage-settings-browser.test.mjs +++ b/packages/webui/tests/triage-settings-browser.test.mjs @@ -222,7 +222,7 @@ test('a catalogue that is not ready says so and offers no model', { timeout: 900 await wait('document.getElementById("triage-route-catalogue")'); assert.match(await text(b, 'triage-route-catalogue'), /No organization can show your models right now, so no route can be saved\. Open Model setup to see why each organization can.t see your models\./); assert.equal(await b.evaluate('document.getElementById("triage-route-catalogue").dataset.status'), 'bus-unavailable'); - assert.equal(await b.evaluate('document.querySelector("#triage-route-catalogue a").getAttribute("href")'), '#/settings/model-proxy'); + assert.equal(await b.evaluate('document.querySelector("#triage-route-catalogue a").getAttribute("href")'), '#/settings/model-setup'); assert.deepEqual(await options(b, 'triage-route-model'), [['', 'Choose a model', false]]); }); diff --git a/packages/webui/tests/views.test.mjs b/packages/webui/tests/views.test.mjs index 908192a81..6ae6bd37f 100644 --- a/packages/webui/tests/views.test.mjs +++ b/packages/webui/tests/views.test.mjs @@ -186,7 +186,8 @@ test('Queue, Business and Settings in their five states, with no move button', { // The owner's model proxy is reached from Settings, never from the Console tree. await go('#/settings', 'Settings'); assert.equal(await count('nav.tree a[href="/proxy"]'), 0); - assert.equal(await count('#settings-nav a[href="#/settings/model-proxy"]'), 1); + // Slice 4 names the page Model setup; the old #/settings/model-proxy address still opens it. + assert.equal(await count('#settings-nav a[href="#/settings/model-setup"]'), 1); // About holds the notifier and instance facts; browser appearance saves immediately. await go('#/settings/about', 'Settings');