Skip to content

test(harness): import shared-state modules as the components do (#1211) - #1244

Merged
agegr merged 1 commit into
mainfrom
test/windows-module-identity-1211
Oct 15, 2026
Merged

agegr merged 1 commit into
mainfrom
test/windows-module-identity-1211

Conversation

@agegr

@agegr agegr commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Fixes #1211. Test harness only, no product code changes.

Cause

jiti keys its module cache by the resolved path string. On Windows it is expected to resolve @/lib/draft-store.ts (with its extension) to a forward-slash path but @/lib/draft-store (as ChatInput.tsx imports it) to a backslash path: with the extension, jiti's bundled resolver returns the existing file as is; without it, the resolver parses C:/… as a URL with scheme c:, fails, and jiti falls back to Node's require.resolve, which answers with backslashes. So ChatInput.test.mjs wrote its draft into a second copy of the store and the composer rendered empty. Eleven newer component tests import @/hooks/useI18n.tsx the same way, the failure #588 fixed for the older tests.

This was traced through jiti 2.7.0's source and an emulation of win32 paths around the real jiti (which reproduces the empty composer). It has not been run on Windows.

Change

  • Tests import @/hooks/useI18n and @/lib/draft-store exactly as the components do (12 files, plus AppShell.workspace-memory.test.mjs's relative import of the store).
  • SessionSidebar.tabs.test.mjs writes its alias key with forward slashes and an upper-case drive letter, the form jiti compares alias keys with.
  • components/test-imports.test.mjs fails when a test names those two modules any other way (extension, relative path).

Verification

tsc --noEmit, eslint and npm test pass on macOS. On Windows, @kcf7012 could confirm with node --experimental-strip-types --test components/ChatInput.test.mjs components/BranchNavigator.test.mjs.

🤖 Generated with Claude Code

On Windows, ChatInput.test.mjs rendered an empty composer: the drafts it set
never reached the component. jiti keys its module cache by the resolved path
string, and on Windows it is expected to resolve "@/lib/draft-store.ts" (with
its extension) to a path with forward slashes but "@/lib/draft-store" (as
ChatInput.tsx imports it) to one with backslashes, so the test wrote into a
second copy of the store. This was traced through jiti's source and an
emulation of Windows paths around the real jiti, not on Windows itself.
Eleven newer component tests imported "@/hooks/useI18n.tsx" the same way,
which gives a second I18n context there (the failure #588 fixed for the
older tests).

The tests now import these modules exactly as the components do, including
AppShell.workspace-memory.test.mjs's relative import of the draft store, and
a small guard test fails when a test names useI18n or the draft store any
other way. SessionSidebar.tabs.test.mjs writes its alias key in forward
slashes with an upper-case drive letter, the form jiti compares alias keys
with. No product code changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@agegr
agegr merged commit 8c61022 into main Oct 15, 2026
2 checks passed
@agegr
agegr deleted the test/windows-module-identity-1211 branch October 29, 2026 13:01
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
…r#1211) (agegr#1244)

On Windows, ChatInput.test.mjs rendered an empty composer: the drafts it set
never reached the component. jiti keys its module cache by the resolved path
string, and on Windows it is expected to resolve "@/lib/draft-store.ts" (with
its extension) to a path with forward slashes but "@/lib/draft-store" (as
ChatInput.tsx imports it) to one with backslashes, so the test wrote into a
second copy of the store. This was traced through jiti's source and an
emulation of Windows paths around the real jiti, not on Windows itself.
Eleven newer component tests imported "@/hooks/useI18n.tsx" the same way,
which gives a second I18n context there (the failure agegr#588 fixed for the
older tests).

The tests now import these modules exactly as the components do, including
AppShell.workspace-memory.test.mjs's relative import of the draft store, and
a small guard test fails when a test names useI18n or the draft store any
other way. SessionSidebar.tabs.test.mjs writes its alias key in forward
slashes with an upper-case drive letter, the form jiti compares alias keys
with. No product code changes.

Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
…r#1211) (agegr#1244)

On Windows, ChatInput.test.mjs rendered an empty composer: the drafts it set
never reached the component. jiti keys its module cache by the resolved path
string, and on Windows it is expected to resolve "@/lib/draft-store.ts" (with
its extension) to a path with forward slashes but "@/lib/draft-store" (as
ChatInput.tsx imports it) to one with backslashes, so the test wrote into a
second copy of the store. This was traced through jiti's source and an
emulation of Windows paths around the real jiti, not on Windows itself.
Eleven newer component tests imported "@/hooks/useI18n.tsx" the same way,
which gives a second I18n context there (the failure agegr#588 fixed for the
older tests).

The tests now import these modules exactly as the components do, including
AppShell.workspace-memory.test.mjs's relative import of the draft store, and
a small guard test fails when a test names useI18n or the draft store any
other way. SessionSidebar.tabs.test.mjs writes its alias key in forward
slashes with an upper-case drive letter, the form jiti compares alias keys
with. No product code changes.

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

[Windows] components/ChatInput.test.mjs fails: the composer renders empty, so the draft never reaches it (passes on Linux)

1 participant