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
feat(integrations): share a responsive connection workbench
Rahmanab97db6ba985
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.mdindex 6233f58f..938c90a6 100644--- a/docs/PROGRESS.md+++ b/docs/PROGRESS.md@@ -2822,3 +2822,8 @@ Screenshot evidence previously lived in unrelated scratch directories or only in### 2026-09-06 — Bounded Dokploy manual deploy- Added `dokploy.application.deploy`, an exact-application bounded operation through a selected named Dokploy connection. It queues only `/application.deploy` for a validated application ID and returns no provider credentials.- This replaces project-specific redeploy helpers that read a loose Dokploy API key from shell environment when an auto-deploy webhook is missed.++### 2026-09-07 — Integrations workbench+- The browser route and embedded MCP Page now share a responsive service rail, real connection-readiness summary, compact account cards, and contextual setup/actions. Setup guides and maintenance controls use progressive disclosure; account switching remains explicit.+- Integration snapshots no longer repeat the complete provider catalog, which is already embedded in the shared manager. The explicit catalog query remains available; compact snapshots prevent bounded MCP responses from truncating the Page.+- Validation: 26 browser assertions at 320/390/768/1440/1920 px in light/dark themes, account isolation, service search, setup focus, auto identifiers and Verify feedback; full verify passes.diff --git a/lib/infra/connection-service.ts b/lib/infra/connection-service.tsindex 9546ac73..4341c2c6 100644--- a/lib/infra/connection-service.ts+++ b/lib/infra/connection-service.ts@@ -23,7 +23,7 @@ export async function integrationSnapshot(selector:ConnectionSelector={}){const state=await readIntegrationState();let user:string|null=null;try{user=resolveUser(state,selector);}catch(e){if(selector.user)throw e;}const profiles=Object.values(state.users).map(u=>({id:u.id,label:u.label,isDefault:state.defaultUser===u.id,connectionCount:Object.values(u.connections).reduce((n,rows)=>n+Object.keys(rows).length,0)}));const connections=user?Object.values(state.users[user].connections).flatMap(rows=>Object.values(rows).map(c=>summaryIn(state,user!,c))):[];- return{version:2,catalog:connectionCatalog(),users:profiles,user,bindings:state.bindings,connections,resolution:user?(selector.user?"explicit":folderBinding(state,selector.cwd)?"folder":"default"):"choose-user"};+ return{version:2,users:profiles,user,bindings:state.bindings,connections,resolution:user?(selector.user?"explicit":folderBinding(state,selector.cwd)?"folder":"default"):"choose-user"};}export function createConnectionIn(state:IntegrationState,input:{user:string;provider:string;connection:string;label?:string;source?:ConnectionSource;authMethod?:string;makeDefault?:boolean}){const user=identity(input.user,"user"),provider=identity(input.provider,"provider"),id=identity(input.connection,"connection"),profile=state.users[user];if(!profile)throw new IntegrationError("user_not_found",404);diff --git a/lib/infra/connection-ui-style.ts b/lib/infra/connection-ui-style.tsnew file mode 100644index 00000000..fa48f76b--- /dev/null+++ b/lib/infra/connection-ui-style.ts@@ -0,0 +1,52 @@+// Shared by the browser route and the MCP Page; theme values come from widget-tokens.+export const CONNECTION_MANAGER_STYLE = String.raw`+.integration.manager{--integration-rail:224px;--integration-gap:24px;max-width:1180px;width:100%}+.integration .identity-heading,.integration .provider-heading,.integration .connection-heading{display:flex;align-items:center;justify-content:space-between;gap:16px}+.integration .identity-heading h2{margin:0}.integration .identity-heading p{margin:5px 0 0}+.integration .identity-count{font:600 12px var(--font-body);color:var(--text-dim);white-space:nowrap}+.integration .identity-bar{display:flex;gap:10px;align-items:end;flex-wrap:wrap;margin:22px 0}+.integration .identity-bar>label{flex:1;max-width:340px;min-width:160px;margin:0}+.integration .identity-bar select{margin-top:6px}+.integration .identity-tools{position:relative;margin:0;padding:0;border:0;background:none}+.integration .identity-tools summary{min-height:42px;display:flex;align-items:center;border:1px solid var(--sep-strong);border-radius:9px;padding:8px 13px;font-size:13px}+.integration .identity-tools[open] .identity-actions{position:absolute;right:0;top:100%;z-index:2;min-width:210px;background:var(--surface);padding:10px;border:1px solid var(--sep-strong);border-radius:12px;box-shadow:var(--shadow-pop)}+.integration .identity-tools .identity-actions{display:grid;margin-top:5px}+.integration .identity-layout{display:grid;grid-template-columns:var(--integration-rail) minmax(0,1fr);gap:var(--integration-gap);align-items:start}+.integration .identity-providers{display:grid;gap:5px;align-content:start;padding-right:18px;border-right:1px solid var(--sep)}+.integration .identity-providers input{margin-bottom:7px;font-size:14px}+.integration .identity-providers button{display:flex;text-align:left;align-items:center;gap:10px;padding:9px 10px;min-height:46px;border-color:transparent;background:transparent}+.integration .identity-providers button:hover{background:var(--hover)}+.integration [aria-pressed=true]{border-color:var(--sep-strong)!important;background:var(--field)!important;font-weight:700}+.integration .provider-mark{display:grid;place-items:center;flex:none;width:32px;height:32px;border:1px solid var(--sep-strong);border-radius:9px;background:var(--field);font:700 13px var(--font-body);color:var(--text)}+.integration .provider-heading .provider-mark{width:44px;height:44px;font-size:18px;border-radius:12px}+.integration .provider-title{display:flex;align-items:center;gap:12px;min-width:0}+.integration .provider-title h2{font-size:22px;margin:0}.integration .provider-title p{margin:4px 0 0}+.integration .provider-count{margin-left:auto;font:600 11px var(--font-body);color:var(--text-dim)}+.integration .identity-detail{min-width:0}.integration .identity-detail>p{max-width:66ch}+.integration .connection-card{border:1px solid var(--sep-strong);border-radius:14px;padding:20px;margin:14px 0;background:var(--field)}+.integration .connection-card h3{margin:0;font-size:17px;overflow-wrap:anywhere}+.integration .connection-heading{align-items:start}.integration .connection-heading small{margin:3px 0 0}+.integration .connection-state{font-size:12px;line-height:1.5;border:1px solid var(--sep-strong);border-radius:99px;padding:3px 9px;white-space:nowrap}+.integration .connection-state[data-ready=true]{color:var(--os-accent);background:color-mix(in srgb,var(--os-accent) 8%,var(--surface))}+.integration .identity-tags{display:flex;flex-wrap:wrap;gap:6px;margin:14px 0;color:var(--text-dim);font-size:12px}+.integration .identity-tags span+span:before{content:"·";margin-right:6px}+.integration .identity-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:16px}+.integration .identity-fields{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin:18px 0}+.integration .identity-fields label{min-width:0}.integration .identity-fields input,.integration .identity-fields select{margin-top:6px}+.integration .identity-feedback{min-height:24px;margin:12px 0;color:var(--text-dim);overflow-wrap:anywhere}+.integration .identity-path{font:12px var(--font-mono);overflow-wrap:anywhere;margin:10px 0 18px;color:var(--text-dim)}+.integration .identity-check{display:flex;align-items:center;gap:8px}.integration .identity-check input{width:18px;height:18px;flex:none}+.integration .identity-empty{border:1px dashed var(--sep-strong);border-radius:14px;padding:28px;margin:20px 0;background:var(--field)}+.integration .identity-empty h3{margin:0 0 8px;font-size:17px}.integration .identity-empty p{max-width:50ch;margin-bottom:18px}+.integration .danger{color:var(--destructive-text)}.integration .identity-guide a{display:inline-block;margin:8px 12px 5px 0}+.integration .identity-guide li{font-size:13px}.integration .identity-muted{font-size:12px;color:var(--text-dim)}+.integration .identity-form{border:1px solid var(--sep-strong);border-radius:12px;padding:16px}+.integration .identity-readonly{padding:12px 16px;border-left:3px solid var(--os-accent);background:var(--field);font-size:13px}+.integration .identity-summary{display:flex;align-items:center;gap:18px;padding:16px 20px;margin-bottom:22px;border:1px solid var(--sep);border-radius:14px;background:var(--field)}+.integration .identity-ring{width:64px;height:64px;flex:none;border-radius:50%;display:grid;place-items:center;background:conic-gradient(var(--os-accent) var(--ready-angle),var(--sep) 0)}+.integration .identity-ring strong{display:grid;place-items:center;width:50px;height:50px;border-radius:50%;background:var(--surface);font:700 18px var(--font-body)}+.integration .identity-summary dl{display:flex;gap:24px;flex-wrap:wrap;margin:0}.integration .identity-summary dt{font-size:12px;color:var(--text-dim)}.integration .identity-summary dd{font-weight:700;font-size:20px;margin:2px 0 0}+.integration :is(button,a,input,select,summary):focus-visible{outline:2px solid var(--os-accent);outline-offset:3px}+@media(max-width:760px){.integration.manager{--integration-rail:180px;--integration-gap:16px}.integration .identity-providers{padding-right:12px}.integration .identity-heading{align-items:start}.integration .identity-count{white-space:normal;text-align:right}.integration .identity-summary dl{gap:16px}}+@media(max-width:560px){.integration .identity-layout{grid-template-columns:1fr;gap:18px}.integration .identity-providers{grid-template-columns:repeat(2,minmax(0,1fr));max-height:240px;overflow-y:auto;padding:0 0 12px;border:0;border-bottom:1px solid var(--sep)}.integration .identity-providers input{grid-column:1/-1;position:sticky;top:0;background:var(--surface);z-index:1}.integration .identity-providers button{font-size:12px;padding:7px;gap:7px}.integration .identity-fields{grid-template-columns:1fr}.integration .identity-bar{gap:8px;margin:18px 0}.integration .identity-bar>label{max-width:none;flex-basis:100%}.integration .connection-card{padding:16px}.integration .provider-heading{align-items:start;flex-wrap:wrap}.integration .identity-summary{padding:14px;gap:14px}.integration .identity-summary dl{gap:14px}.integration .identity-summary dd{font-size:17px}.integration .identity-tools[open] .identity-actions{left:0;right:auto}.integration .identity-heading p{font-size:13px}}+`;diff --git a/lib/infra/connection-ui.ts b/lib/infra/connection-ui.tsindex 4854d38b..4c093806 100644--- a/lib/infra/connection-ui.ts+++ b/lib/infra/connection-ui.ts@@ -1,12 +1,12 @@-// One metadata-only manager for browser, CLI-opened browser and MCP Page.-// Only mountIntegrationForm handles secrets, using its direct HTTPS capability.-export const CONNECTION_MANAGER_STYLE=String.raw`-.integration .identity-bar{display:flex;gap:10px;align-items:end;flex-wrap:wrap;margin:14px 0 20px}.integration .identity-bar>label{flex:1;min-width:170px;margin:0}.integration .identity-bar select{margin-top:6px}.integration .identity-layout{display:grid;grid-template-columns:220px minmax(0,1fr);gap:20px}.integration .identity-providers{display:grid;gap:7px;align-content:start;max-height:560px;overflow:auto}.integration .identity-providers button{display:block;text-align:left;padding:10px 12px;min-height:42px}.integration [aria-pressed=true]{border-color:var(--os-accent);background:color-mix(in srgb,var(--os-accent) 10%,var(--surface))}.integration .connection-card{border:1px solid var(--sep-strong);border-radius:12px;padding:16px;margin:12px 0;background:var(--field)}.integration .connection-card h3{margin:0 0 6px;font-size:18px}.integration .identity-tags{display:flex;flex-wrap:wrap;gap:5px;margin:8px 0}.integration .identity-tags span{padding:3px 7px;border:1px solid var(--sep-strong);border-radius:99px;font-size:11px;color:var(--text-dim)}.integration .identity-actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:12px}.integration .identity-fields{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin:14px 0}.integration .identity-fields label{min-width:0}.integration .identity-fields input,.integration .identity-fields select{margin-top:6px}.integration .identity-feedback{min-height:24px;margin:8px 0;color:var(--text-dim);overflow-wrap:anywhere}.integration .identity-path{font:12px var(--font-mono);overflow-wrap:anywhere;margin:8px 0 15px}.integration .identity-check{display:flex;align-items:center;gap:8px}.integration .identity-check input{width:18px;height:18px;flex:none}.integration .identity-empty{border:1px dashed var(--sep-strong);border-radius:12px;padding:22px}.integration .identity-detail{min-width:0}.integration .identity-detail h2{font-size:22px}.integration .danger{color:var(--destructive-text)}.integration .identity-guide a{display:inline-block;margin:8px 12px 5px 0}.integration .identity-guide li{font-size:13px}.integration .identity-muted{font-size:12px;color:var(--text-dim)}.integration .identity-form{border:1px solid var(--sep-strong);border-radius:12px;padding:16px}.integration .identity-readonly{padding:10px 14px;border-left:3px solid var(--os-accent);background:var(--field);font-size:13px}@media(max-width:640px){.integration .identity-layout{grid-template-columns:1fr;gap:12px}.integration .identity-providers{grid-template-columns:1fr 1fr;max-height:180px}.integration .identity-providers input{grid-column:1/-1}.integration .identity-fields{grid-template-columns:1fr}.integration .identity-bar{gap:7px}.integration .connection-card{padding:13px}}-`;+export { CONNECTION_MANAGER_STYLE } from "./connection-ui-style";export const CONNECTION_MANAGER_SCRIPT=String.raw`function mountConnectionManager(root,catalog,bridge,initial={}){let disposed=false,sequence=0,snapshot=initial.snapshot||{users:[],connections:[],bindings:[]},user=initial.user||snapshot.user||null,provider=catalog.find(p=>p.id===initial.provider)||catalog.find(p=>p.id==="github")||catalog[0];let detail,status,container;+ const ready=c=>c.state==="verified"||c.state==="ACTIVE";+ const stateLabel=c=>ready(c)?"Verified":c.state==="incomplete"?"Needs setup":c.state==="configured"?"Not verified":"Authorize";+ const mark=p=>n("span",p.title.split(/[^A-Za-z0-9]+/).filter(Boolean).map(s=>s[0]).join("").slice(0,2).toUpperCase(),"provider-mark");+ const human=s=>s.replaceAll("-"," ").replaceAll("_"," ");const n=(tag,text,cls)=>{const v=integrationNode(tag,text);if(cls)v.className=cls;return v};const b=(text,fn,cls)=>{const v=n("button",text,cls);v.type="button";v.addEventListener("click",fn);return v};const input=(label,value="",type="text")=>{const l=n("label",label),i=n("input");i.type=type;i.value=value;i.autocomplete="off";i.maxLength=120;l.append(i);return{label:l,input:i}};@@ -14,14 +14,20 @@ function mountConnectionManager(root,catalog,bridge,initial={}){function remember(){if(bridge.remember)bridge.remember({user,provider:provider.id})}async function reload(){const version=++sequence;if(!bridge.query){draw();return}try{const next=await bridge.query({view:"snapshot",...(user?{user}:{})});if(disposed||version!==sequence)return;snapshot=next;user=next.user||user;draw();remember()}catch(e){if(!disposed){draw();status.textContent=textError(e)}}}async function change(args,after=reload){if(!bridge.manage)return;try{status.textContent="Saving connection metadata…";await bridge.manage({...args,confirm:true});await after()}catch(e){status.textContent=textError(e)}}- function guide(method,parent=detail){const d=n("details",undefined,"identity-guide");d.open=true;d.append(n("summary","How to get this credential / authorization"));const g=method.guidance,ol=n("ol");for(const step of g.steps)ol.append(n("li",step));d.append(ol);for(const[url,label]of [[g.url,"Official setup page"],[g.reference,"Documentation"]]){const a=n("a",label);a.href=url;a.rel="noopener noreferrer";a.target="_blank";if(bridge.openLink)a.addEventListener("click",e=>{e.preventDefault();Promise.resolve(bridge.openLink(url)).catch(error=>status.textContent=textError(error))});d.append(a)}parent.append(d)}+ function guide(method,parent=detail){const d=n("details",undefined,"identity-guide");d.open=false;d.append(n("summary","How to get this credential / authorization"));const g=method.guidance,ol=n("ol");for(const step of g.steps)ol.append(n("li",step));d.append(ol);for(const[url,label]of [[g.url,"Official setup page"],[g.reference,"Documentation"]]){const a=n("a",label);a.href=url;a.rel="noopener noreferrer";a.target="_blank";if(bridge.openLink)a.addEventListener("click",e=>{e.preventDefault();Promise.resolve(bridge.openLink(url)).catch(error=>status.textContent=textError(error))});d.append(a)}parent.append(d)}function draw(){- root.replaceChildren();root.classList.add("integration");root.append(n("h2","Integrations"),n("p","Credential owners, named accounts and deployments — shared by MSO CLI, tools and this form."));+ root.replaceChildren();root.classList.add("integration","manager");+ const heading=n("header",undefined,"identity-heading"),title=n("div");title.append(n("h2","Integrations"),n("p","Connect your services. Choose the account each project uses."));heading.append(title,n("span",catalog.length+" services","identity-count"));root.append(heading);const toolbar=n("div",undefined,"identity-bar"),label=n("label","Credential owner"),select=n("select");select.setAttribute("aria-label","Credential owner");const placeholder=n("option","Choose a user");placeholder.value="";select.append(placeholder);- for(const row of snapshot.users){const o=n("option",row.label+" ("+row.id+")"+(row.isDefault?" · default":""));o.value=row.id;select.append(o)}select.value=user||"";select.addEventListener("change",()=>{user=select.value||null;remember();void reload()});label.append(select);toolbar.append(label,b("Manage users",profiles),b("Folder bindings",bindings),b("Refresh",reload));const transfer=b("Import / export JSON",()=>bridge.openTransfer?bridge.openTransfer():bridge.openTransferBrowser?.());transfer.disabled=!bridge.openTransfer&&!bridge.openTransferBrowser;toolbar.append(transfer);root.append(toolbar);+ for(const row of snapshot.users){const o=n("option",row.label+" ("+row.id+")"+(row.isDefault?" · default":""));o.value=row.id;select.append(o)}select.value=user||"";select.addEventListener("change",()=>{user=select.value||null;remember();void reload()});label.append(select);toolbar.append(label,b("Refresh",reload));const tools=n("details",undefined,"identity-tools"),toolActions=n("div",undefined,"identity-actions");tools.append(n("summary","Settings"));toolActions.append(b("Manage users",profiles),b("Folder bindings",bindings));const transfer=b("Import / export JSON",()=>bridge.openTransfer?bridge.openTransfer():bridge.openTransferBrowser?.());transfer.disabled=!bridge.openTransfer&&!bridge.openTransferBrowser;toolActions.append(transfer);tools.append(toolActions);toolbar.append(tools);root.append(toolbar);if(!bridge.manage)root.append(n("p","Sign in as an MSO Owner to manage credentials. Device roles and credential users are different; the public guides remain available.","identity-readonly"));- container=n("div",undefined,"identity-layout");const sidebar=n("nav",undefined,"identity-providers"),search=n("input");search.type="search";search.placeholder="Search services";search.setAttribute("aria-label","Search services");sidebar.append(search);- const buttons=[];for(const p of catalog){const item=b(p.title,()=>{provider=p;remember();drawProvider();for(const[row,button]of buttons)button.setAttribute("aria-pressed",String(row.id===provider.id))});item.setAttribute("aria-pressed",String(p.id===provider.id));buttons.push([p,item]);sidebar.append(item)}search.addEventListener("input",()=>{for(const[p,item]of buttons)item.hidden=!(p.title+" "+p.id).toLowerCase().includes(search.value.toLowerCase())});+ if(snapshot.connections.length){+ const summary=n("section",undefined,"identity-summary"),count=snapshot.connections.filter(ready).length,ring=n("div",undefined,"identity-ring");+ ring.style.setProperty("--ready-angle",(count/snapshot.connections.length*360)+"deg");ring.setAttribute("role","img");ring.setAttribute("aria-label",count+" of "+snapshot.connections.length+" connections verified");ring.append(n("strong",count));+ const stats=n("dl");for(const[label,value]of [["Verified",count],["Needs attention",snapshot.connections.length-count],["Project folders",snapshot.bindings.filter(row=>row.user===user).length]]){const item=n("div");item.append(n("dt",label),n("dd",value));stats.append(item)}summary.append(ring,stats);root.append(summary)+ }+ container=n("div",undefined,"identity-layout");const sidebar=n("nav",undefined,"identity-providers"),search=n("input");search.type="search";search.placeholder="Search services";search.setAttribute("aria-label","Search services");sidebar.setAttribute("aria-label","Services");sidebar.append(search);+ const buttons=[];for(const p of catalog){const item=b(undefined,()=>{provider=p;remember();drawProvider();for(const[row,button]of buttons)button.setAttribute("aria-pressed",String(row.id===provider.id))});item.append(mark(p),n("span",p.title));const count=snapshot.connections.filter(c=>c.provider===p.id).length;if(count)item.append(n("span",count,"provider-count"));item.setAttribute("aria-pressed",String(p.id===provider.id));buttons.push([p,item]);sidebar.append(item)}search.addEventListener("input",()=>{for(const[p,item]of buttons)item.hidden=!(p.title+" "+p.id).toLowerCase().includes(search.value.toLowerCase())});detail=n("section",undefined,"identity-detail");status=n("p",undefined,"identity-feedback");status.setAttribute("role","status");status.setAttribute("aria-live","polite");container.append(sidebar,detail);root.append(container,status);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",drawProvider));}@@ -40,17 +46,17 @@ function mountConnectionManager(root,catalog,bridge,initial={}){for(const binding of snapshot.bindings){const card=n("div",undefined,"connection-card");card.append(n("strong",binding.path),n("p",binding.user+" · "+Object.entries(binding.connections).map(([p,id])=>p+"="+id).join(", ")));const remove=b("Remove binding",()=>change({action:"folder.unmap",path:binding.path}));remove.disabled=!bridge.manage;card.append(remove);detail.append(card)}}function drawProvider(){- detail.replaceChildren(n("h2",provider.title),n("p",provider.description),n("div",(user||"Choose user")+" → "+provider.id+" → Connection → Source → Auth","identity-path"));- const create=b("New connection",newConnection,"primary");create.disabled=!user||!bridge.manage;detail.append(create);+ detail.replaceChildren();const heading=n("header",undefined,"provider-heading"),title=n("div",undefined,"provider-title"),copy=n("div");copy.append(n("h2",provider.title),n("p",provider.description));title.append(mark(provider),copy);heading.append(title);detail.append(heading);+ const create=b("New connection",newConnection,"primary");create.disabled=!user||!bridge.manage;heading.append(create);const rows=snapshot.connections.filter(c=>c.provider===provider.id);- if(!rows.length){detail.append(n("p","No named connection for this user. Create one before entering credentials.","identity-empty"));for(const s of provider.sources)for(const m of s.methods){const info=n("details");info.append(n("summary",s.label+" · "+m.label));guide(m,info);detail.append(info)}}- for(const c of rows){const card=n("article",undefined,"connection-card");card.append(n("h3",c.label),n("small",c.id));const tags=n("div",undefined,"identity-tags");for(const value of [c.source,c.authMethod,c.scope,c.state,c.isDefault?"default":""])if(value)tags.append(n("span",value));card.append(tags);const actions=n("div",undefined,"identity-actions");- const open=b(c.source==="direct"?"Set / rotate credentials":"Authorization",()=>{if(c.source==="direct")void bridge.openSetup({user,provider:provider.id,connection:c.id}).catch(e=>status.textContent=textError(e));else external(c)});open.disabled=!bridge.manage;actions.append(open);+ if(!rows.length){const empty=n("div",undefined,"identity-empty");empty.append(n("h3","Connect "+provider.title),n("p",user?"Add an account to start using "+provider.title+" in your projects.":"Select a credential owner to add an account."));const start=b("Add "+provider.title+" account",newConnection,"primary");start.disabled=!user||!bridge.manage;empty.append(start);detail.append(empty);const help=n("details");help.append(n("summary","Connection methods & setup guides"));for(const s of provider.sources)for(const m of s.methods){const info=n("section");info.append(n("h3",s.label+" · "+m.label));guide(m,info);help.append(info)}detail.append(help)}+ for(const c of rows){const card=n("article",undefined,"connection-card");const top=n("header",undefined,"connection-heading"),name=n("div");name.append(n("h3",c.label),n("small",c.id));const state=n("span",stateLabel(c),"connection-state");state.dataset.ready=String(ready(c));top.append(name,state);card.append(top);const tags=n("div",undefined,"identity-tags");for(const value of [human(c.source),human(c.authMethod),c.isDefault?"Default account":""])if(value)tags.append(n("span",value));card.append(tags);const actions=n("div",undefined,"identity-actions"),more=n("details",undefined,"identity-tools"),secondary=n("div",undefined,"identity-actions");more.append(n("summary","More"));more.append(secondary);+ const open=b(c.source==="direct"?(c.fields.some(f=>f.stored)?"Update credentials":"Finish setup"):"Authorize",()=>{if(c.source==="direct")void bridge.openSetup({user,provider:provider.id,connection:c.id}).catch(e=>status.textContent=textError(e));else external(c)});open.disabled=!bridge.manage;actions.append(open);const verify=b("Verify",async()=>{try{status.textContent="Checking selected connection…";const result=await bridge.execute({user,provider:provider.id,connection:c.id,operation:"verify"});status.textContent=(result.ok===true?"Verified: ":"Status: ")+result.detail}catch(e){status.textContent=textError(e)}});verify.disabled=!bridge.execute;actions.append(verify);- const rename=b("Rename",()=>{detail.replaceChildren(n("h2","Rename connection"));const name=input("Label",c.label);detail.append(name.label,b("Save label",()=>change({action:"connection.rename",user,provider:provider.id,connection:c.id,label:name.input.value})),b("Cancel",drawProvider))});rename.disabled=!bridge.manage;actions.append(rename);- if(c.source==="direct"&&c.fields.some(f=>f.stored)){const clear=b("Clear credentials",()=>confirmation("Clear this connection's credential fields",c.id,()=>change({action:"credential.delete",user,provider:provider.id,connection:c.id})),"danger");clear.disabled=!bridge.manage;actions.append(clear)}- if(!c.isDefault){const def=b("Make default",()=>change({action:"connection.default",user,provider:provider.id,connection:c.id}));def.disabled=!bridge.manage;actions.append(def)}- const del=b("Delete",()=>confirmation("Delete named connection",c.id,()=>change({action:"connection.delete",user,provider:provider.id,connection:c.id})),"danger");del.disabled=!bridge.manage;actions.append(del);card.append(actions);detail.append(card);+ const rename=b("Rename",()=>{detail.replaceChildren(n("h2","Rename connection"));const name=input("Label",c.label);detail.append(name.label,b("Save label",()=>change({action:"connection.rename",user,provider:provider.id,connection:c.id,label:name.input.value})),b("Cancel",drawProvider))});rename.disabled=!bridge.manage;secondary.append(rename);+ if(c.source==="direct"&&c.fields.some(f=>f.stored)){const clear=b("Clear credentials",()=>confirmation("Clear this connection's credential fields",c.id,()=>change({action:"credential.delete",user,provider:provider.id,connection:c.id})),"danger");clear.disabled=!bridge.manage;secondary.append(clear)}+ if(!c.isDefault){const def=b("Make default",()=>change({action:"connection.default",user,provider:provider.id,connection:c.id}));def.disabled=!bridge.manage;secondary.append(def)}+ const del=b("Delete",()=>confirmation("Delete named connection",c.id,()=>change({action:"connection.delete",user,provider:provider.id,connection:c.id})),"danger");del.disabled=!bridge.manage;secondary.append(del);actions.append(more);card.append(actions);if(c.verifiedAt)card.append(n("small","Last verified "+new Date(c.verifiedAt).toLocaleString()));detail.append(card);}}function newConnection(){@@ -59,7 +65,7 @@ function mountConnectionManager(root,catalog,bridge,initial={}){for(const s of provider.sources){const o=n("option",s.label);o.value=s.id;source.append(o)}function changeAuth(){auth.replaceChildren();for(const m of provider.sources.find(s=>s.id===source.value).methods){const o=n("option",m.label+" · "+m.scope);o.value=m.id;auth.append(o)}previewGuide()}function previewGuide(){preview.replaceChildren();const method=provider.sources.find(s=>s.id===source.value).methods.find(m=>m.id===auth.value);if(method.fields.length)preview.append(n("p","Fields: "+method.fields.map(f=>f.label+(f.required?" *":"")).join(", ")));else preview.append(n("p","No provider tokens are stored locally for this source."));guide(method,preview)}source.addEventListener("change",changeAuth);auth.addEventListener("change",previewGuide);changeAuth();- const fields=n("div",undefined,"identity-fields");fields.append(label.label,id.label,sourceLabel,authLabel);detail.append(fields,preview,b("Create connection",()=>change({action:"connection.create",user,provider:provider.id,connection:id.input.value,label:label.input.value,source:source.value,authMethod:auth.value}),"primary"),b("Cancel",drawProvider));+ const fields=n("div",undefined,"identity-fields");fields.append(label.label,sourceLabel,authLabel);const advanced=n("details");advanced.append(n("summary","Connection identifier"),id.label);detail.append(fields,advanced,preview,b("Create & connect",()=>change({action:"connection.create",user,provider:provider.id,connection:id.input.value,label:label.input.value,source:source.value,authMethod:auth.value},async()=>{await reload();if(source.value==="direct")await bridge.openSetup({user,provider:provider.id,connection:id.input.value});else{const created=snapshot.connections.find(c=>c.provider===provider.id&&c.id===id.input.value);if(created)external(created)}}),"primary"),b("Cancel",drawProvider));label.input.focus();}function external(c){detail.replaceChildren(n("h2",c.label),n("p",user+" / "+provider.id+" / "+c.source+" / "+c.authMethod));const method=provider.sources.find(s=>s.id===c.source).methods.find(m=>m.id===c.authMethod);guide(method);@@ -68,6 +74,6 @@ function mountConnectionManager(root,catalog,bridge,initial={}){const authorize=b("Open hosted authorization",async()=>{try{authorize.disabled=true;const result=await bridge.manage({action:"connection.authorize",confirm:true,user,provider:provider.id,connection:c.id,...(broker.input.value?{brokerConnection:broker.input.value}:{}),...(config.input.value?{authConfigId:config.input.value}:{}),createManaged:managed.input.checked});if(result.privateUrl){const a=n("a","Continue on Composio");a.href=result.privateUrl;a.rel="noopener noreferrer";a.target="_blank";a.addEventListener("click",e=>{if(bridge.openLink){e.preventDefault();bridge.openLink(result.privateUrl)}});detail.append(a)}status.textContent="Authorization pending. Complete the provider flow, then refresh status."}catch(e){status.textContent=textError(e);authorize.disabled=false}});authorize.disabled=Boolean(c.external?.connectedAccountId);detail.append(authorize,b("Refresh authorization status",async()=>{try{const result=await bridge.execute({user,provider:provider.id,connection:c.id,operation:"verify"});status.textContent=result.detail}catch(e){status.textContent=textError(e)}}),b("Back",drawProvider));}draw();if(bridge.query)void reload();- return()=>{disposed=true;sequence++;root.replaceChildren();root.classList.remove("integration")};+ return()=>{disposed=true;sequence++;root.replaceChildren();root.classList.remove("integration","manager")};}`;diff --git a/lib/infra/setup-page.ts b/lib/infra/setup-page.tsindex 72ec036b..2794afe4 100644--- a/lib/infra/setup-page.ts+++ b/lib/infra/setup-page.ts@@ -8,7 +8,7 @@ import { connectionCatalog } from "./connection-registry";export function integrationSetupPage() {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_FORM_STYLE}${CONNECTION_MANAGER_STYLE}${PORTABILITY_STYLE}*{box-sizing:border-box}body{margin:0;background:var(--surface);padding:clamp(16px,3vw,40px);font-family:var(--font-body);color:var(--text)}.site-bar{max-width:1100px;margin:0 auto 26px;font-size:13px;display:flex;justify-content:space-between;gap:12px}.site-bar strong{font-weight:750}.site-bar span{color:var(--text-dim)}button{border:1px solid var(--sep-strong);border-radius:9px;background:var(--field);color:var(--text);padding:9px 13px;cursor:pointer}a{color:var(--os-accent)}</style></head><body><header class="site-bar"><strong>MSO / Integrations</strong><span>Native · Private credential setup</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_FORM_STYLE}${CONNECTION_MANAGER_STYLE}${PORTABILITY_STYLE}*{box-sizing:border-box}body{margin:0;background:var(--surface);padding:clamp(16px,3vw,40px);font-family:var(--font-body);color:var(--text)}.site-bar{max-width:1180px;margin:0 auto 26px;font-size:13px;display:flex;justify-content:space-between;gap:12px}.site-bar strong{font-weight:750}.site-bar span{color:var(--text-dim)}button{border:1px solid var(--sep-strong);border-radius:9px;background:var(--field);color:var(--text);padding:9px 13px;cursor:pointer}a{color:var(--os-accent)}</style></head><body><header class="site-bar"><strong>MSO / Integrations</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 'none'` };}export function integrationPageResponse() {diff --git a/scripts/e2e/integrations.mjs b/scripts/e2e/integrations.mjsnew file mode 100644index 00000000..a2d193f7--- /dev/null+++ b/scripts/e2e/integrations.mjs@@ -0,0 +1,56 @@+#!/usr/bin/env node+// Exercises the shared browser/embed manager using synthetic accounts; never production credentials.+import assert from "node:assert/strict";+import { execFileSync } from "node:child_process";+import { createRequire } from "node:module";+import path from "node:path";+const require = createRequire(import.meta.url);+const { chromium } = require(path.join(process.cwd(), "os-browser/node_modules/playwright"));+const html = execFileSync("bun", ["-e", 'import { integrationSetupPage } from "./lib/infra/setup-page"; console.log(integrationSetupPage().html)'], {encoding:"utf8"});+const users=[{id:"studio",label:"Studio",isDefault:true},{id:"personal",label:"Personal"}];+const fixture={id:"work",label:"Delivery GitHub",provider:"github",source:"direct",authMethod:"token",scope:"account",state:"verified",isDefault:true,fields:[{key:"apiKey",stored:true}],verifiedAt:Date.now()};+const snapshot=user=>({version:2,user,users,connections:user==="studio"?[fixture]:[],bindings:[]});+const browser=await chromium.launch({executablePath:"/usr/bin/google-chrome",args:["--no-sandbox","--disable-dev-shm-usage"]});+let checks=0;+try{+ const page=await browser.newPage();+ const errors=[];page.on("pageerror",error=>errors.push(error.message));+ await page.route("https://mso.rahmanef.com/**",route=>{+ const url=new URL(route.request().url());+ if(url.pathname==="/integrations")return route.fulfill({contentType:"text/html",body:html});+ if(url.pathname==="/api/auth/me")return route.fulfill({json:{role:"owner"}});+ if(url.pathname==="/api/v1/integrations"&&route.request().method()==="GET")return route.fulfill({json:snapshot(url.searchParams.get("user")||"studio")});+ if(url.pathname==="/api/v1/integrations")return route.fulfill({json:{ok:true,detail:"Connected to GitHub"}});+ return route.fulfill({status:404,json:{error:"unhandled_fixture"}});+ });+ await page.goto("https://mso.rahmanef.com/integrations");+ await page.getByRole("heading",{name:"Delivery GitHub"}).waitFor();+ for(const width of [320,390,768,1440,1920]){+ await page.setViewportSize({width,height:900});+ for(const theme of ["light","dark"]){+ await page.evaluate(theme=>document.documentElement.dataset.theme=theme,theme);+ assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1),"no document overflow at "+width+" "+theme);checks++;+ assert(await page.getByRole("button",{name:"Update credentials",exact:true}).isVisible());checks++;+ }+ }+ await page.setViewportSize({width:1440,height:900});+ await page.getByRole("button",{name:"Verify",exact:true}).click();+ await page.getByRole("status").filter({hasText:"Verified: Connected to GitHub"}).waitFor();checks++;+ await page.getByRole("combobox",{name:"Credential owner"}).selectOption("personal");+ await page.getByRole("button",{name:"Add GitHub account",exact:true}).waitFor();+ assert.equal(await page.getByRole("heading",{name:"Delivery GitHub"}).count(),0);checks++;+ await page.getByRole("button",{name:"Add GitHub account",exact:true}).click();+ assert(await page.getByRole("textbox",{name:"Connection label",exact:true}).evaluate(el=>el===document.activeElement));checks++;+ await page.getByRole("textbox",{name:"Connection label",exact:true}).fill("Personal delivery");+ await page.getByText("Connection identifier",{exact:true}).click();+ assert.equal(await page.getByRole("textbox",{name:"Connection ID",exact:true}).inputValue(),"personal-delivery");checks++;+ await page.getByRole("button",{name:"Cancel",exact:true}).click();+ await page.getByRole("searchbox",{name:"Search services"}).fill("cloudflare");+ assert.equal(await page.getByRole("navigation",{name:"Services"}).getByRole("button",{includeHidden:true}).count(),14);+ assert.equal(await page.getByRole("navigation",{name:"Services"}).getByRole("button").filter({visible:true}).count(),1);checks++;+ await page.getByRole("searchbox",{name:"Search services"}).fill("");+ await page.getByRole("combobox",{name:"Credential owner"}).selectOption("studio");+ await page.getByRole("heading",{name:"Delivery GitHub"}).waitFor();+ assert.deepEqual(errors,[]);checks++;+ console.log("Integrations browser: "+checks+" checks passed (320–1920 px, light/dark, owner isolation, search, setup, verification).");+}finally{await browser.close()}