Fix the two bugs keeping main's CI red - #211
Merged
Merged
Conversation
isMacPlatform() reads navigator.platform, which happy-dom's GlobalRegistrator reports as whatever the host OS is - Darwin-flavored on a Mac, something else on Linux CI. The "ctrl-click on Mac" tests inherited that host value instead of controlling it, so they passed locally on macOS but failed identically on ubuntu-latest. Each test now stubs navigator.platform to the value it means to exercise (matching the existing navigator.clipboard stub pattern in library-page-selection.test.tsx), so both the Mac and non-Mac branches of isAdditiveSelectClick are asserted deterministically on any OS. No production code changes - isMacPlatform's behavior was already correct.
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
Main's CI has been red on two independent, deterministic bugs, reproduced identically across two separate CI runs (not a flake). This PR fixes one and diagnoses the other with a decomposition for follow-up.
Bug 1 (fixed) — Linux-only platform-detection test flake
apps/web/src/activatable-row.test.tsandapps/web/test/library-page-selection.test.tsxboth had a "ctrl-click is not additive on Mac" test that passed locally on macOS but failed onubuntu-latest.Root cause:
isMacPlatform()(apps/web/src/activatable-row.ts) readsnavigator.platformand matches/mac|darwin/i. Under happy-dom'sGlobalRegistrator, that value reflects the host OS, not a controlled test input — Darwin-flavored on a Mac, something else on Linux. So the "on Mac" test only exercised the Mac branch by accident of where it ran.Fix: both tests now stub
navigator.platformto the value they mean to exercise (mirroring the existingnavigator.clipboardstub already used inlibrary-page-selection.test.tsx), andactivatable-row.test.tsgained an explicit non-Mac case so both branches ofisAdditiveSelectClickare asserted deterministically regardless of host OS. No production code changed —isMacPlatform's behavior was already correct; the seam (navigator.platformitself) was injectable viaObject.defineProperty, so no new seam was needed.Verified:
cd apps/web && bun run build && bun test ./src ./test→ 775 pass, 0 fail.bun run lintfrom repo root → 0 errors (only pre-existing, unrelated warnings).Bug 2 (not fixed in this box) —
reuseExistingchat dedupscripts/e2e/chat.test.ts:874— "re-creating an existing agent chat reuses it" — expects reopening withreuseExisting: trueto return the original chat's id (200), but CI reports a freshly-created id instead.I traced the reuse path in
packages/chat/src/routes.ts(findExistingAgentChat,sameAgent) andpackages/chat/src/platform-adapter.ts(resolveDefinitionAssetId,resolveAuthoredProjectedDefinitionfrom the CL-6452 origin-column work) end to end. On paper the direct-equality match (storedDefinitionId === definitionId, both from the sameechoDefinitionId()helper) should hold and the reuse should succeed — I could not find a static defect in this path within the timebox, and didn't have time left to boot the full hub+sidecar e2e stack locally to get a live repro (Postgres was available locally, but the ports already in LISTEN state plus install/boot time made a safe repro too risky against the box).Decomposition for the next lane:
DATABASE_URL=postgres://localhost:5432/<e2e db> bun test scripts/e2e/chat.test.ts) and add a debug log atfindExistingAgentChat's match/no-match branch to see which side fails live.matches.length === 0: instrumentsameAgentto logstoredDefinitionId,definitionId, and both resolvedassetIds — confirm whetherechoDefinitionId()really returns a stable id across the two calls in the test (I could not rule out a subtle non-determinism inlistInvitableDefinitions's ordering when the CL-6451 "second invite" test runs first in the same tenant).matches.length > 0but the wrong row wins: checkgetWorkbenchTenancyand thecreatedAtfallback sort infindExistingAgentChat.Test plan
cd apps/web && bun run build && bun test ./src ./test— 775 pass, 0 failbun run lintfrom repo root — 0 errorsscripts/e2e/chat.test.ts) — not fixed; needs a live e2e repro per the decomposition aboveDo not merge — bug 2 is still open; a peer reviewer should decide whether to merge bug 1 alone or wait for both.