fix: Chrome <111 titlebars + duplicate-placement REST 500s (#167)#172
Merged
Conversation
Three independent bugs surfaced in Issue #167: 1. Window control buttons invisible on Chrome 109. assets/css/variables.css declared every focused titlebar background through `color-mix(in srgb, ...)`, which Chromium shipped in 111. On older browsers the declaration is invalid-at-computed-value-time, the custom property falls back to the light unfocused surface, and the white close/min/max glyphs vanish into it. The mix inputs were all static literals anyway, so the calls were only ever doing compile-time arithmetic. Replaced with the precomputed sRGB hex per scheme (visually identical on modern Chrome, just works on Chrome <111). Each line keeps the original color-mix() in a comment for traceability. 2. "Failed to write placement" (REST 500) when creating a URL tile whose string matches a soft-trashed one, or when the orphan auto-placer raced a folder-creation. Schema v5 added a UNIQUE key on (user_id, parent_id, file_type, file_ref) without filtering on trashed_at_ms, so both flows hit the same wpdb duplicate-key path. desktop_mode_files_place() now disambiguates the generic `false` from $wpdb->insert: looks up the colliding row, restores it if trashed, then applies the caller's coords / meta. Real DB failures still surface as the original WP_Error because the lookup returns null. 3. After fix 2 the row state was correct but the new tile only appeared after a refresh. Root cause was unrelated to the fix logic: with WP_DEBUG_DISPLAY on, wpdb prints a `<div class="wpdberror">...</div>` block to stdout when the INSERT collides, which gets prepended to the REST JSON response. The client's `await resp.json()` then throws and upsertPlacement is never called. Wrapped the INSERT in $wpdb->suppress_errors() so the deliberate, recovered failure stays silent. The error still lands in $wpdb->last_error and error_log. Tooling: .wp-env.json now sets port=8890 / testsPort=8891 so the standalone `npm run test:php` script coexists with the user's wordpress-develop checkout on 8889. AGENTS.md updated to reflect that `npm run test:php` is the supported path again. Verified: npm run build, npm run lint, tsc --noEmit, npm run test:js (1109 ok), npm run test:php (654 ok). Manual repro of issues 1 and 2 in Chrome via DevTools confirmed real-time tile creation.
Contributor
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
`bin/sync-to-wp-develop.sh` resolves the destination plugin folder in
three steps now, instead of just two:
1. `WPDM_SYNC_DEST` env var, used verbatim if set.
2. Inspect running containers for a mount whose Destination is
exactly `/var/www` and whose host Source looks like a wordpress-
develop checkout (has `src/wp-content/plugins/` and
`wp-tests-config-sample.php`). Append `desktop-mode` to land at
the plugin folder.
3. Fall back to `$HOME/github/wordpress-develop/...` (the historical
default), with a hint to set `WPDM_SYNC_DEST` or start the
container.
The /var/www-Destination check distinguishes wordpress-develop from
wp-env, which mounts to /var/www/html. Another developer with their
wordpress-develop checkout at `~/repos/wordpress-develop` (or anywhere
else) now gets the right sync target automatically, as long as the
container is running. The fallback keeps the script useful before the
container is started for the first time.
Each branch prints which path resolved, so the destination is visible
in the sync log.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #167. Three independent issues, fixed in one PR because they were all reported together.
1. Window control buttons invisible on Chrome <111
assets/css/variables.cssdeclared every focused titlebar background throughcolor-mix(in srgb, ...). Chromium shippedcolor-mix()in 111; on older browsers the declaration is invalid at computed-value time, the custom property is left at the light unfocused fallback, and the white close/min/max glyphs disappear into it.The mix inputs were all static literals, so the calls were just compile-time arithmetic dressed up as runtime CSS. Replaced each with the precomputed sRGB hex (pixel-identical on modern Chrome, works on Chrome <111). Kept the original
color-mix(...)expression as an inline comment per scheme for traceability.2.
desktop_mode_files_insert_failed500 on URL / folder creationSchema v5 added
UNIQUE KEY (user_id, parent_id, file_type, file_ref)without filtering ontrashed_at_ms. Two reported flows hit the duplicate-key path:www.google.com, recreates it, INSERT collides with the still-present trashed row.POST /foldersreturns, the client firesPOST /placements, but a concurrentGET /placements?folder=0triggersdesktop_mode_files_auto_place_orphanswhich places the folder first. The client's POST then collides.desktop_mode_files_place()now disambiguates the genericfalsefrom$wpdb->insert: looks up the colliding row by the unique-key tuple, restores it if trashed, applies the caller's coords / meta viadesktop_mode_files_move. Real DB failures still surface as the originalWP_Errorbecause the lookup returns null in that case.3. Restored tile only appeared after refresh
Tile state was correct server-side, but with
WP_DEBUG_DISPLAYon, wpdb prints a<div class=\"wpdberror\">...</div>block when the INSERT collides. That HTML was getting prepended to the REST JSON response, soawait resp.json()threw on the client andupsertPlacementnever ran. Wrapped the INSERT in$wpdb->suppress_errors()so the deliberate, recovered duplicate-key stays silent. Genuine DB failures still hit$wpdb->last_erroranderror_log.Tooling
.wp-env.jsonnow setsport: 8890andtestsPort: 8891so the standalonenpm run test:phpscript coexists with a wordpress-develop checkout on 8889.AGENTS.mdupdated to drop the prior "do not run test:php" warning.Test plan
npm run buildnpm run lint./node_modules/.bin/tsc --noEmitnpm run test:js(1109 passing)npm run test:php(654 passing)