Give the pasted-text import an extension so the node test runner can load it (#8981)

Frontend build + bundle sanity is red on main. tests/delete-chat-files-preference.test.ts
fails with ERR_MODULE_NOT_FOUND for
studio/frontend/src/features/chat/utils/pasted-text, and the file is there.

The frontend suite runs under `node --experimental-strip-types --test`, and
Node's ESM resolver does not add extensions. #8963 added

    } from "../utils/pasted-text";

to chat-preferences-store.ts, which the test imports for its value, so the
resolver is asked for a file called pasted-text and there is not one. The two
sibling modules that import the same file, use-chat-search-index.ts and
prompt-storage-dialog.tsx, both write ../utils/pasted-text.ts, which is the
convention this restores.

Reproduced the mechanism on its own: a.ts importing "./b" fails with
ERR_MODULE_NOT_FOUND under --experimental-strip-types, and "./b.ts" resolves.

Scope. 47 other relative imports without an extension sit in modules the tests
name, but all except two are erased before resolution, being `import type` or a
braced clause of nothing but types. The two real ones,
chat-settings-api.ts -> ../utils/settings-retry and
per-model-config.ts -> ./model-identity, are not reached at runtime: the tests
that mention those files pass them to readFile as source text, or import only
their types. They are latent rather than broken, so they are left alone here
and worth a separate look.
This commit is contained in:
Daniel Han 2026-08-16 03:41:57 -07:00 committed by GitHub
parent c298c39658
commit d43892ea76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,7 +6,7 @@ import { persist } from "zustand/middleware";
import {
PASTED_TEXT_DEFAULT_MIN_CHARS,
PASTED_TEXT_THRESHOLD_CHOICES,
} from "../utils/pasted-text";
} from "../utils/pasted-text.ts";
// Client-side chat UI prefs kept in localStorage, not the chat DB.
// confirmDeleteChats: when off, deleting a chat skips the confirm dialog.