Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(integrations): restore three fixes a later PR silently reverted, and follow the shell theme
Abdurrahman Fakhrul1b499afb6bd8
diff --git a/lib/infra/connection-ui-style.ts b/lib/infra/connection-ui-style.tsindex ac62ada1..c3b10959 100644--- a/lib/infra/connection-ui-style.ts+++ b/lib/infra/connection-ui-style.ts@@ -26,8 +26,8 @@ export const CONNECTION_MANAGER_STYLE = String.raw`.integration .identity-summary-line{margin:var(--space-4) 0;padding-bottom:var(--space-3);border-bottom:var(--stroke) solid var(--border);font-size:var(--type-small);color:var(--muted-foreground)}.integration .connection-card{border:var(--stroke) solid var(--border);border-radius:var(--radius-panel);padding:var(--space-4);margin:var(--space-4) 0 0;background:var(--settings-card)}.integration .connection-card h3{margin:0;font-size:var(--type-section);font-weight:var(--weight-strong);overflow-wrap:anywhere}.integration .connection-heading small{display:block;margin-top:var(--space-1);color:var(--muted-foreground)}-.integration .connection-state{font-size:var(--type-caption);line-height:var(--line-body);border:var(--stroke) solid var(--border);border-radius:var(--radius-pill);padding:var(--space-1) var(--space-2);white-space:nowrap}.integration .connection-state[data-ready=true]{color:var(--success-text);background:var(--settings-success-fill)}-.integration .identity-tags{display:flex;flex-wrap:wrap;gap:var(--space-2);margin:var(--space-3) 0;color:var(--muted-foreground);font-size:var(--type-caption)}.integration .identity-tags span{border-radius:var(--radius-pill);background:var(--muted);padding:var(--space-1) var(--space-2)}+.integration .connection-state{display:inline-block;max-width:100%;font-size:var(--type-caption);line-height:var(--line-body);border:var(--stroke) solid var(--border);border-radius:var(--radius-pill);padding:var(--space-1) var(--space-2);overflow-wrap:anywhere}.integration .connection-state[data-ready=true]{color:var(--success-text);background:var(--settings-success-fill)}+.integration .identity-tags{display:flex;flex-wrap:wrap;gap:var(--space-2);margin:var(--space-3) 0;color:var(--muted-foreground);font-size:var(--type-caption)}.integration .identity-tags span{display:inline-block;max-width:100%;border-radius:var(--radius-pill);background:var(--muted);padding:var(--space-1) var(--space-2);overflow-wrap:anywhere}.integration .identity-secret{display:flex;flex-wrap:wrap;align-items:center;gap:var(--space-2);min-width:0;max-width:100%}.integration .identity-secret-value{display:inline-block;max-width:100%;min-width:0;padding:var(--space-1) var(--space-2);font:var(--type-small)/var(--line-body) var(--font-mono);background:var(--secondary);color:var(--foreground);border:var(--stroke) solid var(--border);border-radius:var(--radius-control);overflow-wrap:anywhere;word-break:break-word}.integration .identity-secret-toggle{min-height:var(--control-size);min-width:var(--control-size)}.integration .identity-secret-copy{min-height:var(--control-size);min-width:var(--control-size)}.integration .identity-credential-status{display:grid;margin:var(--space-3) calc(var(--space-4) * -1) 0;font-size:var(--type-small);border-top:var(--stroke) solid var(--border)}.integration .identity-credential-status>div{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:var(--space-2);min-height:var(--control-size);padding:var(--space-2) var(--space-4);border-bottom:var(--stroke) solid var(--border)}.integration .identity-credential-status>div:last-child{border-bottom:0}.integration .credential-field-state{font-size:var(--type-caption);color:var(--destructive-text)}.integration .credential-field-state[data-stored=true]{color:var(--success-text)}.integration .identity-fields{display:grid;grid-template-columns:1fr 1fr;gap:var(--space-4);margin:var(--space-4) 0}.integration .identity-fields label{min-width:0}.integration .identity-fields input,.integration .identity-fields select{margin-top:var(--space-2)}@@ -44,7 +44,7 @@ export const CONNECTION_MANAGER_STYLE = String.raw`.integration .integration-sidebar-header{display:grid;flex:none;max-height:calc(var(--control-size) * 4);overflow-y:auto;gap:var(--space-4);padding:var(--space-5) var(--space-3) var(--space-3)}.integration .integration-sidebar-brand{display:flex;align-items:center;gap:var(--space-3);padding-inline:var(--space-1)}.integration .integration-sidebar-brand strong,.integration .integration-sidebar-brand small{display:block}.integration .integration-sidebar-brand strong{font-size:var(--type-small);font-weight:var(--weight-strong)}.integration .integration-sidebar-brand small{margin-top:var(--space-1);color:var(--muted-foreground);font-size:var(--type-caption)}.integration .integration-brand-icon{display:flex;align-items:center;justify-content:center;width:var(--brand-size);height:var(--brand-size);flex:none}.integration .integration-brand-icon svg{display:block;width:100%;height:100%}-.integration .integration-sidebar-header>input[type=search]{width:100%;min-height:var(--control-size);margin:0;border-radius:var(--radius-control);background:var(--secondary);font-size:var(--type-caption)}.integration .integration-settings-sidebar .owner-picker-trigger{min-height:var(--control-size);font-size:var(--type-caption)}+.integration .integration-sidebar-header>input[type=search]{width:100%;min-height:var(--control-size);margin:0;border-radius:var(--radius-control);background:var(--secondary);font-size:var(--type-body)}.integration .integration-settings-sidebar .owner-picker-trigger{min-height:var(--control-size);font-size:var(--type-body)}.integration .integration-settings-nav{min-height:calc(var(--control-size) * 2);flex:1;overflow-y:auto;padding:0 var(--space-2) var(--space-4);scrollbar-width:thin}.integration .integration-nav-group{display:grid;gap:var(--space-1);margin-top:var(--space-3)}.integration .integration-nav-label{margin:0;padding:0 var(--space-2) var(--space-1);font-size:var(--type-caption);font-weight:var(--weight-medium);color:var(--muted-foreground)}.integration .integration-nav-item{position:relative;display:flex;width:100%;min-height:var(--control-size);align-items:center;gap:var(--space-2);border:0;border-radius:var(--radius-control);padding:var(--space-2);text-align:left;background:transparent;color:var(--foreground);font-size:var(--type-small);font-weight:var(--weight-regular)}.integration .integration-nav-item:hover:not(:disabled){background:var(--hover)}.integration .integration-nav-item[aria-current=page]{background:var(--settings-selected);color:var(--settings-selected-text);font-weight:var(--weight-strong)}.integration .integration-nav-item .provider-mark{width:var(--settings-nav-icon-size);height:var(--settings-nav-icon-size);border-radius:var(--radius-control)}.integration .integration-nav-item[aria-current=page] .provider-mark{border-color:var(--settings-selected-border);background:var(--settings-selected-subtle);color:var(--settings-selected-text)}.integration .integration-nav-item .provider-count{margin-left:auto;font-size:var(--type-caption);color:inherit;opacity:var(--settings-muted-opacity)}diff --git a/lib/infra/connection-ui.ts b/lib/infra/connection-ui.tsindex 473b41c0..2f02b727 100644--- a/lib/infra/connection-ui.ts+++ b/lib/infra/connection-ui.ts@@ -91,7 +91,7 @@ function mountConnectionManager(root,catalog,bridge,initial={}){activateNav(navMode);if(navMode==="owners")profiles();else if(navMode==="variables")variables();else if(navMode==="demo-users")void demoUsers();else if(navMode==="ai-providers")void aiProviders();else if(navMode==="routing")bindings();else if(navMode==="project-mcp")showProjectMcp();else drawProvider();}- function confirmation(title,id,fn){detail.replaceChildren(n("h2",title),n("p","This changes only the selected identity. Type “"+id+"” to confirm."));const value=input("Confirmation");detail.append(value.label,b("Confirm",()=>{if(value.input.value!==id){status.textContent="Confirmation does not match.";return}void fn()},"danger"),b("Cancel",()=>{navMode="provider";activateNav(navMode);drawProvider()}));}+ function confirmation(title,id,fn){const trigger=document.activeElement,cancel=()=>{if(navMode==="owners")profiles();else if(navMode==="demo-users")void demoUsers();else{navMode="provider";activateNav(navMode);drawProvider();}if(trigger&&typeof trigger.focus==="function"){if(document.contains(trigger))trigger.focus();else{const m=Array.from(detail.querySelectorAll("button")).find(e=>e.textContent===trigger.textContent);if(m)m.focus();else trigger.focus();}setTimeout(()=>{if(document.contains(trigger))trigger.focus();},0);}};const box=n("div",undefined,"identity-confirmation");box.setAttribute("role","alertdialog");box.setAttribute("aria-modal","true");const titleId="confirmation-title-"+(++sequence),heading=n("h2",title);heading.id=titleId;box.setAttribute("aria-labelledby",titleId);box.addEventListener("keydown",event=>{if(event.key==="Escape"){event.preventDefault();cancel();}});const desc=n("p","This changes only the selected identity. Type “"+id+"” to confirm."),value=input("Confirmation"),confirmBtn=b(title,()=>{if(value.input.value!==id){status.textContent="Confirmation does not match.";return}void fn()},"danger"),cancelBtn=b("Cancel",cancel);box.append(heading,desc,value.label,confirmBtn,cancelBtn);detail.replaceChildren(box);cancelBtn.focus();setTimeout(()=>cancelBtn.focus(),0);}function profiles(){detail.replaceChildren(n("h2","Credential owners"),n("p","These profiles isolate service accounts. They do not grant MSO device roles."));const id=input("New user ID"),name=input("Display label");detail.append(id.label,name.label);const create=b("Create user",()=>change({action:"user.create",user:id.input.value,label:name.input.value||id.input.value},async()=>{user=id.input.value;await reload()}),"primary");create.disabled=!bridge.manage;detail.append(create);diff --git a/lib/infra/integration-theme.test.ts b/lib/infra/integration-theme.test.tsnew file mode 100644index 00000000..33f976aa--- /dev/null+++ b/lib/infra/integration-theme.test.ts@@ -0,0 +1,33 @@+import { describe, expect, it } from "vitest";+import { INTEGRATION_THEME_SCRIPT } from "./integration-theme";+import { integrationSetupPage } from "./setup-page";++// The standalone integrations page is raw HTML from a route handler, so it never passes through+// AppearanceProvider. Found by a browser audit: a dark-shell user on a light OS got a light page,+// because the page only followed `prefers-color-scheme`.+describe("standalone integrations page theme", () => {+ it("reads the shell's persisted theme before first paint", () => {+ // Same storage key and shape the shell writes (lib/appearance/store.tsx KEY + Appearance.theme).+ expect(INTEGRATION_THEME_SCRIPT).toContain("mso:tweaks");+ expect(INTEGRATION_THEME_SCRIPT).toContain("dataset.theme");+ expect(INTEGRATION_THEME_SCRIPT).toMatch(/light|dark/);+ // It must be defensive: a malformed value must not break the page.+ expect(INTEGRATION_THEME_SCRIPT).toContain("try");+ expect(INTEGRATION_THEME_SCRIPT).toContain("catch");+ });++ it("ships the theme script in <head>, before any body content", () => {+ const { html } = integrationSetupPage(false);+ const head = html.slice(0, html.indexOf("</head>"));+ const body = html.slice(html.indexOf("<body"));+ expect(head, "the theme must be set before paint or the page flashes light").toContain("mso:tweaks");+ expect(body, "it must not be needed after the body").not.toContain("mso:tweaks");+ });++ it("ships it in the embedded variant too", () => {+ const { html } = integrationSetupPage(true);+ expect(html).toContain("mso:tweaks");+ // The embedded rule hides the site bar; the theme still has to apply inside the iframe.+ expect(html).toContain(".site-bar{display:none}");+ });+});diff --git a/lib/infra/integration-theme.ts b/lib/infra/integration-theme.tsnew file mode 100644index 00000000..1c8de153--- /dev/null+++ b/lib/infra/integration-theme.ts@@ -0,0 +1,16 @@+// The standalone integrations page is raw HTML served by a route handler, so it never passes through+// AppearanceProvider. Without this it follows the OS `prefers-color-scheme` and ignores the theme the+// operator picked in the shell: a dark-shell user on a light OS got a light page.+//+// The shell persists its choice in localStorage under "mso:tweaks" as `{ theme: "light"|"dark"|null }`.+// This runs in <head> before first paint so there is no light flash, and it degrades to the OS+// preference when the key is absent, exactly as the shell does.+export const INTEGRATION_THEME_SCRIPT = String.raw`+(function(){+ try{+ var raw=localStorage.getItem("mso:tweaks"),theme=null;+ if(raw){var parsed=JSON.parse(raw);theme=parsed&&parsed.theme}+ if(theme==="light"||theme==="dark")document.documentElement.dataset.theme=theme;+ }catch(_){}+})();+`;diff --git a/lib/infra/integration-ui-regressions.test.ts b/lib/infra/integration-ui-regressions.test.tsnew file mode 100644index 00000000..d4505355--- /dev/null+++ b/lib/infra/integration-ui-regressions.test.ts@@ -0,0 +1,55 @@+import { readFileSync } from "node:fs";+import { describe, expect, it } from "vitest";++// Guards that a merged fix cannot be silently deleted by a later PR.+//+// Why this file exists: #248 fixed four integration-UI defects with tests. PR #249 (unrelated+// feature work) overwrote two of those files with stale copies, reverting the code AND the tests+// that pinned it, so the gate stayed green while three of the four fixes were gone:+//+// alertdialog on the confirmation dialog -> missing+// .transfer-error styling -> missing+// role="alert" on the transfer error -> missing+//+// Found by a browser audit, not by CI. These assertions read the source files directly and name the+// behaviour, so deleting the behaviour fails here even if the file is replaced wholesale.++const read = (p: string) => readFileSync(p, "utf8");++describe("integration UI fixes that must not regress", () => {+ it("confirmation dialog stays keyboard-operable and announced", () => {+ const src = read("lib/infra/connection-ui.ts");+ expect(src, "a destructive confirm must be an alertdialog").toContain('setAttribute("role","alertdialog")');+ expect(src, "assistive tech needs the dialog named").toContain('setAttribute("aria-labelledby"');+ expect(src, "Escape must cancel").toMatch(/event\.key==="Escape"/);+ expect(src, "focus must be restored to the trigger").toContain("document.activeElement");+ });++ it("transfer errors stay visible and announced", () => {+ const src = read("lib/infra/portable/ui.ts");+ expect(src, "the error needs a role so it is announced").toContain("role");+ const style = read("lib/infra/portable/ui.ts");+ expect(style, "the error class needs styling, not body text").toContain(".transfer-error{");+ });++ it("status badges wrap rather than overflow", () => {+ const css = read("lib/infra/connection-ui-style.ts");+ const state = css.match(/\.integration \.connection-state\{([^}]*)\}/)?.[1] ?? "";+ expect(state, "nowrap pushed the badge out of the card").not.toContain("white-space:nowrap");+ expect(state, "long labels must be able to wrap").toContain("overflow-wrap");+ });++ it("the sidebar search stays above the iOS auto-zoom threshold", () => {+ const css = read("lib/infra/connection-ui-style.ts");+ const search = css.match(/\.integration \.integration-sidebar-header>input\[type=search\]\{([^}]*)\}/)?.[1] ?? "";+ expect(search, "12px makes Safari zoom and never zoom back").not.toContain("font-size:var(--type-caption)");+ expect(search).toContain("font-size:var(--type-body)");+ });++ it("the lock curtain stays deferred while its timer stays eager", () => {+ // Deferred for bundle reasons in #222; the invariant is that the timer is mounted from the+ // provider, not from the deferred component.+ expect(read("frontend/slices/appshell/provider/app-shell.tsx")).toContain("useIdleAutoLock()");+ expect(read("frontend/slices/appshell/lib/use-idle-auto-lock.ts")).toContain("setTimeout(lock");+ });+});diff --git a/lib/infra/portable/ui.ts b/lib/infra/portable/ui.tsindex fb067c34..b58d34ff 100644--- a/lib/infra/portable/ui.ts+++ b/lib/infra/portable/ui.ts@@ -58,7 +58,7 @@ function mountPortability(root,bridge){const apply=button('Apply import',async()=>{if(!preview||!reviewed.i.checked){status.textContent='Review the preview and confirm first.';return}apply.disabled=check.disabled=true;try{const result=await bridge.request({...input(),apply:true,confirm:preview.planId,acceptWarnings:reviewed.i.checked});previewBox.textContent=JSON.stringify(result,null,2);status.textContent='Import complete. Imported connections are not marked verified; external authorization must be completed again.';documentData=null;file.i.value='';decrypt.i.value='';preview=null}catch(e){status.textContent=e.message;apply.disabled=false}finally{check.disabled=false}},'primary');apply.disabled=true;card.append(file.l,decrypt.l,prefix.l,policyLabel,check,previewBox,reviewed.l,apply,status);body.append(card);}function render(){if(disposed)return;body.replaceChildren();exportTab.setAttribute('aria-selected',String(active==='export'));importTab.setAttribute('aria-selected',String(active==='import'));active==='export'?exportView():importView()}- render();bridge.request({action:'tree'}).then(data=>{if(disposed)return;tree=data;for(const owner of tree.users)for(const p of owner.providers)for(const c of p.connections)selected.add(owner.id+'|'+p.id+'|'+c.id);if(active==='export')render()}).catch(e=>{if(!disposed){tree={users:[]};body.prepend(el('p',e.message,'transfer-error'))}});+ render();bridge.request({action:'tree'}).then(data=>{if(disposed)return;tree=data;for(const owner of tree.users)for(const p of owner.providers)for(const c of p.connections)selected.add(owner.id+'|'+p.id+'|'+c.id);if(active==='export')render()}).catch(e=>{if(!disposed){tree={users:[]};const err=el('p',e.message,'transfer-error');err.setAttribute('role','alert');body.prepend(err)}});function cleanup(){disposed=true;documentData=null;preview=null;selected.clear();root.replaceChildren();root.classList.remove('portable-transfer','integration')}return cleanup;}@@ -71,5 +71,6 @@ export const PORTABILITY_STYLE=String.raw`.portable-transfer .identity-check{display:flex;gap:var(--space-2);align-items:center;min-height:var(--control-size);cursor:pointer;font-weight:var(--weight-regular)}.portable-transfer .identity-check input{width:var(--icon-size);height:var(--icon-size);margin:0;order:-1;flex:none;accent-color:var(--primary)}.portable-transfer .transfer-tree{max-height:var(--settings-scroll-max-height);overflow:auto;margin:var(--space-3) 0;padding:var(--space-3);border:var(--stroke) solid var(--border);border-radius:var(--radius-control);background:var(--background)}.portable-transfer .transfer-tree-user{padding:var(--space-2) 0;border-bottom:var(--stroke) solid var(--border)}.portable-transfer .transfer-tree-provider{padding-left:var(--space-6)}.portable-transfer .transfer-tree-provider>.identity-check~.identity-check{padding-left:var(--space-6);color:var(--muted-foreground)}.portable-transfer pre{max-height:var(--settings-code-max-height);overflow:auto;font:var(--type-caption)/var(--line-body) var(--font-mono);white-space:pre-wrap;overflow-wrap:anywhere;background:var(--muted);border-radius:var(--radius-control);padding:var(--space-3)}.portable-transfer [role=status]{font-size:var(--type-small);overflow-wrap:anywhere}.portable-transfer .transfer-hint{font-size:var(--type-caption);color:var(--muted-foreground);margin-top:var(--space-3)}.portable-transfer button{min-height:var(--control-size);margin:var(--space-2) var(--space-2) var(--space-2) 0}+.portable-transfer .transfer-error{color:var(--destructive-text);background:var(--settings-card);border:var(--stroke) solid var(--settings-danger-border);border-radius:var(--radius-control);padding:var(--space-3);margin:var(--space-3) 0;overflow-wrap:anywhere}@container integration (max-width:${SETTINGS_COMPACT_MAX}){.portable-transfer .transfer-card{padding:var(--space-4)}.portable-transfer .transfer-tabs button{flex:1}.portable-transfer .transfer-tree-provider,.portable-transfer .transfer-tree-provider>.identity-check~.identity-check{padding-left:var(--space-3)}}`;diff --git a/lib/infra/setup-page.ts b/lib/infra/setup-page.tsindex 42d96a7f..f0c0a979 100644--- a/lib/infra/setup-page.ts+++ b/lib/infra/setup-page.ts@@ -5,6 +5,7 @@ import { MSO_WIDGET_TOKENS } from "@/lib/presentation/widget-tokens";import { INTEGRATION_FORM_SCRIPT, INTEGRATION_FORM_STYLE } from "./setup-ui";import { CONNECTION_MANAGER_SCRIPT, CONNECTION_MANAGER_STYLE } from "./connection-ui";import { INTEGRATION_BROWSER_SCRIPT } from "./setup-browser";+import { INTEGRATION_THEME_SCRIPT } from "./integration-theme";import { connectionCatalog } from "./connection-registry";export const INTEGRATION_PAGE_STYLE = String.raw`*{box-sizing:border-box}@@ -17,7 +18,7 @@ button{border:var(--stroke) solid var(--input);border-radius:var(--radius-controexport function integrationSetupPage(embedded = false) {const nonce = randomBytes(18).toString("base64");const catalog = JSON.stringify(connectionCatalog()).replace(/</g,"\\u003c");- const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><title>Integrations · MSO</title><style nonce="${nonce}">${MSO_WIDGET_TOKENS}${INTEGRATION_PAGE_STYLE}${INTEGRATION_FORM_STYLE}${CONNECTION_MANAGER_STYLE}${PORTABILITY_STYLE}${embedded ? "html,body{height:100%}body{padding:0;overflow:hidden}.site-bar{display:none}#setup{height:100%}" : ""}</style></head><body><header class="site-bar"><strong>${MSO_LOGO_SVG} MSO</strong><span>Your service connections</span></header><main id="setup" class="integration"><h1>Integrations</h1><p>Preparing the native provider catalog…</p><noscript>Enable JavaScript to open the secure credential form. Credentials can also be entered through the MSO terminal.</noscript></main><script nonce="${nonce}">const INTEGRATIONS_CATALOG=${catalog};${INTEGRATION_FORM_SCRIPT}${CONNECTION_MANAGER_SCRIPT}${PORTABILITY_SCRIPT}${INTEGRATION_BROWSER_SCRIPT}</script></body></html>`;+ const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="referrer" content="no-referrer"><title>Integrations · MSO</title><style nonce="${nonce}">${MSO_WIDGET_TOKENS}${INTEGRATION_PAGE_STYLE}${INTEGRATION_FORM_STYLE}${CONNECTION_MANAGER_STYLE}${PORTABILITY_STYLE}${embedded ? "html,body{height:100%}body{padding:0;overflow:hidden}.site-bar{display:none}#setup{height:100%}" : ""}</style><script nonce="${nonce}">${INTEGRATION_THEME_SCRIPT}</script></head><body><header class="site-bar"><strong>${MSO_LOGO_SVG} MSO</strong><span>Your service connections</span></header><main id="setup" class="integration"><h1>Integrations</h1><p>Preparing the native provider catalog…</p><noscript>Enable JavaScript to open the secure credential form. Credentials can also be entered through the MSO terminal.</noscript></main><script nonce="${nonce}">const INTEGRATIONS_CATALOG=${catalog};${INTEGRATION_FORM_SCRIPT}${CONNECTION_MANAGER_SCRIPT}${PORTABILITY_SCRIPT}${INTEGRATION_BROWSER_SCRIPT}</script></body></html>`;return { html, csp: `default-src 'none'; script-src 'nonce-${nonce}'; style-src 'nonce-${nonce}'; connect-src 'self'; form-action 'none'; base-uri 'none'; frame-ancestors ${embedded ? "'self'" : "'none'"}` };}function integrationResponse(embedded: boolean) {