Skip to content

Commit 6cf16e7

Browse files
edyedy
authored andcommitted
fix(tui): per-file polish round 5 — routes/session/
TextPart tableOptions snapshotted theme.border at setup, freezing the table border color across theme switches; wrap it in createMemo. Guard the revert branch and dialog-message revert/copy/fork reduce sites with ?? [] so an unloaded message part list no longer throws.
1 parent ad7d758 commit 6cf16e7

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

MERGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ fork 与上游改了同一处(常见于 TUI 视觉/UX、core 加固逻辑)
200200
| 逐文件打磨轮2:`component/{dialog-workspace-create,dialog-console-org,dialog-mcp,dialog-retry-action,dialog-session-rename,dialog-workspace-unavailable,dialog-status,spinner,bg-pulse-render,error-component,todo-item,workspace-label}.ts(x)` || 保留 bug 修复:dialog-workspace-create 最近工作区按连接状态过滤 + 空 adapters 用 `<Show>` 包裹;dialog-console-org 切换失败弹 error toast;dialog-session-rename 重命名失败弹 error toast;dialog-workspace-unavailable 恢复成功后关闭对话框;dialog-retry-action `selectedForeground` 惰值改响应式;error-component 复制失败重置 Copied 态 + ✖ 改 `GLYPH.cross`;todo-item icon/color/attrs 改派生函数(响应式);删除死代码(dialog-mcp 未用 setRef、dialog-status 空 Props 类型、spinner SPINNER_FRAMES 别名、workspace-label 未用组件、bg-pulse-render 死导出与未用 cache:false 分支)(上游若已做可取上游版本) |
201201
| 逐文件打磨轮3:`component/prompt/{autocomplete,index,move,workspace}.tsx` + 删除 `component/prompt/creating-dots.ts`、`component/workspace-label.tsx` | 中 | 保留 bug 修复:autocomplete `<Index>` 行内 8 个 setup 期常量改派生函数(行复用时 label/图标/颜色冻结)+ files resource 源补 `store.visible`(弹窗打开且查询未变时不刷新);index shell/斜杠命令失败补 error toast(原静默丢输入)+ extmark 样式 ID 改访问器(主题切换后指向已销毁 SyntaxStyle)+ interrupt 双击计数器补 clearTimeout/onCleanup(陈旧定时器清零新计数)+ 内联 reduce 换用 `expandPastedTextPlaceholders` + `basename ?? "image"` 改 `\|\|`;workspace 死 notice 改为成功 warp 弹 success toast(原 showNotice 从未渲染);删除死代码(Autocomplete sessionID prop、AutocompleteOption.disabled、move creatingDots/pendingNew、workspace label memo、creating-dots.ts 与 workspace-label.tsx 整文件)(上游若已做可取上游版本) |
202202
| 逐文件打磨轮4:`context/{sync,sdk,project,local,theme,route}.tsx` | 高/中 | 保留 bug 修复:sync `message.removed`/`message.part.removed``if (!messages/!parts) break`(未加载会话/被驱逐消息触发 `search(undefined)` 抛错杀死事件循环)+ `lsp.updated` 改无条件调用 debounce(默认无 workspace 时 LSP 状态不再刷新的回归)+ 会话列表排序改用与二分查找一致的码位比较(localeCompare 大小写次序不一致);sdk `onCleanup` 移出 `await` 之后(owner 已失效导致订阅永不清理)+ SSE 重连循环连接/迭代包 try/catch 并在收到事件后重置退避(一次网络错误即永久断连);project/local 事件订阅补 onCleanup;删除死代码(LocalTheme、RouteContext、SyncContext 解构、theme_mode 只写不读的持久化)(上游若已做可取上游版本) |
203+
| 逐文件打磨轮5:`routes/session/{index,dialog-message}.tsx` || 保留 bug 修复:TextPart `tableOptions` 由 setup 期字面量改 `createMemo`(原 `theme.border` 快照在主题切换后冻结表格边框色);`index.tsx` revert 分支与 `dialog-message.tsx` revert/copy/fork 四处 `sync.data.part[id].reduce``?? []`(消息 part 未加载时 `.reduce` 抛错);moveChild 方向语义(`- direction`)疑似与命令名相反但属上游行为,择要跳过(上游若已做可取上游版本) |
203204

204205
### 其他
205206

packages/tui/src/routes/session/dialog-message.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export function DialogMessage(props: {
3636
})
3737

3838
if (props.setPrompt) {
39-
const parts = sync.data.part[msg.id]
39+
const parts = sync.data.part[msg.id] ?? []
4040
const promptInfo = parts.reduce(
4141
(agg, part) => {
4242
if (part.type === "text") {
@@ -61,7 +61,7 @@ export function DialogMessage(props: {
6161
const msg = message()
6262
if (!msg) return
6363

64-
const parts = sync.data.part[msg.id]
64+
const parts = sync.data.part[msg.id] ?? []
6565
const text = parts.reduce((agg, part) => {
6666
if (part.type === "text" && !part.synthetic) {
6767
agg += part.text
@@ -84,7 +84,7 @@ export function DialogMessage(props: {
8484
})
8585
const msg = message()
8686
const prompt = msg
87-
? sync.data.part[msg.id].reduce(
87+
? (sync.data.part[msg.id] ?? []).reduce(
8888
(agg, part) => {
8989
if (part.type === "text") {
9090
if (!part.synthetic) agg.input += part.text

packages/tui/src/routes/session/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ export function Session() {
555555
.then(() => {
556556
toBottom()
557557
})
558-
const parts = sync.data.part[message.id]
558+
const parts = sync.data.part[message.id] ?? []
559559
prompt?.set(
560560
parts.reduce(
561561
(agg, part) => {
@@ -1658,13 +1658,13 @@ function TextPart(props: { last: boolean; part: TextPart; message: AssistantMess
16581658
const local = useLocal()
16591659
const { theme, syntax } = useTheme()
16601660
const color = createMemo(() => local.agent.color(props.message.agent))
1661-
const tableOptions = {
1661+
const tableOptions = createMemo(() => ({
16621662
style: "grid" as const,
16631663
borderStyle: "rounded" as const,
16641664
borderColor: theme.border,
16651665
outerBorder: true,
16661666
wrapMode: "word" as const,
1667-
}
1667+
}))
16681668
// While the part is still streaming, keep a single <markdown streaming> so it
16691669
// updates in place instead of being torn down and rebuilt every token. Only
16701670
// once the text is finalized do we split real fenced code blocks into panels;
@@ -1688,7 +1688,7 @@ function TextPart(props: { last: boolean; part: TextPart; message: AssistantMess
16881688
streaming={true}
16891689
internalBlockMode="top-level"
16901690
content={props.part.text.trim()}
1691-
tableOptions={tableOptions}
1691+
tableOptions={tableOptions()}
16921692
conceal={ctx.conceal()}
16931693
fg={theme.markdownText}
16941694
bg={theme.background}
@@ -1706,7 +1706,7 @@ function TextPart(props: { last: boolean; part: TextPart; message: AssistantMess
17061706
streaming={false}
17071707
internalBlockMode="top-level"
17081708
content={ctx.conceal() ? polishMarkdown(seg.text) : seg.text}
1709-
tableOptions={tableOptions}
1709+
tableOptions={tableOptions()}
17101710
conceal={ctx.conceal()}
17111711
fg={theme.markdownText}
17121712
bg={theme.background}

0 commit comments

Comments
 (0)