diff --git a/README.md b/README.md
index 75ff151..7f8f542 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
# OpenCode Backdrop
-
Use your own wallpapers in OpenCode Desktop. Supports OpenCode 2.2.6 and later 2.2.x versions through the GUI plugin API.
+Use your own wallpapers in OpenCode Desktop. Supports OpenCode 2.2.x from 2.2.6 and 2.3.x from 2.3.2 through the GUI plugin API.
## Install
```sh
-opencode plugin add 'github:viralcodex/opencode-backdrop#v0.1.0'
+opencode plugin add 'github:viralcodex/opencode-backdrop#v0.2.0'
```
This installs the plugin globally. Alternatively, add it to your global `opencode.json` or `opencode.jsonc`, keeping any existing plugins. Do not add it to `cli.json`.
@@ -14,7 +14,7 @@ This installs the plugin globally. Alternatively, add it to your global `opencod
```jsonc
{
"$schema": "https://opencode.ai/config.json",
- "plugins": ["github:viralcodex/opencode-backdrop#v0.1.0"],
+ "plugins": ["github:viralcodex/opencode-backdrop#v0.2.0"],
}
```
@@ -28,9 +28,11 @@ Wallpaper starts off with an empty gallery. Images and preferences stay local, a
- Folder images support PNG, JPEG, WebP and SVG, including subfolders. Changes appear automatically.
- Uploads support PNG, JPEG and WebP.
+- The gallery shows at most two rows, including the **+** tile. Use **Show more** to see all images, or **Show less** to collapse it.
- More tint improves text contrast. **Fill background** crops the image; **Show whole image** keeps it fully visible.
- Use `/wallpaper` in chat to switch images or turn wallpaper off. Escape cancels the picker.
- Turn **Show wallpaper** off to restore the app's backgrounds without losing your choices.
+- Turn **Wallpaper slideshow** on to cycle through all gallery images in order. Choose **None** or **Fade** in the transition dropdown and set **Display time** in seconds, from 5 to 86400. The default is 60 seconds. Slideshow needs at least two images, and fades respect reduced-motion settings.
To remove an upload, hover or focus its tile and click **X**. Remove folder images by moving or deleting their source files.
@@ -43,7 +45,7 @@ You can set an initial folder with an absolute path instead of choosing one in S
"$schema": "https://opencode.ai/config.json",
"plugins": [
{
- "package": "github:viralcodex/opencode-backdrop#v0.1.0",
+ "package": "github:viralcodex/opencode-backdrop#v0.2.0",
"options": { "folder": "/absolute/path/to/wallpapers" },
},
],
diff --git a/bun.lock b/bun.lock
index 92b180f..0799a01 100644
--- a/bun.lock
+++ b/bun.lock
@@ -15,7 +15,7 @@
"vite-plugin-solid": "2.11.10",
},
"peerDependencies": {
- "@opencode/plugin": "~2.2.6 || ^0.0.0-dev",
+ "@opencode/plugin": "~2.2.6 || ~2.3.2 || ^0.0.0-dev",
"effect": "^4.1.0",
"solid-js": "^1.9.17",
},
diff --git a/dist/gui-experimental.cjs b/dist/gui-experimental.cjs
index ac8e192..a15e8e0 100644
--- a/dist/gui-experimental.cjs
+++ b/dist/gui-experimental.cjs
@@ -1,12 +1,12 @@
-"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("solid-js/web"),R=require("@opencode/plugin/gui"),k=require("solid-js"),p=require("effect"),Z=require("solid-js/store"),W=require("node:fs/promises"),L=require("node:path"),ce=require("node:os"),z=8*1024*1024,de=p.Schema.Struct({id:p.Schema.String,title:p.Schema.String,version:p.Schema.String}),pe=p.Schema.Struct({id:p.Schema.String,version:p.Schema.String}),J=R.Ipc.define({id:"wallpaper.catalog.v5",state:p.Schema.Struct({folder:p.Schema.String,folderLabel:p.Schema.optional(p.Schema.String),ready:p.Schema.Boolean,images:p.Schema.Array(de),error:p.Schema.String}),methods:{refresh:{output:p.Schema.Boolean},setFolder:{input:p.Schema.NonEmptyString,output:p.Schema.Boolean},read:{input:pe,output:p.Schema.String}}}),ue=/^[A-Za-z0-9+/]+={0,2}$/,ge=new Set(["image/png","image/jpeg","image/webp"]),X=p.Schema.String.check(p.Schema.isPattern(/^(?:data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2})?$/),p.Schema.isMaxLength(23+4*Math.ceil(z/3)),p.Schema.makeFilter(e=>{const t=q(e);return!e||t.length%4===0&&Y(t)<=z}));function me(e){if(!ge.has(e.type))throw new Error("image.typeError");if(e.size===0||e.size>z)throw new Error("image.sizeError")}function Q(e){const t=/^data:(image\/(?:png|jpeg|webp|svg\+xml))(;base64)?,([\s\S]+)$/.exec(e);if(!t)throw new Error("image.decodeError");const[,o,l,r]=t;if(l&&(r.length%4!==0||Y(r)>z||!ue.test(r)))throw new Error("image.decodeError");if(!l&&o!=="image/svg+xml")throw new Error("image.decodeError");try{const n=new Blob([l?Uint8Array.from(atob(r),c=>c.charCodeAt(0)):decodeURIComponent(r)],{type:o});if(n.size===0||n.size>z)throw new Error("image.decodeError");return n}catch(n){throw new Error("image.decodeError",{cause:n})}}async function G(e,t){t.throwIfAborted();const o=new Image,l=()=>{o.src=""};t.addEventListener("abort",l,{once:!0});try{return o.src=e,await o.decode(),t.throwIfAborted(),o}catch(r){throw t.throwIfAborted(),new Error("image.decodeError",{cause:r})}finally{t.removeEventListener("abort",l)}}async function he(e,t){t.throwIfAborted();const o=URL.createObjectURL(Q(e));try{const l=await G(o,t),r=document.createElement("canvas"),n=Math.min(1,320/l.naturalWidth,200/l.naturalHeight);r.width=Math.max(1,Math.round(l.naturalWidth*n)),r.height=Math.max(1,Math.round(l.naturalHeight*n));const c=r.getContext("2d");if(!c)throw new Error("image.decodeError");c.drawImage(l,0,0,r.width,r.height);const d=await new Promise((u,g)=>{r.toBlob(v=>v?u(v):g(new Error("image.decodeError")),"image/png")});return t.throwIfAborted(),{blob:d,width:r.width,height:r.height}}finally{URL.revokeObjectURL(o)}}async function fe(e,t){t.throwIfAborted(),me(e);const o=URL.createObjectURL(e);try{await G(o,t)}finally{URL.revokeObjectURL(o)}return t.throwIfAborted(),new Promise((l,r)=>{const n=new FileReader,c=()=>n.abort(),d=()=>t.removeEventListener("abort",c);n.onload=()=>{d(),typeof n.result!="string"?r(new Error("image.readError")):l(n.result)},n.onerror=()=>{d(),r(new Error("image.readError"))},n.onabort=()=>{d(),r(t.reason)},t.addEventListener("abort",c,{once:!0});try{n.readAsDataURL(e)}catch(u){d(),r(new Error("image.readError",{cause:u}))}})}function B(e,t){return e.startsWith("image.")?t(e):`${t("image.readError")} ${e}`}function q(e){return e.slice(e.indexOf(",")+1)}function Y(e){return e.length/4*3-(e.endsWith("==")?2:e.endsWith("=")?1:0)}const M={tint:{min:0,max:100,initial:80},brightness:{min:25,max:150,initial:100}},ee=["tint","brightness"],be=p.Schema.Struct({id:p.Schema.String.check(p.Schema.isPattern(/^upload:.+$/)),name:p.Schema.String.check(p.Schema.isMinLength(1)),image:X.check(p.Schema.isMinLength(1))}),we=p.Schema.Struct({enabled:p.Schema.Boolean,preset:p.Schema.String,image:X,imageName:p.Schema.optional(p.Schema.String),images:p.Schema.optional(p.Schema.Array(be)),tint:p.Schema.optional(p.Schema.Int.check(p.Schema.isBetween({minimum:M.tint.min,maximum:M.tint.max}))),brightness:p.Schema.optional(p.Schema.Int.check(p.Schema.isBetween({minimum:M.brightness.min,maximum:M.brightness.max}))),fit:p.Schema.Literals(["cover","contain"]),strength:p.Schema.Int.check(p.Schema.isBetween({minimum:5,maximum:45})),hidden:p.Schema.optional(p.Schema.Array(p.Schema.String))}),H={enabled:!1,preset:"",image:"",strength:100-M.tint.initial,fit:"cover"};function te(e){return{tint:e.tint??100-e.strength,brightness:e.brightness??M.brightness.initial}}function T(e,t){return e?.id===t?.id&&e?.version===t?.version&&e?.image===t?.image}function ae(e,t){return t.find(o=>o.id===e.preset)}function re(e){const t=e.images??[];return e.image?[{id:"custom",name:e.imageName??"",image:e.image},...t]:t}function ve(e=[],t=H,o=[]){const l=new Map(o.map(r=>[r.id,r]));return[...e,...re(t).map(r=>{const n=oe(r.name),c=l.get(r.id);return c?.image===r.image&&c.title===n?c:{id:r.id,title:n,version:"custom",image:r.image}})]}function V(e){return e.id==="custom"||e.id.startsWith("upload:")}function ye(e,t,o){if(!V(t)||(t.id==="custom"?(e.image="",delete e.imageName):e.images=e.images?.filter(r=>r.id!==t.id),e.preset!==t.id))return;const l=o[o.findIndex(r=>r.id===t.id)+1]??o.find(r=>r.id!==t.id);e.preset=l?.id??H.preset,l||(e.enabled=!1)}function N(e,t){e.enabled=t!=="off",t!=="off"&&(e.preset=t)}function j(e,t){return V(e)?e.title||t("image.custom"):e.title}function K(e,t,o){const l=_(e.name),r=q(e.image??"");for(const n of re(t)){if(n.name&&_(n.name)===l)throw new Error("image.duplicateName");if(r&&r===q(n.image))throw new Error("image.duplicateImage")}for(const n of o){const c=Se(n.id);if(c&&_(c)===l)throw new Error("image.duplicateName")}}function Se(e){if(!e.startsWith("file:"))return"";const t=e.slice(5);try{return decodeURIComponent(t)}catch{return t}}function _(e){return oe(e).normalize("NFC").toLowerCase()}function oe(e){const t=(e.split(/[\\/]/).at(-1)??e).trim();return t.replace(/\.(?:png|jpe?g|webp|svg)$/i,"")||t}function ke(e,t,o){return{id:"choose",title:e.t("picker.title"),description:e.t("picker.description"),keywords:"wallpaper background image",slash:{name:"wallpaper"},async run(){if(e.signal.aborted||(await o(),e.signal.aborted))return;const l=e.stores.preferences,r=await e.dialogs.select({title:e.t("picker.title"),placeholder:e.t("picker.search"),current:l.value.enabled?l.value.preset:"off",options:[...t().map(n=>({title:j(n,e.t),value:n.id})),{title:e.t("picker.off"),value:"off"},{title:e.t("picker.settings"),value:"settings"}]});if(!(!r||e.signal.aborted)){if(r==="settings"){e.layout.settings("wallpaper");return}l.update(n=>{N(n,r)})}}}}function ne(e){return k.createMemo(()=>{const t=e();return t?{...t}:void 0},void 0,{equals:T})}function $e(e,t){const[o,l]=Z.createStore({url:"",width:0,height:0,loading:!1,error:""}),r=ne(e);return k.createEffect(()=>{const n=r(),c=new AbortController;let d="";k.onCleanup(()=>{c.abort(),d&&URL.revokeObjectURL(d)}),l({url:"",width:0,height:0,loading:!!n,error:""}),n&&(async()=>{try{const u=n.image??await t(n,c.signal);c.signal.throwIfAborted(),d=URL.createObjectURL(Q(u));const g=await G(d,c.signal);l({url:d,width:g.naturalWidth,height:g.naturalHeight,loading:!1,error:""})}catch(u){d&&URL.revokeObjectURL(d),d="",c.signal.aborted||l({url:"",loading:!1,error:u instanceof Error?u.message:String(u)})}})()}),o}function Ee(e,t){const[o,l]=Z.createStore({url:"",width:0,height:0,loading:!1,error:""}),r=ne(e);return k.createRenderEffect(()=>{const n=r(),c=new AbortController;let d;if(k.onCleanup(()=>{c.abort(),d?.release()}),l({url:"",width:0,height:0,loading:!!n,error:""}),!!n)try{if(d=t.acquire(n),d.value){l({...d.value,loading:!1});return}d.ready.then(u=>{c.signal.aborted||l({...u,loading:!1})},u=>{c.signal.aborted||l({loading:!1,error:u instanceof Error?u.message:String(u)})})}catch(u){l({loading:!1,error:u instanceof Error?u.message:String(u)})}}),o}function xe(e){const t=new Map;return(o,l,r)=>{const n=t.get(o)??new Set,c=r.filter(d=>!d||n.has(d)?!1:(n.add(d),!0));t.set(o,n),c.length&&e.show({variant:"error",icon:"outline-photo",title:l,description:c.join(`
+"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("solid-js/web"),q=require("@opencode/plugin/gui"),g=require("solid-js"),p=require("effect"),se=require("solid-js/store"),N=require("node:fs/promises"),U=require("node:path"),ye=require("node:os"),D=8*1024*1024,Se=p.Schema.Struct({id:p.Schema.String,title:p.Schema.String,version:p.Schema.String}),ke=p.Schema.Struct({id:p.Schema.String,version:p.Schema.String}),oe=q.Ipc.define({id:"wallpaper.catalog.v5",state:p.Schema.Struct({folder:p.Schema.String,folderLabel:p.Schema.optional(p.Schema.String),ready:p.Schema.Boolean,images:p.Schema.Array(Se),error:p.Schema.String}),methods:{refresh:{output:p.Schema.Boolean},setFolder:{input:p.Schema.NonEmptyString,output:p.Schema.Boolean},read:{input:ke,output:p.Schema.String}}}),xe=/^[A-Za-z0-9+/]+={0,2}$/,$e=new Set(["image/png","image/jpeg","image/webp"]),ce=p.Schema.String.check(p.Schema.isPattern(/^(?:data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2})?$/),p.Schema.isMaxLength(23+4*Math.ceil(D/3)),p.Schema.makeFilter(e=>{const t=Q(e);return!e||t.length%4===0&&pe(t)<=D}));function Ce(e){if(!$e.has(e.type))throw new Error("image.typeError");if(e.size===0||e.size>D)throw new Error("image.sizeError")}function de(e){const t=/^data:(image\/(?:png|jpeg|webp|svg\+xml))(;base64)?,([\s\S]+)$/.exec(e);if(!t)throw new Error("image.decodeError");const[,r,l,a]=t;if(l&&(a.length%4!==0||pe(a)>D||!xe.test(a)))throw new Error("image.decodeError");if(!l&&r!=="image/svg+xml")throw new Error("image.decodeError");try{const o=new Blob([l?Uint8Array.from(atob(a),s=>s.charCodeAt(0)):decodeURIComponent(a)],{type:r});if(o.size===0||o.size>D)throw new Error("image.decodeError");return o}catch(o){throw new Error("image.decodeError",{cause:o})}}async function ee(e,t){t.throwIfAborted();const r=new Image,l=()=>{r.src=""};t.addEventListener("abort",l,{once:!0});try{return r.src=e,await r.decode(),t.throwIfAborted(),r}catch(a){throw t.throwIfAborted(),new Error("image.decodeError",{cause:a})}finally{t.removeEventListener("abort",l)}}async function Ee(e,t){t.throwIfAborted();const r=URL.createObjectURL(de(e));try{const l=await ee(r,t),a=document.createElement("canvas"),o=Math.min(1,320/l.naturalWidth,200/l.naturalHeight);a.width=Math.max(1,Math.round(l.naturalWidth*o)),a.height=Math.max(1,Math.round(l.naturalHeight*o));const s=a.getContext("2d");if(!s)throw new Error("image.decodeError");s.drawImage(l,0,0,a.width,a.height);const d=await new Promise((c,b)=>{a.toBlob(x=>x?c(x):b(new Error("image.decodeError")),"image/png")});return t.throwIfAborted(),{blob:d,width:a.width,height:a.height}}finally{URL.revokeObjectURL(r)}}async function Ae(e,t){t.throwIfAborted(),Ce(e);const r=URL.createObjectURL(e);try{await ee(r,t)}finally{URL.revokeObjectURL(r)}return t.throwIfAborted(),new Promise((l,a)=>{const o=new FileReader,s=()=>o.abort(),d=()=>t.removeEventListener("abort",s);o.onload=()=>{d(),typeof o.result!="string"?a(new Error("image.readError")):l(o.result)},o.onerror=()=>{d(),a(new Error("image.readError"))},o.onabort=()=>{d(),a(t.reason)},t.addEventListener("abort",s,{once:!0});try{o.readAsDataURL(e)}catch(c){d(),a(new Error("image.readError",{cause:c}))}})}function X(e,t){return e.startsWith("image.")?t(e):`${t("image.readError")} ${e}`}function Q(e){return e.slice(e.indexOf(",")+1)}function pe(e){return e.length/4*3-(e.endsWith("==")?2:e.endsWith("=")?1:0)}const O={tint:{min:0,max:100,initial:80},brightness:{min:25,max:150,initial:100}},ue=["tint","brightness"],_={min:5,max:86400,duration:60,transition:"fade"},Le=800,Re=p.Schema.Struct({id:p.Schema.String.check(p.Schema.isPattern(/^upload:.+$/)),name:p.Schema.String.check(p.Schema.isMinLength(1)),image:ce.check(p.Schema.isMinLength(1))}),Me=p.Schema.Struct({enabled:p.Schema.Boolean,preset:p.Schema.String,image:ce,imageName:p.Schema.optional(p.Schema.String),images:p.Schema.optional(p.Schema.Array(Re)),tint:p.Schema.optional(p.Schema.Int.check(p.Schema.isBetween({minimum:O.tint.min,maximum:O.tint.max}))),brightness:p.Schema.optional(p.Schema.Int.check(p.Schema.isBetween({minimum:O.brightness.min,maximum:O.brightness.max}))),fit:p.Schema.Literals(["cover","contain"]),slideshow:p.Schema.optional(p.Schema.Boolean),duration:p.Schema.optional(p.Schema.Int.check(p.Schema.isBetween({minimum:_.min,maximum:_.max}))),transition:p.Schema.optional(p.Schema.Literals(["none","fade"])),strength:p.Schema.Int.check(p.Schema.isBetween({minimum:5,maximum:45})),hidden:p.Schema.optional(p.Schema.Array(p.Schema.String))}),te={enabled:!1,preset:"",image:"",strength:100-O.tint.initial,fit:"cover"};function ge(e){return{tint:e.tint??100-e.strength,brightness:e.brightness??O.brightness.initial}}function V(e,t){return e?.id===t?.id&&e?.version===t?.version&&e?.image===t?.image}function Y(e,t){return t.find(r=>r.id===e.preset)}function me(e){const t=e.images??[];return e.image?[{id:"custom",name:e.imageName??"",image:e.image},...t]:t}function Ie(e=[],t=te,r=[]){const l=new Map(r.map(a=>[a.id,a]));return[...e,...me(t).map(a=>{const o=fe(a.name),s=l.get(a.id);return s?.image===a.image&&s.title===o?s:{id:a.id,title:o,version:"custom",image:a.image}})]}function ae(e){return e.id==="custom"||e.id.startsWith("upload:")}function ze(e,t,r){if(!ae(t)||(t.id==="custom"?(e.image="",delete e.imageName):e.images=e.images?.filter(a=>a.id!==t.id),e.preset!==t.id))return;const l=r[r.findIndex(a=>a.id===t.id)+1]??r.find(a=>a.id!==t.id);e.preset=l?.id??te.preset,l||(e.enabled=!1)}function he(e,t){e.enabled=t!=="off",t!=="off"&&(e.preset=t)}function G(e,t){return ae(e)?e.title||t("image.custom"):e.title}function ie(e,t,r){const l=J(e.name),a=Q(e.image??"");for(const o of me(t)){if(o.name&&J(o.name)===l)throw new Error("image.duplicateName");if(a&&a===Q(o.image))throw new Error("image.duplicateImage")}for(const o of r){const s=We(o.id);if(s&&J(s)===l)throw new Error("image.duplicateName")}}function We(e){if(!e.startsWith("file:"))return"";const t=e.slice(5);try{return decodeURIComponent(t)}catch{return t}}function J(e){return fe(e).normalize("NFC").toLowerCase()}function fe(e){const t=(e.split(/[\\/]/).at(-1)??e).trim();return t.replace(/\.(?:png|jpe?g|webp|svg)$/i,"")||t}function Ue(e,t,r,l,a){return{id:"choose",title:e.t("picker.title"),description:e.t("picker.description"),keywords:"wallpaper background image",slash:{name:"wallpaper"},async run(){if(e.signal.aborted||(await r(),e.signal.aborted))return;const o=await e.dialogs.select({title:e.t("picker.title"),placeholder:e.t("picker.search"),current:l(),options:[...t().map(s=>({title:G(s,e.t),value:s.id})),{title:e.t("picker.off"),value:"off"},{title:e.t("picker.settings"),value:"settings"}]});if(!(!o||e.signal.aborted)){if(o==="settings"){e.layout.settings("wallpaper");return}a(o)}}}}function we(e){return g.createMemo(()=>{const t=e();return t?{...t}:void 0},void 0,{equals:V})}function je(e,t,r=()=>0){const[l,a]=se.createStore({url:"",width:0,height:0,loading:!1,error:"",previous:void 0,transition:0});let o,s,d;const c=()=>{clearTimeout(d),d=void 0,s&&URL.revokeObjectURL(s.url),s=void 0,a({previous:void 0,transition:0})};g.onCleanup(()=>{c(),o&&URL.revokeObjectURL(o.url)});const b=we(e);return g.createEffect(()=>{const x=b(),$=new AbortController;let k="";if(g.onCleanup(()=>{$.abort(),k&&URL.revokeObjectURL(k),k=""}),a({loading:!!x,error:""}),!x){c(),o&&URL.revokeObjectURL(o.url),o=void 0,a({url:"",width:0,height:0});return}(async()=>{try{const u=x.image??await t(x,$.signal);$.signal.throwIfAborted(),k=URL.createObjectURL(de(u));const C=await ee(k,$.signal);$.signal.throwIfAborted(),c();const L=g.untrack(r);o&&L>0?s=o:o&&URL.revokeObjectURL(o.url),o={url:k,width:C.naturalWidth,height:C.naturalHeight},k="",a({...o,previous:s,transition:s?L:0,loading:!1,error:""}),s&&(d=setTimeout(c,L))}catch(u){k&&URL.revokeObjectURL(k),k="",$.signal.aborted||a({loading:!1,error:u instanceof Error?u.message:String(u)})}})()}),l}function _e(e,t){const[r,l]=se.createStore({url:"",width:0,height:0,loading:!1,error:""}),a=we(e);return g.createRenderEffect(()=>{const o=a(),s=new AbortController;let d;if(g.onCleanup(()=>{s.abort(),d?.release()}),l({url:"",width:0,height:0,loading:!!o,error:""}),!!o)try{if(d=t.acquire(o),d.value){l({...d.value,loading:!1});return}d.ready.then(c=>{s.signal.aborted||l({...c,loading:!1})},c=>{s.signal.aborted||l({loading:!1,error:c instanceof Error?c.message:String(c)})})}catch(c){l({loading:!1,error:c instanceof Error?c.message:String(c)})}}),r}function Pe(e){const t=new Map;return(r,l,a)=>{const o=t.get(r)??new Set,s=a.filter(d=>!d||o.has(d)?!1:(o.add(d),!0));t.set(r,o),s.length&&e.show({variant:"error",icon:"outline-photo",title:l,description:s.join(`
-`)})}}function Ce(e,{maxEntries:t=48,maxBytes:o=8*1024*1024,concurrency:l=2,signal:r}={}){const n=new Map,c=new Set,d=new Map,u=new Set;let g=0,v=0,w=!1;function $(a){const m=d.get(a);m!==void 0&&(d.delete(a),g-=m)}function b(a){$(a),a.value&&URL.revokeObjectURL(a.value.url),a.value=void 0,c.delete(a)}function E(a){a.retired||($(a),u.delete(a),n.get(a.choice.id)===a&&n.delete(a.choice.id),a.retired=!0,a.controller.abort(),a.reject(a.controller.signal.reason),a.users?c.add(a):b(a))}function y(a){if(!(a.users||a.retired))for($(a),d.set(a,a.bytes),g+=a.bytes;d.size>t||g>o;){const m=d.keys().next().value;if(!m)break;E(m)}}function f(){for(;!w&&v(a.controller.signal.throwIfAborted(),e(a.choice,a.controller.signal))).then(m=>{a.controller.signal.throwIfAborted(),a.value={url:URL.createObjectURL(m.blob),width:m.width,height:m.height},a.bytes=m.blob.size,a.resolve(a.value),y(a)}).catch(m=>{a.reject(m),E(a)}).finally(()=>{v--,f()})}}function i(a){if(w)throw new DOMException("Thumbnail cache is disposed.","AbortError");let m=n.get(a.id);if(m&&!T(m.choice,a)&&(E(m),m=void 0),!m){let C,A;const I=new Promise((U,se)=>{C=U,A=se});m={choice:{...a},controller:new AbortController,ready:I,resolve:C,reject:A,users:0,bytes:0,retired:!1},u.add(m)}const S=m;$(S),S.users++,n.set(a.id,S),f();let x=!1;return{value:S.value,ready:S.ready,release(){x||(x=!0,S.users--,S.retired&&!S.users?b(S):y(S))}}}function h(){if(!w){w=!0,r?.removeEventListener("abort",h);for(const a of new Set([...n.values(),...c]))E(a),b(a);n.clear(),c.clear(),d.clear(),g=0,u.clear()}}return r?.addEventListener("abort",h,{once:!0}),r?.aborted&&h(),{acquire:i,peek(a){const m=n.get(a.id);return m&&T(m.choice,a)?m.value:void 0},retain(a){const m=new Map(a.map(S=>[S.id,S]));for(const S of n.values())T(S.choice,m.get(S.choice.id))||E(S)},dispose:h}}const P='[data-slot="home-panel"], [data-slot="session-chat-panel"] > .bg-v2-background-bg-base, [data-component="new-session"]',Ae=`
+`)})}}function Te(e,{maxEntries:t=48,maxBytes:r=8*1024*1024,concurrency:l=2,signal:a}={}){const o=new Map,s=new Set,d=new Map,c=new Set;let b=0,x=0,$=!1;function k(n){const h=d.get(n);h!==void 0&&(d.delete(n),b-=h)}function u(n){k(n),n.value&&URL.revokeObjectURL(n.value.url),n.value=void 0,s.delete(n)}function C(n){n.retired||(k(n),c.delete(n),o.get(n.choice.id)===n&&o.delete(n.choice.id),n.retired=!0,n.controller.abort(),n.reject(n.controller.signal.reason),n.users?s.add(n):u(n))}function L(n){if(!(n.users||n.retired))for(k(n),d.set(n,n.bytes),b+=n.bytes;d.size>t||b>r;){const h=d.keys().next().value;if(!h)break;C(h)}}function v(){for(;!$&&x(n.controller.signal.throwIfAborted(),e(n.choice,n.controller.signal))).then(h=>{n.controller.signal.throwIfAborted(),n.value={url:URL.createObjectURL(h.blob),width:h.width,height:h.height},n.bytes=h.blob.size,n.resolve(n.value),L(n)}).catch(h=>{n.reject(h),C(n)}).finally(()=>{x--,v()})}}function y(n){if($)throw new DOMException("Thumbnail cache is disposed.","AbortError");let h=o.get(n.id);if(h&&!V(h.choice,n)&&(C(h),h=void 0),!h){let T,H;const z=new Promise((f,w)=>{T=f,H=w});h={choice:{...n},controller:new AbortController,ready:z,resolve:T,reject:H,users:0,bytes:0,retired:!1},c.add(h)}const A=h;k(A),A.users++,o.set(n.id,A),v();let j=!1;return{value:A.value,ready:A.ready,release(){j||(j=!0,A.users--,A.retired&&!A.users?u(A):L(A))}}}function E(){if(!$){$=!0,a?.removeEventListener("abort",E);for(const n of new Set([...o.values(),...s]))C(n),u(n);o.clear(),s.clear(),d.clear(),b=0,c.clear()}}return a?.addEventListener("abort",E,{once:!0}),a?.aborted&&E(),{acquire:y,peek(n){const h=o.get(n.id);return h&&V(h.choice,n)?h.value:void 0},retain(n){const h=new Map(n.map(A=>[A.id,A]));for(const A of o.values())V(A.choice,h.get(A.choice.id))||C(A)},dispose:E}}const P='[data-slot="home-panel"], [data-slot="session-chat-panel"] > .bg-v2-background-bg-base, [data-component="new-session"]',be=`
[data-slot="home-panel"] .sticky.bg-v2-background-bg-base,
[data-slot="session-chat-panel"] [data-session-title] > .bg-v2-background-bg-base,
[data-slot="session-chat-panel"] [data-slot="session-location-bar"],
[data-slot="session-chat-panel"] [data-component="collapsed-tool-group"] > [data-component="collapsible"] > [data-slot="collapsible-trigger"][aria-expanded="true"],
[data-slot="session-chat-panel"] :is([data-component="edit-tool"], [data-component="write-tool"], [data-component="apply-patch-tool"]) > [data-component="collapsible"] > [data-slot="collapsible-trigger"]:is([aria-expanded="true"], [data-locked])
-`;function ie(e){const t=`:is(${e})`;return`
+`;function Oe(e){const t=`:is(${e})`;return`
${t}::before,
${t}::after {
content: "";
@@ -34,7 +34,7 @@
z-index: -99;
background: var(--wallpaper-tint, transparent);
}
- `}const Le=`
+ `}const Fe=`
:is(${P}) {
position: relative;
isolation: isolate;
@@ -122,9 +122,21 @@
[data-component="new-session"] [data-slot="brick-breaker-hud"] :is(.bg-v2-border-border-base, .bg-v2-icon-icon-faint) {
background-color: var(--wallpaper-secondary);
}
-`,Re=Le+ie(`${P}, :is(${P}) [data-wallpaper-backed]`);function le(e,t){const o=e.enabled&&!!t,{tint:l,brightness:r}=te(e);return{"--wallpaper-image":o?`url(${JSON.stringify(t)})`:"none","--wallpaper-fit":e.fit,"--wallpaper-tint":o?`color-mix(in srgb, var(--v2-background-bg-base) ${l}%, transparent)`:"transparent","--wallpaper-filter":o?`brightness(${r}%) contrast(85%) saturate(90%)`:"none"}}function Me(e,t){if(!e.enabled||!t)return"";const o=Object.entries(le(e,t)).map(([l,r])=>`${l}: ${r};`).join(`
+`,Be=Fe+Oe(`${P}, :is(${P}) [data-wallpaper-backed]`);function Ne(e,t){const r=e.enabled&&!!t,{tint:l,brightness:a}=ge(e);return{"--wallpaper-image":r?`url(${JSON.stringify(t)})`:"none","--wallpaper-fit":e.fit,"--wallpaper-tint":r?`color-mix(in srgb, var(--v2-background-bg-base) ${l}%, transparent)`:"transparent","--wallpaper-filter":r?`brightness(${a}%) contrast(85%) saturate(90%)`:"none"}}function qe(e,t){if(!e.enabled||!t)return"";const r=Object.entries(Ne(e,t)).map(([l,a])=>`${l}: ${a};`).join(`
`);return`${P} {
- ${o}
-}`}function Ie(e,t,o,l){const r=Math[l==="cover"?"max":"min"](e.width/o.width,e.height/o.height),n=o.width*r,c=o.height*r,d=(e.width-n)/2-(t.left-e.left),u=(e.height-c)/2-(t.top-e.top),g=v=>`${Math.round(v*1e3)/1e3}px`;return{"--wallpaper-background-size":`${g(n)} ${g(c)}`,"--wallpaper-background-position":`${g(d)} ${g(u)}`}}function We(e){if(!(e.image.width>0&&e.image.height>0))return()=>{};const t=new Map,o=new Set;let l=0,r=!1,n=!0,c=[];const d=($,b)=>{b.attribute===null?$.removeAttribute("data-wallpaper-backed"):$.setAttribute("data-wallpaper-backed",b.attribute);for(const[E,y]of b.properties)y.value?$.style.setProperty(E,y.value,y.priority):$.style.removeProperty(E)},u=()=>{!r&&!l&&(l=requestAnimationFrame(v))},g=new ResizeObserver(u);function v(){if(l=0,r)return;n&&(c=[...document.querySelectorAll(Ae)],n=!1);const $=new Set,b=new Set,E=new Map,y=[];for(const f of c){const i=f.closest(P);if(!i)continue;const h=f.getBoundingClientRect(),a=E.get(i)??i.getBoundingClientRect();E.set(i,a),!(!h.width||!h.height||!a.width||!a.height)&&($.add(f),b.add(i),b.add(f),y.push({element:f,geometry:Ie(a,h,e.image,e.fit)}))}for(const[f,i]of t)$.has(f)||(d(f,i),t.delete(f));for(const{element:f,geometry:i}of y){t.has(f)||t.set(f,{attribute:f.getAttribute("data-wallpaper-backed"),properties:new Map(Object.keys(i).map(h=>[h,{value:f.style.getPropertyValue(h),priority:f.style.getPropertyPriority(h)}]))});for(const[h,a]of Object.entries(i))f.style.getPropertyValue(h)!==a&&f.style.setProperty(h,a);f.hasAttribute("data-wallpaper-backed")||f.setAttribute("data-wallpaper-backed","")}for(const f of o)b.has(f)||(g.unobserve(f),o.delete(f));for(const f of b)o.has(f)||(g.observe(f),o.add(f))}const w=new MutationObserver(()=>{n=!0,u()});return w.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-expanded","data-locked","class"]}),document.addEventListener("scroll",u,{capture:!0,passive:!0}),window.addEventListener("resize",u,{passive:!0}),u(),()=>{if(!r){r=!0,cancelAnimationFrame(l),w.disconnect(),g.disconnect(),document.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u);for(const[$,b]of t)d($,b);t.clear(),o.clear(),c=[]}}}var je=s.template(""),ze=s.template(""),Pe=s.template("
");function Ue(e){const[t,o]=k.createSignal(!!e.cache.peek(e.choice));let l;k.onMount(()=>{const n=new IntersectionObserver(c=>{o(c.some(d=>d.isIntersecting))},{rootMargin:"200px"});n.observe(l),k.onCleanup(()=>n.disconnect())});const r=Ee(()=>t()?e.choice:void 0,e.cache);return(()=>{var n=je(),c=l;return typeof c=="function"?s.use(c,n):l=n,s.insert(n,s.createComponent(k.Show,{get when(){return r.url},get fallback(){return s.createComponent(k.Show,{get when(){return r.error},get children(){var d=ze();return s.insert(d,()=>e.t("image.unavailable")),s.effect(u=>{var g=B(r.error,e.t),v=B(r.error,e.t);return g!==u.e&&s.setAttribute(d,"title",u.e=g),v!==u.t&&s.setAttribute(d,"aria-label",u.t=v),u},{e:void 0,t:void 0}),d}})},children:d=>(()=>{var u=Pe();return s.effect(()=>s.setAttribute(u,"src",d())),u})()})),s.effect(()=>s.setAttribute(n,"aria-busy",r.loading)),n})()}var Te=s.template("