Skip to content

Commit e0e0708

Browse files
authored
fix: resume live wallpapers and simplify lifecycle code (#8)
* fix: recover live wallpaper playback and simplify lifecycle code * Update README * chore: prepare v0.3.1 and verify watcher recovery in Node * test: use a deterministic video fixture in browser checks
1 parent 03019a8 commit e0e0708

30 files changed

Lines changed: 871 additions & 1024 deletions

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.3.1
4+
5+
- Resume videos and restart HTML wallpapers after focus or visibility interruptions without changing the selected wallpaper. HTML simulation state resets on recovery; sandbox restrictions stay unchanged.
6+
- Fix a catalog refresh-completion race and simplify thumbnail ownership, header alignment, gallery controls and styles.
7+
- Consolidate overlapping tests and verify folder deletion/recreation under Desktop's Node runtime, including direct folders, aliases and atomic replacements.
8+
39
## 0.3.0
410

511
- Add muted, looping MP4 and WebM wallpapers, animated GIF and APNG uploads, and self-contained HTML wallpapers.

‎README.md‎

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,41 @@
11
# OpenCode Backdrop
22

3-
<p>Use your own wallpapers in OpenCode Desktop. Supports OpenCode 2.2.x from 2.2.6, 2.3.x from 2.3.2, and 2.4.x from 2.4.3 through the GUI plugin API.</p>
4-
<img width="3020" height="1910" alt="image" src="https://github.com/user-attachments/assets/8d1626f2-7048-496c-8aa9-7745f19e1531" />
3+
<p>Use your own wallpapers in OpenCode Desktop.</p>
4+
5+
<img alt="Wallpaper preview" src="https://github.com/user-attachments/assets/8d1626f2-7048-496c-8aa9-7745f19e1531" />
6+
7+
https://github.com/user-attachments/assets/72617017-5f4d-4153-94dd-635d6eaea54d
58

69
## Install
710

811
```sh
9-
opencode plugin add 'github:viralcodex/opencode-backdrop#v0.3.0'
12+
opencode plugin add 'github:viralcodex/opencode-backdrop#v0.3.1'
1013
```
1114

1215
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`.
1316

1417
```jsonc
1518
{
1619
"$schema": "https://opencode.ai/config.json",
17-
"plugins": ["github:viralcodex/opencode-backdrop#v0.3.0"],
20+
"plugins": ["github:viralcodex/opencode-backdrop#v0.3.1"],
1821
}
1922
```
2023

2124
## Use
25+
Images and HTML (WebGL self-contained animated wallpapers) must be non-empty and no larger than 8 MiB and videos can be up to 256 MiB.
2226

2327
1. Open **Settings > Wallpapers**.
2428
2. Choose **Change folder** to use a local folder, or **+** to upload an image.
2529
3. Select a wallpaper and adjust tint, brightness and fit.
2630

27-
Wallpaper starts off with an empty gallery. Wallpapers and preferences stay local and are not sent to models. Images and HTML must be non-empty and no larger than 8 MiB; videos can be up to 256 MiB.
28-
29-
- Folders support PNG, JPEG, WebP, SVG, GIF, APNG, MP4, WebM, and self-contained HTML, including subfolders. Changes appear automatically.
30-
- Uploads support PNG, JPEG, WebP, GIF and APNG. Add video and HTML through the wallpaper folder.
31-
- Videos play muted and loop continuously. MP4 with H.264 is recommended; other codecs depend on Desktop support. Animated images keep their original animation.
32-
- HTML wallpapers run in a sandbox without access to the OpenCode interface or local storage. CSP blocks external scripts, styles, assets, and fetch requests. Embed everything in the HTML and use files from sources you trust. This is not a network firewall; a script can still navigate its own frame to another URL.
33-
- Filter the gallery by **All wallpapers**, **Static**, or **Live**. Live tiles have a small play icon beside their name. Hover or keyboard-focus a live tile to preview it without changing your selected wallpaper.
34-
- Videos and animated images show static thumbnail frames until previewed. For an HTML poster, put `Name.poster.png`, `.jpg`, `.jpeg`, or `.webp` beside `Name.html`. Poster files stay out of the gallery. Without a poster, HTML tiles show a live-wallpaper label until previewed.
35-
- The gallery shows at most two rows, including the **+** tile. Use **Show more** to see all wallpapers, or **Show less** to collapse it.
36-
- More tint improves text contrast. **Fill background** crops the image; **Show whole image** keeps it fully visible.
37-
- Use `/wallpaper` in chat to switch images or turn wallpaper off. Escape cancels the picker.
38-
- Turn **Show wallpaper** off to restore the app's backgrounds without losing your choices.
39-
- Turn **Wallpaper slideshow** on to cycle through all wallpapers in gallery order, regardless of the gallery filter. Choose **None** or **Fade** and set **Display time** in seconds, from 5 to 86400. The default is 60 seconds. Slideshow needs at least two wallpapers. Fades apply between images and respect reduced-motion settings; video and HTML switch instantly. Live playback itself does not pause under reduced motion.
40-
41-
To remove an upload, hover or focus its tile and click **X**. Remove folder wallpapers by moving or deleting their source files.
42-
43-
## Koi Pond example
44-
45-
[Koi Pond](https://github.com/Himanshu-Sangshetti/koipond) is a live WebGL wallpaper, not a video. Download `koipond-linux.tar.gz` from its [wallpaper release](https://github.com/Himanshu-Sangshetti/koipond/releases/tag/wallpaper-v0.2.0), extract `web/index.html`, and save it in your wallpaper folder as `Koi Pond.html`. No installer is needed. Select it in **Settings > Wallpapers**.
46-
47-
Save the repo's [poster image](https://raw.githubusercontent.com/Himanshu-Sangshetti/koipond/main/.github/assets/hero.webp) beside it as `Koi Pond.poster.webp` to show the pond before hovering.
48-
49-
Other HTML animations work the same way when bundled into one file. The wallpaper cannot intercept clicks or read the OpenCode interface. HTML fills the panel; the fit setting applies to images and videos.
31+
## Features
32+
1. Use `/wallpaper` in chat to switch images or turn wallpaper off.
33+
2. Folders support PNG, JPEG, WebP, SVG, GIF, APNG, MP4, WebM, and self-contained HTML, including subfolders.
34+
3. Uploads support PNG, JPEG, WebP, GIF and APNG. Add video and HTML through the wallpaper folder.
35+
4. Videos play muted and loop continuously. MP4 with H.264 is recommended; other codecs depend on Desktop support.
36+
5. HTML wallpapers run in a sandbox without access to the OpenCode interface or local storage. <i>(CSP blocks external scripts, styles, assets, and fetch requests. Add only from trusted sources.)</i>
37+
6. Turn **Wallpaper slideshow** on to cycle through all wallpapers in gallery order, regardless of the gallery filter.
38+
7. Choose **Fade** and set **Display time** in seconds, from 5 to 86400. The default is 60 seconds.
5039

5140
## Optional folder configuration
5241

@@ -57,7 +46,7 @@ You can set an initial folder with an absolute path instead of choosing one in S
5746
"$schema": "https://opencode.ai/config.json",
5847
"plugins": [
5948
{
60-
"package": "github:viralcodex/opencode-backdrop#v0.3.0",
49+
"package": "github:viralcodex/opencode-backdrop#v0.3.1",
6150
"options": { "folder": "/absolute/path/to/wallpapers" },
6251
},
6352
],
@@ -68,15 +57,9 @@ The folder chosen in Settings takes precedence over this option.
6857

6958
## Development
7059

71-
Use Bun 1.4.4, as pinned in `package.json`, so the generated bundle matches CI.
60+
Use Bun 1.4.4, as pinned in `package.json`.
7261

7362
```sh
7463
bun run check
7564
bun run test:storage /path/to/opencode
7665
```
77-
78-
`check` rebuilds the GUI bundle and runs unit, native Node filesystem-watcher, headless Chrome, and package checks. Set `CHROME_BIN` to a Chrome or Chromium executable if it is installed elsewhere. The PR workflow runs these checks and rejects a stale committed bundle. `test:storage` checks migration against an OpenCode checkout's actual persistence decoder. Pass the checkout path or set `OPENCODE_CHECKOUT`.
79-
80-
## Release
81-
82-
See [CHANGELOG.md](CHANGELOG.md) for the 0.3.0 release notes. Before tagging `v0.3.0`, run `bun install --frozen-lockfile --ignore-scripts` and `bun run check`, then commit the rebuilt `dist/gui-experimental.cjs` with the source changes. Run the host-storage check against a supported OpenCode checkout and smoke-test the installed package in Desktop. Keep the local `showcase/` captures and artwork out of this PR.

‎dist/gui-experimental.cjs‎

Lines changed: 19 additions & 25 deletions
Large diffs are not rendered by default.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json.schemastore.org/package.json",
33
"name": "opencode-backdrop",
4-
"version": "0.3.0",
4+
"version": "0.3.1",
55
"description": "Use your own local wallpapers in OpenCode Desktop",
66
"type": "module",
77
"license": "MIT",

‎script/check-catalog-node.ts‎

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ assert(bundle.success, "Catalog test bundle failed to build")
1212
const output = bundle.outputs[0]
1313
assert(output, "Catalog test bundle is missing")
1414
const scenario = `
15-
{
15+
for (const useAlias of [false, true]) {
1616
const assert = (await import('node:assert/strict')).default
1717
const fs = await import('node:fs/promises')
1818
const path = (await import('node:path')).default
@@ -24,48 +24,52 @@ const scenario = `
2424
const aliases = path.join(directory, 'aliases')
2525
const alias = path.join(aliases, 'alias')
2626
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'
27-
const pending = new Set()
28-
const catalog = createCatalog(alias, () => { for (const notify of [...pending]) notify() })
27+
let notify = () => {}
28+
const catalog = createCatalog(useAlias ? alias : target, () => notify())
2929
const waitFor = (predicate) => new Promise((resolve, reject) => {
30-
if (predicate()) { resolve(); return }
31-
const notify = () => {
30+
notify = () => {
3231
if (!predicate()) return
3332
clearTimeout(timer)
34-
pending.delete(notify)
3533
resolve()
3634
}
3735
const timer = setTimeout(() => {
38-
pending.delete(notify)
3936
reject(new Error('Filesystem event did not update the catalog: ' + JSON.stringify(catalog.state())))
4037
}, 5000)
41-
pending.add(notify)
38+
notify()
4239
})
4340
try {
4441
await fs.mkdir(target)
45-
await fs.mkdir(aliases)
46-
await fs.symlink(target, alias, ${JSON.stringify(process.platform === "win32" ? "junction" : "dir")})
42+
if (useAlias) {
43+
await fs.mkdir(aliases)
44+
await fs.symlink(target, alias, ${JSON.stringify(process.platform === "win32" ? "junction" : "dir")})
45+
}
4746
await fs.writeFile(path.join(target, 'before.svg'), svg)
4847
assert.equal(await catalog.refresh(), true)
4948
assert.equal(catalog.state().images.length, 1)
50-
const removed = waitFor(() => catalog.state().images.length === 0 && catalog.state().error.includes('ENOENT'))
51-
await fs.rm(target, { recursive: true })
52-
await removed
53-
const restored = waitFor(() => !catalog.state().error && catalog.state().images.some(image => image.title === 'restored'))
54-
await fs.mkdir(target)
55-
await fs.writeFile(path.join(target, 'restored.svg'), svg)
56-
await restored
57-
assert.ok((await catalog.read(catalog.state().images[0])).includes(Buffer.from(svg).toString('base64')))
58-
const changed = waitFor(() => catalog.state().images.length === 2)
59-
await fs.writeFile(path.join(target, 'another.svg'), svg)
60-
await changed
49+
for (const atomic of [false, true]) {
50+
const removed = waitFor(() => catalog.state().images.length === 0 && catalog.state().error.includes('ENOENT'))
51+
await fs.rm(target, { recursive: true })
52+
await removed
53+
const restored = waitFor(() => !catalog.state().error && catalog.state().images.some(image => image.title === 'restored'))
54+
const replacement = atomic ? path.join(directory, 'replacement') : target
55+
await fs.mkdir(replacement)
56+
await fs.writeFile(path.join(replacement, 'restored.svg'), svg)
57+
if (atomic) await fs.rename(replacement, target)
58+
await restored
59+
assert.ok((await catalog.read(catalog.state().images[0])).includes(Buffer.from(svg).toString('base64')))
60+
const changed = waitFor(() => catalog.state().images.length === 2)
61+
await fs.writeFile(path.join(target, 'another.svg'), svg)
62+
await changed
63+
assert.deepEqual(catalog.state().images.map(image => image.title), ['another', 'restored'])
64+
}
6165
catalog.dispose()
6266
assert.equal(await catalog.refresh(), false)
63-
console.log('Node catalog passed: symlink target removal, recreation, subsequent changes, reads, and disposal.')
6467
} finally {
6568
catalog.dispose()
6669
await fs.rm(directory, { recursive: true, force: true })
6770
}
6871
}
72+
console.log('Node catalog passed: direct folders and symlink targets, deletion, normal/atomic recreation, subsequent changes, reads, and disposal.')
6973
`
7074
const node = Bun.spawn([process.env.NODE_BIN ?? "node", "--input-type=module", "--eval", `${await output.text()}\n${scenario}`],
7175
{ cwd: root, stdout: "pipe", stderr: "pipe" },

0 commit comments

Comments
 (0)