Skip to content

fix(ui): resolve colormap swatches against the app base URL - #11

Merged
eeholmes merged 1 commit into
mainfrom
fix/colormap-swatch-base-path
Aug 27, 2026
Merged

fix(ui): resolve colormap swatches against the app base URL#11
eeholmes merged 1 commit into
mainfrom
fix/colormap-swatch-base-path

Conversation

@eeholmes

Copy link
Copy Markdown
Owner

Closes #10 (same symptom as eeholmes/gridlook-xl#61).

The bug

Both swatch call sites requested the pre-generated WebP gradients from an
absolute, site-root URL:

`/static/colormaps/${cm}.webp`

The build sets base: "./", so the app is served from a subpath — GitHub
Pages at /gridlook/, and the JupyterHub proxy prefix in dev. The leading
slash bypasses that base and points at the domain root, so every swatch
request 404s. Nothing surfaces the failure: ColormapControls renders a
broken <img> and HoverReadout's img.onerror just resolves the promise.

The fix

Prefix both with import.meta.env.BASE_URL, which Vite substitutes with the
configured base./ in the production build, the proxy prefix under
vite.jupyter.config.ts. Two one-line changes; no other absolute public-asset
paths exist in src/.

gridlook-xl#70 fixed this by dropping the leading slash, which also works
for a hash-routed app. BASE_URL is the same size and stays correct if the
document is ever served from a nested path.

Verification

  • npm run lint-ci, npm run typecheck, npm run test (216 passing), npm run build all clean.
  • The built bundle now emits ./static/colormaps/${…}.webp for both call
    sites, and dist/static/colormaps/ holds all 58 swatches.

Note: upstream/main carries the identical bug in both files, so this is
also worth proposing to d70-t/gridlook.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FniDZANGZVtrQgN1eacurN

The colormap gradient thumbnails in the colormap dropdown and the
hover readout were requested from `/static/colormaps/<name>.webp`.
The leading slash makes that an absolute, site-root URL, so once the
app is served from a subpath — GitHub Pages at `/gridlook/`, or the
JupyterHub proxy prefix in dev — every swatch request 404s and the
thumbnails silently disappear (`img.onerror` just resolves).

Prefix both with `import.meta.env.BASE_URL` instead, which Vite fills
in with the configured `base` ("./" for the production build, the
proxy prefix under `vite.jupyter.config.ts`), so the paths follow
wherever the app is mounted.

Closes #10

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FniDZANGZVtrQgN1eacurN
@eeholmes
eeholmes merged commit 648fb5e into main Aug 27, 2026
2 checks passed
@eeholmes
eeholmes deleted the fix/colormap-swatch-base-path branch August 27, 2026 23:44
eeholmes added a commit that referenced this pull request Aug 27, 2026
Issue #10 / PR #11 is merged into main, so the handoff now carries the
BASE_URL rule it leaves behind: files in public/ are referenced from script
through import.meta.env.BASE_URL, never a leading slash.

The single-branch note about fix/codec-error-messages becomes a table of two,
now that fix/colormap-swatch-base-url exists alongside it. Both are open on
d70-t/gridlook (d70-t#210 and d70-t#211), both must stay byte-identical to their copies
on main, and neither is merged here as a branch — but the swatch fix reached
main on its own PR, so merging d70-t#211 upstream is a no-op on those lines.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FniDZANGZVtrQgN1eacurN
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.

images for palletes do not appear

1 participant