Expose board background settings per board size#3593
Conversation
Review: Expose board background settings per board sizeTwo issues worth addressing: Potential state loss in
function setGridBackground(size: keyof CustomBoardGridBackgrounds, url: string): void {
setGridBackgrounds({
...grid_backgrounds,
[size]: url,
});
}Under React 18 automatic batching, if two calls to Use the functional update form instead: function setGridBackground(size: keyof CustomBoardGridBackgrounds, url: string): void {
setGridBackgrounds((prev) => ({ ...prev, [size]: url }));
}Misleading z-index variable name --z-goban-grid-layer: 5;
--z-goban-grid-background-layer: 8;
|
Review: Bugs & PerformanceStale closure in
// current — second call in a batched update discards the first
setGridBackgrounds({
...grid_backgrounds,
[size]: url,
});
// correct
setGridBackgrounds((prev) => ({ ...prev, [size]: url }));Under React 18's default batching this is safe for typical one-key-at-a-time edits, but autofill can trigger multiple Inverted z-index naming ( --z-goban-grid-layer: 5;
--z-goban-grid-background-layer: 8;
|
|
In const reset_label = getResetGridBackgroundLabel(size);
// ...
<button
title={reset_label}
aria-label={reset_label}
> |
Code ReviewOverview: Adds per-board-size baked-grid background URL settings (9×9, 13×13, 19×19), wiring them through One finding: In title={getResetGridBackgroundLabel(size)}
aria-label={getResetGridBackgroundLabel(size)}Each call goes through const resetLabel = getResetGridBackgroundLabel(size);
// ...
title={resetLabel}
aria-label={resetLabel}Otherwise the implementation looks solid: the |
Code Review
The component correctly uses a ref to handle batched updates (since React.useEffect(() => {
grid_backgrounds_ref.current = grid_backgrounds;
}, [grid_backgrounds]);
The standard React pattern for an always-current ref is to assign it directly during render, not in const grid_backgrounds_ref = React.useRef(grid_backgrounds);
grid_backgrounds_ref.current = grid_backgrounds; // synchronous, no useEffect neededThis removes the stale window entirely and is simpler. The synchronous batching behaviour described in the comment is preserved because |
Code ReviewI reviewed this PR for bugs and performance issues and the implementation looks solid overall. No significant bugs or performance issues were found. Two minor observations (not blocking):
Neither affects correctness in the current implementation. The ref-based pattern for avoiding stale closures is well-justified and handles batched updates correctly. |
Code Review
In const grid_background_sizes: (keyof CustomBoardGridBackgrounds)[] = ["9", "13", "19"];Meanwhile, Deriving the array from const grid_background_sizes = Object.keys(emptyCustomBoardGridBackgrounds) as (keyof CustomBoardGridBackgrounds)[];This also makes the |
|
Reviewed for bugs and performance issues — the implementation is clean. A few notes: Merge dependency: The goban submodule is pinned to a commit from online-go/goban#252, which is still open. This OGS PR should not be merged until that goban PR lands on its Ref-based state batching: The No other issues found. |
ReviewThis PR adds per-board-size baked-grid background URLs (9×9, 13×13, 19×19) to the custom board theme picker. The preference is stored as a single structured object, threaded through `getSelectedThemes` and `watchSelectedThemes`, and exposed via a new `GobanCustomBoardGridBackgroundPicker` component. The design is consistent with how sibling custom-theme pickers work and the z-index layering comment accurately describes the intended fallback behavior.
|
This depends on the goban renderer support in: online-go/goban#252. For motivation see the screenshots of themed boards in that PR.
The changes are made with Codex. I've reviewed them and closely steered the technical design.
The existing custom board background URL remains the default background. This PR adds three optional URLs for baked-grid board assets:
If a matching baked-grid URL is absent, invalid, or not applicable to the current board, rendering falls back to the default custom board background and
vector grid.
Screenshots
What this PR enables
This is of the themes I made and plan to release as Creative Commons once OGS supports backgrounds per board size.

It relies on two features:
Details
goban-theme-custom-board-grid-backgroundspreference.Compatibility
Existing customized boards are unaffected:
goban-theme-custom-board-urlkeeps its current meaning.Testing
I followed the testing recommendations in the CONTRIBUTION doc, and separately from that tested for graceful degradation when the asset URL's become unavailable.