Skip to content

fix(dashboard): rename backendFlag util to avoid case-only module collision - #2823

Closed
Geek-Icebreaker wants to merge 2 commits into
TencentCloud:mainfrom
Geek-Icebreaker:dev
Closed

Geek-Icebreaker wants to merge 2 commits into
TencentCloud:mainfrom
Geek-Icebreaker:dev

Conversation

@Geek-Icebreaker

Copy link
Copy Markdown

Summary

On case-insensitive filesystems (macOS/Windows), Vite's dev server resolves ./BackendFlag to backendFlag.ts because .ts is probed before .tsx. The BackendFlag component is then imported as a module without a default export, and /admin/users fails with:

The requested module '/src/pages/Experts/components/backendFlag.ts' does not provide an export named 'default'

This PR renames the utility module to backendFlagModel.ts (and its test file) and updates the imports in BackendFlag.tsx and the test. No runtime logic or public exports are changed.

Root cause

  1. BackendFlag.tsx (React component with a default export) and backendFlag.ts (utility module with named exports only) differ only by case. Both were introduced by d7cd8027 (feat: record the model system prompt and harden chat, connectors, and images #2700, 2026-11-01).
  2. Vite's dev-server extension resolution order is .mjs → .js → .mts → .ts → .jsx → .tsx → .json, so .ts is probed before .tsx.
  3. AgentCard.tsx imports it extensionless: import BackendFlag from "./BackendFlag".
  4. macOS/Windows file systems are case-insensitive by default, so ./BackendFlag.ts matches the on-disk backendFlag.ts. The default import is therefore resolved to a module with only named exports, producing the runtime error.
  5. Load path: /admin/users → UsersListPanel → AgentCard → ./BackendFlag, which is why the error only appears on that page.
  6. This was not caught earlier because:
    • Linux CI and production builds resolve imports on a case-sensitive filesystem / statically, so the ambiguity never occurs;
    • octop run serves the pre-built src/octop/dashboard/ bundle, where imports are already resolved at build time;
    • On the very first run, the page that pulls in BackendFlag may not have been visited.

Fix

  • Renamed backendFlag.ts to backendFlagModel.ts and the test file accordingly, so the utility module no longer shares the same name as the component except for case.
  • Updated the two import paths in BackendFlag.tsx and backendFlagModel.test.ts.
  • No runtime behavior, public exports, or logic changes: resolveBackendFlag / backendFlagIcon / BackendFlagIcon stay the same.

Target branch

  • Base is develop (feature / fix — default)
  • Base is main (release/* or hotfix/* only)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactor / chore
  • Release / hotfix

Test plan

  • make all passes locally
  • Updated test file import path; existing tests pass

Commands run:

npx tsc -b
npx vitest run src/pages/Experts/components src/pages/Admin/Users
npx prettier --check <changed files>
npx eslint <changed files>

…lision

On case-insensitive filesystems (macOS/Windows), Vite's dev server resolves
"./BackendFlag" to backendFlag.ts because ".ts" is probed before ".tsx".
The BackendFlag component is then imported as a module without a default
export and the page fails with "does not provide an export named 'default'".

Rename the utility module to backendFlagModel.ts (and its test file) and
update the imports in BackendFlag.tsx. No runtime behavior changes.
# Conflicts:
#	dashboard/src/pages/Experts/components/BackendFlag.tsx
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

请把这个变更重新提交到 develop。功能修改和问题修复都要指向 develop,不要直接指向 main。

Please open this change against develop instead of main.

@github-actions github-actions Bot closed this Nov 4, 2026
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.

1 participant