refactor(vscode): 重构消息排序和展示逻辑

- 移除旧的消息排序改进总结文档
- 重新组织消息渲染逻辑,合并所有类型的消息按时间戳排序
- 优化工具调用处理流程,添加时间戳支持
- 改进会话保存机制,直接使用SessionManager保存检查点
- 重构部分组件以提高可维护性
This commit is contained in:
yiliang114
2025-11-28 22:35:31 +08:00
parent 5ce40085d5
commit 9ae45c01a6
33 changed files with 299 additions and 837 deletions

View File

@@ -36,7 +36,7 @@ const mapToolStatusToBullet = (
}
};
// 从文本中尽可能解析带有 - [ ] / - [x] 的 todo 列表
// Parse todo list with - [ ] / - [x] from text as much as possible
const parseTodoEntries = (textOutputs: string[]): TodoEntry[] => {
const text = textOutputs.join('\n');
const lines = text.split(/\r?\n/);
@@ -60,7 +60,7 @@ const parseTodoEntries = (textOutputs: string[]): TodoEntry[] => {
}
}
// 如果没匹配到,退化为将非空行当作 pending 条目
// If no match is found, fall back to treating non-empty lines as pending items
if (entries.length === 0) {
for (const line of lines) {
const title = line.trim();
@@ -83,7 +83,7 @@ export const TodoWriteToolCall: React.FC<BaseToolCallProps> = ({
const { content, status } = toolCall;
const { errors, textOutputs } = groupContent(content);
// 错误优先展示
// Error-first display
if (errors.length > 0) {
return (
<ToolCallContainer label="Update Todos" status="error">

View File

@@ -29,7 +29,7 @@ interface DiffDisplayProps {
oldText?: string | null;
newText?: string;
onOpenDiff?: () => void;
/** 是否显示统计信息 */
/** Whether to display statistics */
showStats?: boolean;
}
@@ -44,13 +44,13 @@ export const DiffDisplay: React.FC<DiffDisplayProps> = ({
onOpenDiff,
showStats = true,
}) => {
// 统计信息(仅在文本变化时重新计算)
// Statistics (recalculate only when text changes)
const stats = useMemo(
() => calculateDiffStats(oldText, newText),
[oldText, newText],
);
// 仅生成变更行(增加/删除),不渲染上下文
// Only generate changed lines (additions/deletions), do not render context
const ops: DiffOp[] = useMemo(
() => computeLineDiff(oldText, newText),
[oldText, newText],
@@ -106,7 +106,7 @@ export const DiffDisplay: React.FC<DiffDisplayProps> = ({
</div>
</div>
{/* 只绘制差异行的预览区域 */}
{/* Only draw preview area for diff lines */}
<pre className="diff-preview code-block" aria-label="Diff preview">
<div className="code-content">
{previewOps.length === 0 && (
@@ -142,7 +142,7 @@ export const DiffDisplay: React.FC<DiffDisplayProps> = ({
</div>
</pre>
{/* 在预览下方提供显式打开按钮(可选) */}
{/* Provide explicit open button below preview (optional) */}
{onOpenDiff && (
<div className="diff-compact-actions">
<button

View File

@@ -48,7 +48,7 @@ export interface ToolCallData {
rawInput?: string | object;
content?: ToolCallContent[];
locations?: ToolCallLocation[];
timestamp?: number; // 添加时间戳字段用于消息排序
timestamp?: number; // Add a timestamp field for message sorting
}
/**