refactor: 精简 dev 相对 main 新增代码里的重复与白干(行为不变)
dev 分支的新增代码过了一轮「代码精简」审查(复用 / 简化 / 效率 / 修在哪一层四个角度, 分宿主侧、客户端外壳、客户端功能面板三片,另加测试与脚本),这里只落地行为完全不变的那批: - `runGitRaw` 是 `runGit` 的纯转发别名(三个角度都点到):导出 `runGit`、删掉别名, `active-worktree.ts` 与它的 `vi.mock` 键同步改名。 - `open-external.ts` 的 `messageOf` 与 `fs-tree.ts` 的导出逐字相同:删本地实现改 import。 - `fs-operations.ts` 的单段名校验抄了三遍(注释却自称 shared rule):提成 `assertSingleSegmentName`,rename / mkdir / 新建文件三处共用。 - `fs-tree.ts` 两个探测函数各抄一遍有界并发池:提成 `forEachRow`。 - `index.ts` 自己复刻了一遍 `request/header` 的 provider/model 读取:改调 `collectModelRoutes(events, 1)[0]`;`lowestReasoningEffortOf` 的三态循环收成 best/bestRank;`formatModelRoute` 零调用点,删掉(连带自测)。 - `state.ts`:`markUnread` / `clearUnread` 的当前会话路径改走已有的 `reduce` (「归约器返回同引用即 no-op」本来就在 reduce 里),删掉私有的 `replaceCurrent`; 非当前会话那条仍只写内存不落盘,行为未动。 - `editor-dirty.ts`:`DirtyEntry.sessionId` 只服务一个没有生产调用者的 `dirtyCountForSession`,会话隔离已由 `sessionId::tabId` 这个键承载,两个一起删, 用例改断 `isEditorDirty(tabId, sessionId)`。 - `FileTree.tsx`:同一批行原先 `renderLevel` 与 `visibleRows` 各排一次,收进按 `(data, sort)` 记忆的 `entriesFor`(照 `chainFor` 的形状)。 - `dock-fallback.tsx`:500ms 重测出的坐标没变就不换 state 对象(省掉一次无意义重渲染)。 - 其余同形收口:`DiffPane` 的死分支、`terminal-client` 的 `bottomTerminalKey` (与 `bottomTerminalContentId` 同值,调用点复用同一个 id)、`SideChatView` 的 O(线程×目录) 排序扫描降为 Map、`conversation-draft` 的末段路径复用 `paths.baseName`、 `TreePanel` 的目录命中集按 results 记忆。 验证:`tsc --noEmit` 只剩改动前那 3 条缺 `@xterm/*` 的既有报错;eslint 干净; 全套 vitest 与改动前的失败集合逐条一致(13 条,均为环境原因:缺 xterm 的构建/转换类 3 条、Windows 符号链接权限 3 条、语言字典串味 4 条、真起 git 的冒烟 1 条、文件级 1 条)。
This commit is contained in:
1 parent
9021d1094e
commit
ebc5d0b6b7
21 files changed
+116
-158
No files matched your search
+5
-12
@@ -58,11 +58,6 @@ export function parseModelRoute(value: unknown): CommitModelRoute | undefined {
|
||||
return { provider, model }
|
||||
}
|
||||
|
||||
/** Render one route back into its stored form (the select value). */
|
||||
export function formatModelRoute(route: CommitModelRoute): string {
|
||||
return `${route.provider}/${route.model}`
|
||||
}
|
||||
|
||||
/** Cap of the conversation-derived route list (the adapter catalog is
|
||||
* capped separately, host-side). */
|
||||
export const MODEL_ROUTE_HISTORY_LIMIT = 20
|
||||
@@ -136,19 +131,17 @@ export function lowestReasoningEffortOf(efforts: unknown): string | undefined {
|
||||
const id = entry !== null && typeof entry === 'object' ? (entry as { id?: unknown }).id : undefined
|
||||
if (typeof id === 'string' && id !== '') ids.push(id)
|
||||
}
|
||||
const first = ids[0]
|
||||
if (first === undefined) return undefined
|
||||
let best = first
|
||||
let bestRank = (REASONING_LEVEL_ORDER as readonly string[]).indexOf(best)
|
||||
for (const id of ids.slice(1)) {
|
||||
let best: string | undefined
|
||||
let bestRank = Number.POSITIVE_INFINITY
|
||||
for (const id of ids) {
|
||||
const rank = (REASONING_LEVEL_ORDER as readonly string[]).indexOf(id)
|
||||
if (rank < 0) continue
|
||||
if (bestRank < 0 || rank < bestRank) {
|
||||
if (rank < bestRank) {
|
||||
best = id
|
||||
bestRank = rank
|
||||
}
|
||||
}
|
||||
return best
|
||||
return best ?? ids[0]
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user