fix(terminal): 修 TerminalManager t() 被 .map 参数遮蔽导致 't2 is not a function'#112
Merged
Conversation
TerminalManager's `const { t } = useTranslation("terminal")` was being
shadowed by every `.map((t) => ...` and `.find((t) => ...` inside the
component. Most sites were fine because they only accessed `t.name` /
`t.terminalId` / `t.status` — terminal object properties. But line 387
(`title={t("closeTerminal")}`) was actually trying to call the
i18n function, which the shadowed `t` (the terminal object) was not.
Symptom: clicking the "+" to add a terminal throws
`TypeError: t2 is not a function` (in the minified bundle, t2 is the
.map parameter; the actual i18n t() is a different binding) and the
TerminalManager fails to render.
Fix: rename every `t` callback parameter to `term` so the i18n `t`
binding is the only `t` in scope. Touched the seven callback sites
(map ×4, find ×3, .filter ×1) and the corresponding body references.
Verified via electron-vite build + grep on the minified bundle: the
i18n t() call now appears in the title prop, no more t2.
Reported by user via the v0.2.1 release.
There was a problem hiding this comment.
Code Review
This pull request renames the variable t to term in several array callback functions within src/components/TerminalManager.tsx to improve clarity and avoid shadowing. The reviewer suggests also renaming t to term in the .filter callback on line 74 for consistency, and recommends addressing other remaining occurrences of t as a callback parameter throughout the file.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
2 tasks
… callbacks
Follow-up to the t() shadowing fix: five more .filter/.find callbacks
inside TerminalManager still used `t` as the parameter name. While these
particular callbacks don't call the i18n `t()` and would not crash, they
still shadow the i18n binding and could cause subtle bugs if anyone adds
a `t("someKey")` call inside any of them in the future.
This is a pure consistency cleanup — no functional change.
ACCSCI
added a commit
that referenced
this pull request
Jul 2, 2026
…delete (#113) Adds e2e/extended-user-flow.spec.ts which exercises the full UI path from cold start through session delete, including the terminal panel that the existing bun-start-simulation.spec.ts does not cover: 1. Cold start → home page 2. Click 打开项目 → modal 3. Navigate dir browser to F:\ProgramPlayground\JavaScript\Copilot-Switch 4. Project workspace loads 5. Create session (wait for state to leave 'creating') 6. Create 3 terminals via the + button 7. Close 1 terminal via the × on the second tab 8. Delete session via the close button + confirm modal Why this matters: prior e2e suite never created terminals, so the t() shadowing bug in TerminalManager (PR #112) reached v0.2.1 without test coverage. This spec would have caught it at the 'expected to render terminal panel' assertion. Note: TerminalManager does NOT auto-create a terminal when a session becomes active — the user must click '+'. The spec accounts for this. Verified locally: 1 passed (41.4s) on Node v24 + Electron 42 + Playwright 1.60.0 (the e2e fixture path that works in this environment). Co-authored-by: Marco Taylor <[email protected]>
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.
问题
v0.2.1 用户报告:点击 Terminal "+" 按钮创建 terminal 时报:
```
TypeError: t2 is not a function
at TerminalManager (index-BvQwO9hX.js:34163:28)
```
TerminalManager 无法渲染。
根因
`TerminalManager.tsx` 顶部:
```ts
const { t } = useTranslation("terminal");
```
但在内部多个 `.map((t) => ...`、`.find((t) => ...`、`.filter((t) => ...`
把外层的 i18n `t` 遮蔽成 terminal 对象。绝大多数地方没问题(只读
`t.name` / `t.terminalId` / `t.status`)—— 但 line 387:
```tsx
title={t("closeTerminal")}
```
这本来是调 i18n `t()` 函数,但因为外层 `t` 被遮蔽,minified 之后
title={t2(\"closeTerminal\")}报 "t2 is not a function"。修复
把 7 处 callback 参数从 `t` 改成 `term`(map ×4, find ×3, filter ×1),
并同步所有 body 引用。从此 i18n `t` 是作用域内唯一的 `t`。
验证
属于 v0.2.2 patch。