Skip to content

Fix VS Code theme not appearing (extension needs an extensions.json entry) - #128

Open
srince77 wants to merge 1 commit into
omacom:mainfrom
srince77:fix/vscode-theme-not-detected
Open

Fix VS Code theme not appearing (extension needs an extensions.json entry)#128
srince77 wants to merge 1 commit into
omacom:mainfrom
srince77:fix/vscode-theme-not-detected

Conversation

@srince77

Copy link
Copy Markdown

Fixes #113.

VS Code stopped treating a bare extension folder as installed. It now checks ~/.vscode/extensions/extensions.json to know what is installed, so an unpacked folder placed there with nothing recording it is invisible to the theme picker and the Extensions view, even though the files are correct.

I confirmed this on my own machine (VS Code 1.137.0). Omarchy's own VS Code theme hook, omarchy-theme-set-vscode, already works around this for its bundled theme by writing a matching entry into extensions.json. Aether's ApplyVSCodeTheme never did the equivalent, so its generated extension folder sits there unrecognized, which matches exactly what is reported in #113.

What this changes

internal/theme/applier_vscode.go: after writing the extension files, also register the extension in extensions.json using the same entry shape Omarchy's script writes, and clear any leftover .obsolete marker from a previous uninstall (VS Code will hide an extension that is still listed there even if it is back in extensions.json).

Existing entries in extensions.json are preserved untouched via json.RawMessage, so Marketplace extensions keep their metadata. Registration failures are logged rather than failing theme application, so a corrupt or unreadable extensions.json cannot break the rest of theme apply.

No new dependencies.

Testing

  • Added six tests in internal/theme/applier_vscode_test.go covering: extension gets registered end to end through ApplyVSCodeTheme, existing marketplace entries are preserved with their metadata intact, repeated calls do not create duplicate entries, and the .obsolete marker is cleared (both when other keys remain and when it becomes empty).
  • go test ./internal/... ./cli/... passes.
  • go vet ./internal/... ./cli/... clean.
  • gofmt -l clean on changed files.

VS Code no longer treats a bare extension folder as installed. It checks
~/.vscode/extensions/extensions.json to know what is installed, so
Aether's generated extension folder was never recognized, even though
its files were correct.

Omarchy's own omarchy-theme-set-vscode script already works around this
for its bundled theme by writing a matching entry into extensions.json.
This applies the same fix to Aether's ApplyVSCodeTheme: register the
extension there after writing its files, and clear any leftover
.obsolete marker from a previous uninstall.

Existing entries in extensions.json are preserved untouched, so
Marketplace extensions keep their metadata. Registration failures are
logged rather than failing theme application.

Fixes omacom#113
@srince77

Copy link
Copy Markdown
Author

@bjarneo Wanted to flag my reasoning behind this fix and a possible follow up, in case you'd rather steer before I spend more time on it.

Why this approach: VS Code stopped picking up a bare extension folder in ~/.vscode/extensions once there's no matching entry in extensions.json. I noticed omarchy-theme-set-vscode already works around exactly this for its own bundled theme by hand writing that entry, so I matched that pattern here rather than inventing something new.

A more robust alternative I'm considering: extensions.json is an undocumented internal format, so this fix could break again if VS Code reshapes it, the same way it broke this issue in the first place. A sturdier route would be to build a real .vsix (just a zip, doable with Go's stdlib archive/zip, no new dependency) and install it through code --install-extension, which is VS Code's own supported path. That mirrors what your script already does for third party marketplace themes, just extended to cover a locally generated one. I'd fall back to the direct extensions.json edit only when the code binary isn't on PATH.

Happy to build that out if it's worth the extra surface area, or leave this fix as is if the simpler approach is preferred. Let me know which direction you'd rather see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aether doesn't sync with Visual Studio Code.

1 participant