moi-computer 0.13.1-next.0 → 0.13.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/api/app-config.ts +0 -1
- package/client/app/routes/workspace-route.tsx +4 -7
- package/client/features/account/account-test-utils.tsx +13 -5
- package/client/features/account/api.ts +4 -2
- package/client/features/account/profile-actions.ts +1 -1
- package/client/features/app-settings/avatar-upload.tsx +62 -0
- package/client/features/app-settings/profile-settings.tsx +10 -0
- package/client/features/chat/applet-chat-intents.ts +4 -4
- package/client/features/chat/sessions/api.ts +5 -5
- package/client/features/chat/sessions/use-selected-session.ts +3 -3
- package/client/features/chat/use-chat.ts +4 -4
- package/client/features/collab/applet-api.ts +1 -1
- package/client/features/collab/components/cursors.tsx +6 -1
- package/client/features/collab/components/presence-avatars.tsx +1 -1
- package/client/features/collab/components/presence-frame.tsx +1 -1
- package/client/features/collab/components/presence-group.tsx +1 -1
- package/client/features/collab/components/presence-helpers.ts +2 -2
- package/client/features/collab/components/user-avatar-group.tsx +1 -1
- package/client/features/collab/components/user-avatar.tsx +1 -1
- package/client/features/collab/components/user.tsx +1 -1
- package/client/features/collab/index.ts +3 -3
- package/client/features/{workspace-members → collab/members}/api.ts +6 -3
- package/client/features/{workspace-members → collab/members}/hooks.ts +11 -35
- package/client/features/{workspace-members → collab/members}/store.ts +4 -4
- package/client/features/{workspace-members → collab/members}/types.ts +2 -2
- package/client/features/collab/{client.ts → presence/client.ts} +2 -2
- package/client/features/collab/{provider.tsx → presence/provider.tsx} +1 -12
- package/client/features/collab/{users.ts → presence/users.ts} +19 -21
- package/client/features/collab/sharing/agent-invite.tsx +30 -0
- package/client/features/collab/sharing/workspace-members.tsx +277 -0
- package/client/features/collab/sharing/workspace-sharing-menu.tsx +179 -0
- package/client/features/collab/testing/component-fixtures.tsx +3 -3
- package/client/features/collab/testing/fake-engine.ts +2 -2
- package/client/features/dev/collab/collab-playground.tsx +2 -2
- package/client/features/dev/dev-index-page.tsx +0 -6
- package/client/features/dev/dev-routes.tsx +0 -2
- package/client/features/dev/workspace-setup-mocks.ts +0 -1
- package/client/features/identity/host-api.ts +2 -2
- package/client/features/identity/store.ts +1 -1
- package/client/features/views/use-view-actions.ts +3 -3
- package/client/features/workspace/browser-tab-state.ts +6 -6
- package/client/features/workspace/workspace-content.tsx +10 -6
- package/dist/{chunk-00s35r33.js → chunk-3smkkcfw.js} +76 -76
- package/dist/chunk-47h9c2qy.js +2 -0
- package/dist/chunk-8qed2gqp.js +75 -0
- package/dist/{chunk-7rz6g7g7.js → chunk-8zy3vesm.js} +1 -1
- package/dist/{chunk-s5s1vzdw.js → chunk-a47zy276.js} +2 -2
- package/dist/chunk-g4c1nte9.css +1 -0
- package/dist/chunk-kcactdr4.js +2 -0
- package/dist/chunk-m8bhx6tw.js +1 -0
- package/dist/{chunk-svxhxfeq.js → chunk-pf19zcrn.js} +2 -2
- package/dist/{chunk-kdgk4dac.js → chunk-th91xfnp.js} +1 -1
- package/dist/chunk-ygzxah0e.js +1 -0
- package/dist/index.html +1 -1
- package/lib/types.ts +0 -1
- package/package.json +1 -1
- package/server/app-config.ts +2 -7
- package/server/applets/declarations.ts +6 -7
- package/server/cli/commands/init.ts +0 -11
- package/server/collab/config.ts +1 -5
- package/server/collab/manager.ts +5 -2
- package/server/collab/skill/index.ts +1 -47
- package/server/skills/template.ts +3 -2
- package/server/skills/update.ts +1 -1
- package/server/skills/workspace.ts +0 -2
- package/server/web.ts +1 -2
- package/server/workspaces/scaffold.ts +1 -0
- package/skill/SKILL.md +1 -1
- package/client/features/collab/workspace-users-menu.tsx +0 -190
- package/client/features/dev/cloud-avatar-upload.tsx +0 -58
- package/client/features/dev/cloud-page.tsx +0 -363
- package/dist/chunk-af2jyddf.js +0 -2
- package/dist/chunk-cekekc3f.css +0 -1
- package/dist/chunk-ep5vh16c.js +0 -75
- package/dist/chunk-t0r0bds1.js +0 -1
- package/dist/chunk-vp2qzc0d.js +0 -1
- package/dist/chunk-wz5qv1bn.js +0 -2
- /package/client/features/{workspace-members → collab/members}/keys.ts +0 -0
- /package/client/features/collab/{hooks.tsx → presence/hooks.tsx} +0 -0
- /package/client/features/collab/{presence-publisher.ts → presence/presence-publisher.ts} +0 -0
- /package/client/features/collab/{presence-target.ts → presence/presence-target.ts} +0 -0
- /package/client/features/collab/{store.ts → presence/store.ts} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e,x}from"/chunk-a47zy276.js";import{p}from"/chunk-pf19zcrn.js";var t=x(function(m,r){r.exports=globalThis.__esm.react});var f=e(t(),1);var s={environment:"local",demo:!1,demoInstallUrl:"https://moi.computer"},o=s,i=new Set;function c(n){return i.add(n),()=>{i.delete(n)}}async function l(){try{o=await p("/api/config");for(let n of i)n();return o}catch{}}async function bt(){return l()}function v(){return f.useSyncExternalStore(c,()=>o)}
|
|
2
|
+
export{t,bt,v};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{yt}from"/chunk-th91xfnp.js";export{yt as sanitizeSvg};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
async function s(t,e){let o=await t.text();return Error(o||e)}async function p(t,e,o="Request failed"){let n=await fetch(t,e);if(!n.ok)throw await s(n,o);return n.json()}async function
|
|
2
|
-
export{p,
|
|
1
|
+
async function s(t,e){let o=await t.text();return Error(o||e)}async function p(t,e,o="Request failed"){let n=await fetch(t,e);if(!n.ok)throw await s(n,o);return n.json()}async function V(t,e,o="Request failed"){let n=await fetch(t,e);if(!n.ok)throw await s(n,o)}function w(t,e){return{method:t,headers:{"Content-Type":"application/json"},body:e===void 0?void 0:JSON.stringify(e)}}
|
|
2
|
+
export{p,V,w};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* SVG/attribute allowlists and URI sanitization approach derived from DOMPurify.
|
|
3
3
|
* DOMPurify — MIT License, Copyright (c) 2015 Mario Heiderich
|
|
4
4
|
* https://github.com/cure53/DOMPurify/blob/main/LICENSE
|
|
5
|
-
*/var v=new Set(["svg","a","altglyph","altglyphdef","altglyphitem","animate","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","filter","font","foreignobject","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","set","stop","style","switch","symbol","text","textpath","title","tref","tspan","use","view","vkern"]),y=new Set(["a","b","blockquote","body","br","code","del","div","em","h1","h2","h3","h4","h5","h6","i","li","mark","ol","p","pre","span","strong","s","sub","sup","table","tbody","td","th","thead","tr","u","ul"]),A=new Set(["script","iframe","object","embed","form","input","textarea","select","button","link","meta","base","img","video","audio","source","picture","svg"]),x=new Set(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clip-path","clip-rule","clippathunits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","diffuseconstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","from","fx","fy","g1","g2","glyph-name","glyphref","gradienttransform","gradientunits","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","kernelmatrix","kernelunitlength","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","mask","mask-type","maskcontentunits","maskunits","max","media","method","min","mode","name","numoctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","radius","refx","refy","repeatcount","repeatdur","requiredfeatures","restart","result","role","rotate","rx","ry","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","text-anchor","text-decoration","text-rendering","textlength","to","transform","transform-origin","type","u1","u2","unicode","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewbox","visibility","width","word-spacing","wrap","writing-mode","x","x1","x2","xchannelselector","xlink:href","xml:id","xml:space","xlink:title","xmlns","xmlns:xlink","y","y1","y2","z","zoomandpan"]),k=new Set(["class","dir","href","id","lang","role","style","tabindex","title"]),d=/^data-/,p=/^aria-/,o=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,g=/^(?:https?:|mailto:)/i,S=/^data:/i,T=/^data:image\/(?:png|jpeg|jpg|gif|webp|avif|bmp|tiff|x-icon|vnd\.microsoft\.icon)[;,]/i,_=/^data:image\/svg\+xml[;,]/i,u=/^#/;function w(t){return t.replace(/\\([0-9a-fA-F]{1,6})\s?|\\([^\n])/g,(i,r,n)=>{if(r){let e=parseInt(r,16);if(e>1114111||e===0)return"�";return String.fromCodePoint(e)}return n})}var E=/^data:(?:image\/(?:png|jpeg|jpg|gif|webp|avif)|font\/(?:woff2?|opentype|truetype|sfnt)|application\/(?:x-font-woff|font-woff2?|x-font-ttf|x-font-opentype|font-sfnt))[;,]/i;function f(t){let i=w(t);return i=i.replace(/@import\s+(?:url\s*\([^)]*\)|"[^"]*"|'[^']*')[^;]*;?|@import\b[^;]*;?/gi,""),i=i.replace(/expression\s*\([^)]*\)/gi,""),i=i.replace(/-moz-binding\s*:[^;]*/gi,""),i=i.replace(/behavior\s*:[^;]*/gi,""),i=i.replace(/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gis,(r,n,e)=>{let a=e.replace(o,"");if(E.test(a)||u.test(a))return r;return""}),i}function L(t){return f(t)}var N=new Set(["animate","set","animatecolor","animatetransform"]),R=/^(?:href|xlink:href|on)/i;function z(t){let i=t.getAttribute("attributeName");if(!i)return!1;return R.test(i.replace(o,""))}var h=/^on/i,D=new Set(["clip-path","cursor","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"]),m=10;function I(t){let i=t.search(/;base64,/i);if(i>=0){let n=t.slice(i+8),e=Uint8Array.from(atob(n),(a)=>a.charCodeAt(0));return new TextDecoder().decode(e)}let r=t.indexOf(",");if(r<0)return null;return decodeURIComponent(t.slice(r+1))}function C(t){let i=new TextEncoder().encode(t),r=Array.from(i,(n)=>String.fromCharCode(n)).join("");return"data:image/svg+xml;base64,"+btoa(r)}function G(t,i){if(i>=m)return console.warn(`Embedded SVG data URI recursion depth limit (${m}) reached`),null;let r;try{let e=I(t);if(e===null)return null;r=e}catch{return null}let n=b(r,i+1);if(!n)return null;return C(n)}function O(t,i,r,n){let e=r.replace(o,""),a=t.tagName.toLowerCase();if(a==="image"||a==="feimage"){if(T.test(e))return r;if(_.test(e))return G(e,n);return null}if(a==="use"){if(u.test(e))return r;return null}if(a==="a"){if(g.test(e))return r;return null}if(S.test(e)||u.test(e))return r;return null}function l(t,i){for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!x.has(e)){t.removeAttribute(n.name);continue}if(e==="href"||e==="xlink:href"){let s=O(t,e,n.value,i);if(s===null)t.removeAttribute(n.name);else if(s!==n.value)n.value=s;continue}if(e==="style"){n.value=f(n.value);continue}if(D.has(e)&&/url\s*\(/i.test(n.value))n.value=f(n.value)}}function M(t){let i=t.tagName.toLowerCase();for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!k.has(e)){t.removeAttribute(n.name);continue}if(e==="href"){if(i!=="a"){t.removeAttribute(n.name);continue}let s=n.value.replace(o,"");if(!g.test(s))t.removeAttribute(n.name);continue}if(e==="style")n.value=f(n.value)}}function c(t,i,r){for(let n=t.children.length-1;n>=0;n--){let e=t.children[n],a=e.tagName.toLowerCase();if(i==="svg")if(a==="foreignobject")l(e,r),c(e,"html",r);else if(a==="style"){if(l(e,r),e.textContent)e.textContent=L(e.textContent)}else if(N.has(a)&&z(e))e.remove();else if(v.has(a))l(e,r),c(e,"svg",r);else e.remove();else if(A.has(a))e.remove();else if(y.has(a))M(e),c(e,"html",r);else e.remove()}}function b(t,i){let r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.querySelector("parsererror"))return"";let e=r.documentElement;if(e.tagName.toLowerCase()!=="svg")return"";if(l(e,i),c(e,"svg",i),e.children.length===0)return"";return new XMLSerializer().serializeToString(e)}function
|
|
5
|
+
*/var v=new Set(["svg","a","altglyph","altglyphdef","altglyphitem","animate","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","feblend","fecolormatrix","fecomponenttransfer","fecomposite","feconvolvematrix","fediffuselighting","fedisplacementmap","fedistantlight","fedropshadow","feflood","fefunca","fefuncb","fefuncg","fefuncr","fegaussianblur","feimage","femerge","femergenode","femorphology","feoffset","fepointlight","fespecularlighting","fespotlight","fetile","feturbulence","filter","font","foreignobject","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","set","stop","style","switch","symbol","text","textpath","title","tref","tspan","use","view","vkern"]),y=new Set(["a","b","blockquote","body","br","code","del","div","em","h1","h2","h3","h4","h5","h6","i","li","mark","ol","p","pre","span","strong","s","sub","sup","table","tbody","td","th","thead","tr","u","ul"]),A=new Set(["script","iframe","object","embed","form","input","textarea","select","button","link","meta","base","img","video","audio","source","picture","svg"]),x=new Set(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clip-path","clip-rule","clippathunits","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","diffuseconstant","direction","display","divisor","dominant-baseline","dur","dx","dy","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","from","fx","fy","g1","g2","glyph-name","glyphref","gradienttransform","gradientunits","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","kernelmatrix","kernelunitlength","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","mask","mask-type","maskcontentunits","maskunits","max","media","method","min","mode","name","numoctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","pointer-events","points","preservealpha","preserveaspectratio","primitiveunits","r","radius","refx","refy","repeatcount","repeatdur","requiredfeatures","restart","result","role","rotate","rx","ry","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","text-anchor","text-decoration","text-rendering","textlength","to","transform","transform-origin","type","u1","u2","unicode","values","version","vert-adv-y","vert-origin-x","vert-origin-y","viewbox","visibility","width","word-spacing","wrap","writing-mode","x","x1","x2","xchannelselector","xlink:href","xml:id","xml:space","xlink:title","xmlns","xmlns:xlink","y","y1","y2","z","zoomandpan"]),k=new Set(["class","dir","href","id","lang","role","style","tabindex","title"]),d=/^data-/,p=/^aria-/,o=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,g=/^(?:https?:|mailto:)/i,S=/^data:/i,T=/^data:image\/(?:png|jpeg|jpg|gif|webp|avif|bmp|tiff|x-icon|vnd\.microsoft\.icon)[;,]/i,_=/^data:image\/svg\+xml[;,]/i,u=/^#/;function w(t){return t.replace(/\\([0-9a-fA-F]{1,6})\s?|\\([^\n])/g,(i,r,n)=>{if(r){let e=parseInt(r,16);if(e>1114111||e===0)return"�";return String.fromCodePoint(e)}return n})}var E=/^data:(?:image\/(?:png|jpeg|jpg|gif|webp|avif)|font\/(?:woff2?|opentype|truetype|sfnt)|application\/(?:x-font-woff|font-woff2?|x-font-ttf|x-font-opentype|font-sfnt))[;,]/i;function f(t){let i=w(t);return i=i.replace(/@import\s+(?:url\s*\([^)]*\)|"[^"]*"|'[^']*')[^;]*;?|@import\b[^;]*;?/gi,""),i=i.replace(/expression\s*\([^)]*\)/gi,""),i=i.replace(/-moz-binding\s*:[^;]*/gi,""),i=i.replace(/behavior\s*:[^;]*/gi,""),i=i.replace(/url\s*\(\s*(['"]?)(.*?)\1\s*\)/gis,(r,n,e)=>{let a=e.replace(o,"");if(E.test(a)||u.test(a))return r;return""}),i}function L(t){return f(t)}var N=new Set(["animate","set","animatecolor","animatetransform"]),R=/^(?:href|xlink:href|on)/i;function z(t){let i=t.getAttribute("attributeName");if(!i)return!1;return R.test(i.replace(o,""))}var h=/^on/i,D=new Set(["clip-path","cursor","fill","filter","marker-end","marker-mid","marker-start","mask","stroke"]),m=10;function I(t){let i=t.search(/;base64,/i);if(i>=0){let n=t.slice(i+8),e=Uint8Array.from(atob(n),(a)=>a.charCodeAt(0));return new TextDecoder().decode(e)}let r=t.indexOf(",");if(r<0)return null;return decodeURIComponent(t.slice(r+1))}function C(t){let i=new TextEncoder().encode(t),r=Array.from(i,(n)=>String.fromCharCode(n)).join("");return"data:image/svg+xml;base64,"+btoa(r)}function G(t,i){if(i>=m)return console.warn(`Embedded SVG data URI recursion depth limit (${m}) reached`),null;let r;try{let e=I(t);if(e===null)return null;r=e}catch{return null}let n=b(r,i+1);if(!n)return null;return C(n)}function O(t,i,r,n){let e=r.replace(o,""),a=t.tagName.toLowerCase();if(a==="image"||a==="feimage"){if(T.test(e))return r;if(_.test(e))return G(e,n);return null}if(a==="use"){if(u.test(e))return r;return null}if(a==="a"){if(g.test(e))return r;return null}if(S.test(e)||u.test(e))return r;return null}function l(t,i){for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!x.has(e)){t.removeAttribute(n.name);continue}if(e==="href"||e==="xlink:href"){let s=O(t,e,n.value,i);if(s===null)t.removeAttribute(n.name);else if(s!==n.value)n.value=s;continue}if(e==="style"){n.value=f(n.value);continue}if(D.has(e)&&/url\s*\(/i.test(n.value))n.value=f(n.value)}}function M(t){let i=t.tagName.toLowerCase();for(let r=t.attributes.length-1;r>=0;r--){let n=t.attributes[r],e=n.name.toLowerCase(),a=e.replace(o,"");if(h.test(a)){t.removeAttribute(n.name);continue}if(d.test(e)||p.test(e))continue;if(!k.has(e)){t.removeAttribute(n.name);continue}if(e==="href"){if(i!=="a"){t.removeAttribute(n.name);continue}let s=n.value.replace(o,"");if(!g.test(s))t.removeAttribute(n.name);continue}if(e==="style")n.value=f(n.value)}}function c(t,i,r){for(let n=t.children.length-1;n>=0;n--){let e=t.children[n],a=e.tagName.toLowerCase();if(i==="svg")if(a==="foreignobject")l(e,r),c(e,"html",r);else if(a==="style"){if(l(e,r),e.textContent)e.textContent=L(e.textContent)}else if(N.has(a)&&z(e))e.remove();else if(v.has(a))l(e,r),c(e,"svg",r);else e.remove();else if(A.has(a))e.remove();else if(y.has(a))M(e),c(e,"html",r);else e.remove()}}function b(t,i){let r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.querySelector("parsererror"))return"";let e=r.documentElement;if(e.tagName.toLowerCase()!=="svg")return"";if(l(e,i),c(e,"svg",i),e.children.length===0)return"";return new XMLSerializer().serializeToString(e)}function yt(t){return b(t,0)}export{yt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{bt,v}from"/chunk-kcactdr4.js";export{bt as loadAppConfig,v as useAppConfig};
|
package/dist/index.html
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
<link rel="modulepreload" href="/vendor/react/19.2.4/production/react-dom-client.js" />
|
|
56
56
|
<link rel="modulepreload" href="/vendor/react/19.2.4/production/_impl/react-dom-client.js" />
|
|
57
57
|
|
|
58
|
-
<link rel="stylesheet" crossorigin href="/chunk-
|
|
58
|
+
<link rel="stylesheet" crossorigin href="/chunk-g4c1nte9.css"><script type="module" crossorigin src="/chunk-a47zy276.js"></script></head>
|
|
59
59
|
<body>
|
|
60
60
|
<div id="root"></div>
|
|
61
61
|
|
package/lib/types.ts
CHANGED
|
@@ -351,7 +351,6 @@ export type AppEnvironment = 'local' | 'cloud'
|
|
|
351
351
|
|
|
352
352
|
export type ClientAppConfig = {
|
|
353
353
|
environment: AppEnvironment
|
|
354
|
-
collab: boolean
|
|
355
354
|
// Demo mode: workspace creation is blocked; the UI offers the
|
|
356
355
|
// cloud-demo promo dialog instead.
|
|
357
356
|
demo: boolean
|
package/package.json
CHANGED
package/server/app-config.ts
CHANGED
|
@@ -18,7 +18,6 @@ import { DATA_DIR } from './data-dir'
|
|
|
18
18
|
// CLI or server down with it.
|
|
19
19
|
export type AppConfig = {
|
|
20
20
|
environment: AppEnvironment
|
|
21
|
-
collab: boolean
|
|
22
21
|
// Demo mode: workspace creation is blocked (UI shows the
|
|
23
22
|
// cloud-demo promo dialog instead) and `moi` system commands are disabled.
|
|
24
23
|
demo: boolean
|
|
@@ -48,8 +47,6 @@ export type CloudflareAccessConfig = {
|
|
|
48
47
|
|
|
49
48
|
const DEFAULTS: AppConfig = {
|
|
50
49
|
environment: 'local',
|
|
51
|
-
// Experimental; deployments opt in explicitly.
|
|
52
|
-
collab: false,
|
|
53
50
|
demo: false,
|
|
54
51
|
demoInstallUrl: 'https://moi.computer',
|
|
55
52
|
cloudflareAccess: null,
|
|
@@ -198,7 +195,6 @@ function fileValues(raw: Record<string, unknown>): Partial<AppConfig> {
|
|
|
198
195
|
const out: Partial<AppConfig> = {}
|
|
199
196
|
const environment = parseEnvironment(raw.environment)
|
|
200
197
|
if (environment !== undefined) out.environment = environment
|
|
201
|
-
if (typeof raw.collab === 'boolean') out.collab = raw.collab
|
|
202
198
|
if (raw.demo !== undefined) {
|
|
203
199
|
if (typeof raw.demo === 'boolean') out.demo = raw.demo
|
|
204
200
|
else warn('ignoring "demo" — expected a boolean')
|
|
@@ -226,7 +222,6 @@ export function loadAppConfig(
|
|
|
226
222
|
const fromEnv: Partial<AppConfig> = {
|
|
227
223
|
environment: parseEnvironment(env.MOI_ENVIRONMENT),
|
|
228
224
|
demo: parseBool(env.MOI_DEMO),
|
|
229
|
-
collab: parseBool(env.MOI_COLLAB),
|
|
230
225
|
demoInstallUrl: parseString(env.MOI_DEMO_INSTALL_URL)
|
|
231
226
|
}
|
|
232
227
|
const merged = { ...DEFAULTS, ...fromFile }
|
|
@@ -264,6 +259,6 @@ export function resetAppConfig(): void {
|
|
|
264
259
|
// The only shape that reaches the browser (GET /api/config). Server-only keys
|
|
265
260
|
// added to AppConfig later stay out unless explicitly forwarded here.
|
|
266
261
|
export function clientAppConfig(): ClientAppConfig {
|
|
267
|
-
const { environment,
|
|
268
|
-
return { environment,
|
|
262
|
+
const { environment, demo, demoInstallUrl } = getAppConfig()
|
|
263
|
+
return { environment, demo, demoInstallUrl }
|
|
269
264
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { mkdir, stat } from 'node:fs/promises'
|
|
2
|
+
import { getAppConfig } from '../app-config'
|
|
2
3
|
import { dirname, join } from 'node:path'
|
|
3
4
|
|
|
4
5
|
export const BASE_DECLARATION_SOURCE_PATH = join(import.meta.dir, 'declarations', 'base.d.ts')
|
|
@@ -33,14 +34,12 @@ export async function syncAppletDeclarations(
|
|
|
33
34
|
const updated: AppletDeclarationFile[] = []
|
|
34
35
|
if (await writeDeclaration(workspacePath, 'base.d.ts')) updated.push('base.d.ts')
|
|
35
36
|
|
|
36
|
-
//
|
|
37
|
-
if (
|
|
37
|
+
// Keep existing applets typecheckable when a cloud workspace is opened locally.
|
|
38
|
+
if (
|
|
39
|
+
getAppConfig().environment === 'cloud' ||
|
|
40
|
+
(await Bun.file(appletDeclarationPath(workspacePath, 'collab.d.ts')).exists())
|
|
41
|
+
) {
|
|
38
42
|
if (await writeDeclaration(workspacePath, 'collab.d.ts')) updated.push('collab.d.ts')
|
|
39
43
|
}
|
|
40
44
|
return updated
|
|
41
45
|
}
|
|
42
|
-
|
|
43
|
-
export async function installCollabDeclaration(workspacePath: string): Promise<void> {
|
|
44
|
-
await writeDeclaration(workspacePath, 'base.d.ts')
|
|
45
|
-
await writeDeclaration(workspacePath, 'collab.d.ts')
|
|
46
|
-
}
|
|
@@ -2,7 +2,6 @@ import type { WorkspaceType } from '@/lib/types'
|
|
|
2
2
|
import { defineCommand } from 'citty'
|
|
3
3
|
import { existsSync } from 'node:fs'
|
|
4
4
|
import { join, resolve } from 'path'
|
|
5
|
-
import { installCollabSkill } from '../../collab/skill'
|
|
6
5
|
import { PORT } from '../../constants'
|
|
7
6
|
import type { DetectedAgent } from '../../harness/detect'
|
|
8
7
|
import {
|
|
@@ -137,11 +136,6 @@ export const init = defineCommand({
|
|
|
137
136
|
default: false,
|
|
138
137
|
description: 'Start the web server if not already running'
|
|
139
138
|
},
|
|
140
|
-
collab: {
|
|
141
|
-
type: 'boolean',
|
|
142
|
-
default: false,
|
|
143
|
-
description: 'Include the optional collaboration guide and applet types'
|
|
144
|
-
},
|
|
145
139
|
id: {
|
|
146
140
|
type: 'string',
|
|
147
141
|
description:
|
|
@@ -204,11 +198,6 @@ export const init = defineCommand({
|
|
|
204
198
|
// package.json + bun install). An existing `.moi/` is left untouched.
|
|
205
199
|
console.log()
|
|
206
200
|
const { scaffold, skillsDir, installLogPath } = await provisionWorkspace(target, type)
|
|
207
|
-
if (args['collab']) {
|
|
208
|
-
const { referencePath } = await installCollabSkill(target, type)
|
|
209
|
-
console.log(pc.dim(' Collaboration guide installed to ' + referencePath))
|
|
210
|
-
console.log(pc.dim(' Live presence is available in the cloud environment'))
|
|
211
|
-
}
|
|
212
201
|
if (scaffold !== 'exists') {
|
|
213
202
|
if (scaffold === 'installing') {
|
|
214
203
|
console.log(pc.dim(' Widget dependencies still installing in .moi/ (background)'))
|
package/server/collab/config.ts
CHANGED
|
@@ -3,15 +3,11 @@ import type { WorkspaceType } from '@/lib/types'
|
|
|
3
3
|
import { getAppConfig } from '../app-config'
|
|
4
4
|
import { collabSkillReferencePath } from './skill'
|
|
5
5
|
|
|
6
|
-
export function isCollabEnabled(): boolean {
|
|
7
|
-
return getAppConfig().collab
|
|
8
|
-
}
|
|
9
|
-
|
|
10
6
|
export async function getCollabReferencePath(
|
|
11
7
|
workspacePath: string,
|
|
12
8
|
type?: WorkspaceType
|
|
13
9
|
): Promise<string | undefined> {
|
|
14
|
-
if (
|
|
10
|
+
if (getAppConfig().environment !== 'cloud') return undefined
|
|
15
11
|
const referencePath = collabSkillReferencePath(workspacePath, type)
|
|
16
12
|
return (await Bun.file(referencePath).exists()) ? referencePath : undefined
|
|
17
13
|
}
|
package/server/collab/manager.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { join, resolve } from 'node:path'
|
|
|
5
5
|
import { COLLAB_MAX_MESSAGE_BYTES, isCollabClientMessage } from '@/lib/collab/protocol'
|
|
6
6
|
import type { CollabClientMessage, CollabServerMessage, UserProfile } from '@/lib/collab/types'
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { getAppConfig } from '../app-config'
|
|
9
9
|
import type { ParentMessage, WorkerMessage } from './worker-messages'
|
|
10
10
|
|
|
11
11
|
export type ClientSocket = {
|
|
@@ -107,7 +107,10 @@ export class CollabManager {
|
|
|
107
107
|
const canonicalPath = await realpath(workspacePath)
|
|
108
108
|
binding.workspacePaths.add(canonicalPath)
|
|
109
109
|
if (binding.closed) throw new CollabRuntimeError('unavailable', 'Collab connection closed')
|
|
110
|
-
|
|
110
|
+
const enabled = this.options.enabled
|
|
111
|
+
? await this.options.enabled(canonicalPath)
|
|
112
|
+
: getAppConfig().environment === 'cloud'
|
|
113
|
+
if (!enabled) {
|
|
111
114
|
throw new CollabRuntimeError(
|
|
112
115
|
'unavailable',
|
|
113
116
|
'Collaboration is only available in the cloud environment'
|
|
@@ -1,53 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dirname, join } from 'node:path'
|
|
3
|
-
|
|
1
|
+
import { join } from 'node:path'
|
|
4
2
|
import type { WorkspaceType } from '@/lib/types'
|
|
5
|
-
|
|
6
|
-
import { appletDeclarationPath, installCollabDeclaration } from '../../applets/declarations'
|
|
7
|
-
import { COLLAB_REFERENCE_SOURCE_PATH } from '../../skills/template'
|
|
8
3
|
import { skillsDirFor } from '../../workspaces/init'
|
|
9
4
|
|
|
10
|
-
export type SkillPaths = { referencePath: string; typesPath: string }
|
|
11
|
-
|
|
12
5
|
export function collabSkillReferencePath(workspacePath: string, type?: WorkspaceType): string {
|
|
13
6
|
return join(skillsDirFor(workspacePath, type), 'moi-workspace', 'references', 'COLLAB.md')
|
|
14
7
|
}
|
|
15
|
-
|
|
16
|
-
function targetPaths(workspacePath: string, type?: WorkspaceType): SkillPaths {
|
|
17
|
-
return {
|
|
18
|
-
referencePath: collabSkillReferencePath(workspacePath, type),
|
|
19
|
-
typesPath: appletDeclarationPath(workspacePath, 'collab.d.ts')
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function writeChanged(path: string, contents: string): Promise<void> {
|
|
24
|
-
const file = Bun.file(path)
|
|
25
|
-
if ((await file.exists()) && (await file.text()) === contents) return
|
|
26
|
-
await mkdir(dirname(path), { recursive: true })
|
|
27
|
-
await Bun.write(path, contents)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Only an explicit `moi init --collab` installs the guide and types.
|
|
31
|
-
export async function installCollabSkill(
|
|
32
|
-
workspacePath: string,
|
|
33
|
-
type?: WorkspaceType
|
|
34
|
-
): Promise<SkillPaths> {
|
|
35
|
-
const source = Bun.file(COLLAB_REFERENCE_SOURCE_PATH)
|
|
36
|
-
if (!(await source.exists())) {
|
|
37
|
-
throw new Error('The collab guide is unavailable in this build: COLLAB.md is missing.')
|
|
38
|
-
}
|
|
39
|
-
const reference = await source.text()
|
|
40
|
-
const paths = targetPaths(workspacePath, type)
|
|
41
|
-
await writeChanged(paths.referencePath, reference)
|
|
42
|
-
await installCollabDeclaration(workspacePath)
|
|
43
|
-
return paths
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function removeCollabSkill(
|
|
47
|
-
workspacePath: string,
|
|
48
|
-
type?: WorkspaceType
|
|
49
|
-
): Promise<void> {
|
|
50
|
-
const paths = targetPaths(workspacePath, type)
|
|
51
|
-
await rm(paths.referencePath, { force: true })
|
|
52
|
-
await rm(paths.typesPath, { force: true })
|
|
53
|
-
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// workspace). Both commands take a fresh or existing directory and lay
|
|
4
4
|
// down the same set of skill folders.
|
|
5
5
|
import { cp, lstat, mkdir, readFile, readdir, readlink } from 'node:fs/promises'
|
|
6
|
+
import { getAppConfig } from '../app-config'
|
|
6
7
|
import { join } from 'node:path'
|
|
7
8
|
|
|
8
9
|
// Resolve relative to this file so source checkouts and published installs agree.
|
|
@@ -19,9 +20,9 @@ export async function bundledSkillNames(): Promise<string[]> {
|
|
|
19
20
|
|
|
20
21
|
export const COLLAB_REFERENCE_SOURCE_PATH = join(BUNDLED_SKILL_DIR, 'references', 'COLLAB.md')
|
|
21
22
|
|
|
22
|
-
//
|
|
23
|
+
// Only cloud workspaces expose live presence to applets.
|
|
23
24
|
function isDefaultSkillFile(source: string): boolean {
|
|
24
|
-
return source !== COLLAB_REFERENCE_SOURCE_PATH
|
|
25
|
+
return source !== COLLAB_REFERENCE_SOURCE_PATH || getAppConfig().environment === 'cloud'
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
async function matchesBundledPath(source: string, target: string, exact = false): Promise<boolean> {
|
package/server/skills/update.ts
CHANGED
|
@@ -80,7 +80,7 @@ async function updateWorkspaceSkillFiles(
|
|
|
80
80
|
}
|
|
81
81
|
const changedSkills = [...new Set(changedSkillPaths.map(path => basename(path)))]
|
|
82
82
|
// Applet declarations ship with the CLI, so refresh installed copies along
|
|
83
|
-
// with skills.
|
|
83
|
+
// with skills.
|
|
84
84
|
const updatedAppletTypes = await syncAppletDeclarations(workspaceRoot)
|
|
85
85
|
const skills = await skillStatuses(workspaceRoot, type)
|
|
86
86
|
|
|
@@ -52,8 +52,6 @@ export async function installWorkspaceSkillFiles(
|
|
|
52
52
|
return (await installBundledSkills(directory)).map(name => join(directory, name))
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
// Both init and updates reset the owned skill. Local additions (including the
|
|
56
|
-
// experimental collab guide) are intentionally discarded; sibling skills stay.
|
|
57
55
|
async function resetWorkspaceSkill(workspaceRoot: string): Promise<string[]> {
|
|
58
56
|
const root = resolve(workspaceRoot)
|
|
59
57
|
const canonical = join(root, '.agents', 'skills', SKILL_NAME)
|
package/server/web.ts
CHANGED
|
@@ -14,7 +14,6 @@ import { harnessStore } from './harness/auth'
|
|
|
14
14
|
import { PORT } from './constants'
|
|
15
15
|
import { control } from './control'
|
|
16
16
|
import { proxyUserState } from './collab/cloudflare-access'
|
|
17
|
-
import { isCollabEnabled } from './collab/config'
|
|
18
17
|
import { collabManager } from './collab/manager'
|
|
19
18
|
import { EVENTS_TOPIC, setEventServer } from './events'
|
|
20
19
|
import { killBuildWorkers } from './applets/build-worker'
|
|
@@ -179,7 +178,7 @@ export const app = Bun.serve<WsData>({
|
|
|
179
178
|
const workspaceId = decodeURIComponent(new URL(req.url).pathname.split('/')[3] ?? '')
|
|
180
179
|
const workspace = await getWorkspace(workspaceId)
|
|
181
180
|
if (!workspace) return new Response('Workspace not found', { status: 404 })
|
|
182
|
-
if (
|
|
181
|
+
if (getAppConfig().environment !== 'cloud') {
|
|
183
182
|
return new Response('Collab is not enabled for this workspace', { status: 403 })
|
|
184
183
|
}
|
|
185
184
|
// Behind Cloudflare Access, presence is joined only as the verified viewer.
|
|
@@ -154,6 +154,7 @@ export async function scaffoldMoiDir(
|
|
|
154
154
|
// Repair path: workspaces scaffolded before `.moi/.gitignore` existed pick
|
|
155
155
|
// it up on the next `moi init` instead of leaking cache files into git.
|
|
156
156
|
await ensureMoiGitignore(workspacePath)
|
|
157
|
+
await syncAppletDeclarations(workspacePath)
|
|
157
158
|
return 'exists'
|
|
158
159
|
}
|
|
159
160
|
// A bare `.moi/` dir without package.json counts as not-bootstrapped —
|
package/skill/SKILL.md
CHANGED
|
@@ -522,4 +522,4 @@ This skill is installed with Moi (via the CLI or the UI) and can fall behind whe
|
|
|
522
522
|
- **Then** — if you updated, mention it.
|
|
523
523
|
|
|
524
524
|
<!-- moi skill version marker — read by `moi skill` to detect drift; do not edit by hand -->
|
|
525
|
-
<moi-skill version="0.20.
|
|
525
|
+
<moi-skill version="0.20.2" />
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { useState, useSyncExternalStore } from 'react'
|
|
2
|
-
|
|
3
|
-
import { IconChevronDown } from '@tabler/icons-react'
|
|
4
|
-
import type { Icon as TabIcon } from '@tabler/icons-react'
|
|
5
|
-
import { useRouter } from 'wouter'
|
|
6
|
-
import { usePathname } from 'wouter/use-browser-location'
|
|
7
|
-
|
|
8
|
-
import { Button } from '@/client/components/ui/button'
|
|
9
|
-
import {
|
|
10
|
-
Popover,
|
|
11
|
-
PopoverContent,
|
|
12
|
-
PopoverTitle,
|
|
13
|
-
PopoverTrigger
|
|
14
|
-
} from '@/client/components/ui/popover'
|
|
15
|
-
import { cn } from '@/client/lib/cn'
|
|
16
|
-
import type { WorkspaceTabId } from '@/lib/types'
|
|
17
|
-
import { tabFromPath } from '@/lib/workspace-tabs'
|
|
18
|
-
|
|
19
|
-
import { UserContainer } from './components/user'
|
|
20
|
-
import { UserAvatarGroupContainer as UserAvatarGroup } from './components/user-avatar-group'
|
|
21
|
-
import { pageFromPath, useCollabEnabled, useCollabEngine } from './provider'
|
|
22
|
-
import { useConnectionState, useWorkspaceUsers } from './hooks'
|
|
23
|
-
import { summarizeWorkspaceUsers } from './users'
|
|
24
|
-
import type { WorkspaceUserInfo } from './users'
|
|
25
|
-
|
|
26
|
-
export type TabInfo = { label: string; Icon: TabIcon }
|
|
27
|
-
type DescribeTab = (tab: WorkspaceTabId) => TabInfo | null
|
|
28
|
-
const USER_STATUS_ORDER = { active: 0, away: 1, offline: 2 }
|
|
29
|
-
|
|
30
|
-
type WorkspaceUsersMenuProps = {
|
|
31
|
-
workspaceId: string
|
|
32
|
-
describeTab: DescribeTab
|
|
33
|
-
onOpenTab: (tab: WorkspaceTabId) => void
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function WorkspaceUsersMenu({
|
|
37
|
-
workspaceId,
|
|
38
|
-
describeTab,
|
|
39
|
-
onOpenTab
|
|
40
|
-
}: WorkspaceUsersMenuProps) {
|
|
41
|
-
const enabled = useCollabEnabled()
|
|
42
|
-
const engine = useCollabEngine()
|
|
43
|
-
const state = useConnectionState()
|
|
44
|
-
const workspaceUsers = useWorkspaceUsers()
|
|
45
|
-
const currentUser = useSyncExternalStore(
|
|
46
|
-
engine.subscribeCurrentUser,
|
|
47
|
-
engine.getCurrentUser,
|
|
48
|
-
engine.getCurrentUser
|
|
49
|
-
)
|
|
50
|
-
const router = useRouter()
|
|
51
|
-
const page = pageFromPath(usePathname(router), workspaceId, router.base)
|
|
52
|
-
const users = summarizeWorkspaceUsers(state.connections, {
|
|
53
|
-
currentUser,
|
|
54
|
-
connectionId: state.connectionId,
|
|
55
|
-
users: workspaceUsers,
|
|
56
|
-
page
|
|
57
|
-
})
|
|
58
|
-
const avatarIds = users
|
|
59
|
-
.filter(user => user.self || user.status !== 'offline')
|
|
60
|
-
.map(user => user.profile.id)
|
|
61
|
-
const [open, setOpen] = useState(false)
|
|
62
|
-
|
|
63
|
-
if (!enabled || workspaceUsers.length <= 1) return null
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<Popover open={open} onOpenChange={setOpen}>
|
|
67
|
-
<PopoverTrigger
|
|
68
|
-
render={
|
|
69
|
-
<Button
|
|
70
|
-
variant="ghost"
|
|
71
|
-
size="sm"
|
|
72
|
-
aria-label="Users in this workspace"
|
|
73
|
-
className="gap-0.5 rounded-full pr-1 pl-1 data-popup-open:bg-accent"
|
|
74
|
-
/>
|
|
75
|
-
}
|
|
76
|
-
>
|
|
77
|
-
<UserAvatarGroup ids={avatarIds} size="xs" max={4} />
|
|
78
|
-
<IconChevronDown stroke={2.5} className="size-3! text-muted-foreground" />
|
|
79
|
-
</PopoverTrigger>
|
|
80
|
-
<PopoverContent align="end" className="max-w-64 p-1">
|
|
81
|
-
<PopoverTitle className="sr-only">Users in this workspace</PopoverTitle>
|
|
82
|
-
<WorkspaceUsersList
|
|
83
|
-
users={users}
|
|
84
|
-
page={page}
|
|
85
|
-
describeTab={describeTab}
|
|
86
|
-
onOpenTab={tab => {
|
|
87
|
-
setOpen(false)
|
|
88
|
-
onOpenTab(tab)
|
|
89
|
-
}}
|
|
90
|
-
/>
|
|
91
|
-
{users.length === 0 && (
|
|
92
|
-
<p className="px-2 py-1 text-xs text-muted-foreground">No workspace users to show.</p>
|
|
93
|
-
)}
|
|
94
|
-
</PopoverContent>
|
|
95
|
-
</Popover>
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
type WorkspaceUsersListProps = {
|
|
100
|
-
users: WorkspaceUserInfo[]
|
|
101
|
-
page: string
|
|
102
|
-
describeTab: DescribeTab
|
|
103
|
-
onOpenTab: (tab: WorkspaceTabId) => void
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function WorkspaceUsersList({
|
|
107
|
-
users,
|
|
108
|
-
page,
|
|
109
|
-
describeTab,
|
|
110
|
-
onOpenTab
|
|
111
|
-
}: WorkspaceUsersListProps) {
|
|
112
|
-
const sorted = users.toSorted(
|
|
113
|
-
(a, b) =>
|
|
114
|
-
USER_STATUS_ORDER[a.status] - USER_STATUS_ORDER[b.status] || Number(b.self) - Number(a.self)
|
|
115
|
-
)
|
|
116
|
-
return (
|
|
117
|
-
<ul className="flex max-h-80 scroll-fade flex-col overflow-y-auto">
|
|
118
|
-
{sorted.map(user => (
|
|
119
|
-
<UserRow
|
|
120
|
-
key={user.profile.id}
|
|
121
|
-
user={user}
|
|
122
|
-
page={page}
|
|
123
|
-
describeTab={describeTab}
|
|
124
|
-
onOpenTab={onOpenTab}
|
|
125
|
-
/>
|
|
126
|
-
))}
|
|
127
|
-
</ul>
|
|
128
|
-
)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
type UserRowProps = Omit<WorkspaceUsersListProps, 'users'> & { user: WorkspaceUserInfo }
|
|
132
|
-
|
|
133
|
-
function UserRow({ user, page, describeTab, onOpenTab }: UserRowProps) {
|
|
134
|
-
const tabs = user.pages.map(candidate => {
|
|
135
|
-
const tab = tabFromPath(candidate)
|
|
136
|
-
return { tab, info: tab ? describeTab(tab) : null }
|
|
137
|
-
})
|
|
138
|
-
const destination =
|
|
139
|
-
user.self || user.status === 'offline'
|
|
140
|
-
? undefined
|
|
141
|
-
: tabs.find(({ tab, info }) => tab !== null && info !== null && tab !== page)
|
|
142
|
-
const target = destination?.tab
|
|
143
|
-
const labels = [
|
|
144
|
-
...new Set(tabs.map(({ tab, info }) => info?.label ?? tab ?? 'Another tab'))
|
|
145
|
-
].join(', ')
|
|
146
|
-
const where =
|
|
147
|
-
user.status === 'offline'
|
|
148
|
-
? 'Offline'
|
|
149
|
-
: user.status === 'away'
|
|
150
|
-
? labels
|
|
151
|
-
? `${labels} · Away`
|
|
152
|
-
: 'Away'
|
|
153
|
-
: labels || 'Another tab'
|
|
154
|
-
const Icon = user.status === 'offline' ? undefined : tabs[0]?.info?.Icon
|
|
155
|
-
const content = (
|
|
156
|
-
<UserContainer
|
|
157
|
-
id={user.profile.id}
|
|
158
|
-
className="flex-1"
|
|
159
|
-
size="sm"
|
|
160
|
-
showYouLabel
|
|
161
|
-
description={
|
|
162
|
-
<span className="flex items-center gap-1 text-xs">
|
|
163
|
-
{Icon && <Icon size={12} stroke={1.75} className="shrink-0" />}
|
|
164
|
-
<span className="truncate">{where}</span>
|
|
165
|
-
</span>
|
|
166
|
-
}
|
|
167
|
-
/>
|
|
168
|
-
)
|
|
169
|
-
const row = 'flex w-full items-center gap-2.5 rounded-md px-2 py-1 text-left'
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<li>
|
|
173
|
-
{target ? (
|
|
174
|
-
<button
|
|
175
|
-
type="button"
|
|
176
|
-
title={`Go to ${destination?.info?.label}`}
|
|
177
|
-
className={cn(
|
|
178
|
-
row,
|
|
179
|
-
'cursor-pointer outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50'
|
|
180
|
-
)}
|
|
181
|
-
onClick={() => onOpenTab(target)}
|
|
182
|
-
>
|
|
183
|
-
{content}
|
|
184
|
-
</button>
|
|
185
|
-
) : (
|
|
186
|
-
<div className={row}>{content}</div>
|
|
187
|
-
)}
|
|
188
|
-
</li>
|
|
189
|
-
)
|
|
190
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { useRef, type ReactNode } from 'react'
|
|
2
|
-
import { useMutation } from '@tanstack/react-query'
|
|
3
|
-
import { IconLoader } from '@tabler/icons-react'
|
|
4
|
-
import { Button } from '@/client/components/ui/button'
|
|
5
|
-
import { toast } from '@/client/components/ui/toast'
|
|
6
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
7
|
-
import { useAccount } from '../account/account-provider'
|
|
8
|
-
|
|
9
|
-
type CloudAvatarUploadProps = { children: ReactNode }
|
|
10
|
-
|
|
11
|
-
export function CloudAvatarUpload({ children }: CloudAvatarUploadProps) {
|
|
12
|
-
const account = useAccount()
|
|
13
|
-
const input = useRef<HTMLInputElement>(null)
|
|
14
|
-
const upload = useMutation({
|
|
15
|
-
mutationFn: (file: File) => account.saveAvatar(file),
|
|
16
|
-
onSuccess: () => toast.add({ title: 'Avatar updated', type: 'success' }),
|
|
17
|
-
onError: error =>
|
|
18
|
-
toast.add({ title: 'Couldn’t update avatar', description: error.message, type: 'error' })
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<>
|
|
23
|
-
<input
|
|
24
|
-
ref={input}
|
|
25
|
-
type="file"
|
|
26
|
-
accept="image/*"
|
|
27
|
-
aria-label="Choose an avatar file"
|
|
28
|
-
className="hidden"
|
|
29
|
-
disabled={upload.isPending}
|
|
30
|
-
onChange={event => {
|
|
31
|
-
const file = event.currentTarget.files?.[0]
|
|
32
|
-
event.currentTarget.value = ''
|
|
33
|
-
if (file) upload.mutate(file)
|
|
34
|
-
}}
|
|
35
|
-
/>
|
|
36
|
-
<Tooltip>
|
|
37
|
-
<TooltipTrigger
|
|
38
|
-
render={
|
|
39
|
-
<Button
|
|
40
|
-
variant="ghost"
|
|
41
|
-
size="icon"
|
|
42
|
-
className="rounded-full"
|
|
43
|
-
aria-label="Change your avatar"
|
|
44
|
-
aria-busy={upload.isPending}
|
|
45
|
-
disabled={upload.isPending || !account.registered}
|
|
46
|
-
onClick={() => input.current?.click()}
|
|
47
|
-
/>
|
|
48
|
-
}
|
|
49
|
-
>
|
|
50
|
-
{upload.isPending ? <IconLoader className="animate-spin" stroke={1.5} /> : children}
|
|
51
|
-
</TooltipTrigger>
|
|
52
|
-
<TooltipContent>
|
|
53
|
-
{upload.isPending ? 'Updating avatar…' : 'Change your avatar'}
|
|
54
|
-
</TooltipContent>
|
|
55
|
-
</Tooltip>
|
|
56
|
-
</>
|
|
57
|
-
)
|
|
58
|
-
}
|