优化: 会话入口与对话交互打磨

- 完成卡点开子代理轨迹浮层,任务抽屉关联会话跳转
- 提及片段编辑差分三向判定,不再错位
- 长回复折叠完成瞬间锚定消息顶,视口不跳
- 空编辑/技能无匹配/回填覆盖草稿均有提示确认
- 队列编辑态切会话重置,刷新快捷键不再误触
- git 变更面板去重缓存,项目卡骨架与溢出重测
This commit is contained in:
lxy
2026-10-03 17:57:43 +08:00
parent 890ceef0ec
commit f67e65633b
8 changed files with 433 additions and 19 deletions
+30 -10
View File
@@ -185,8 +185,6 @@ const loading = ref(false)
const gitStatus = ref<GitStatusResult | null>(null)
const showHistory = ref(false)
const selectedFile = ref('')
const diffContent = ref('')
const diffLoading = ref(false)
// 行内错误提示:loadError 主区展示(loadStatus 失败),actionError 分支条下方展示(loadMore/selectFile/切分支/提交详情 失败)
const loadError = ref('')
const actionError = ref('')
@@ -194,6 +192,12 @@ const actionError = ref('')
// (对齐 ProjectDetail taskReqSeq 模式)
let statusReqSeq = 0
// UX走查 P3-4: 点文件 diff 单槽去重缓存 — 重复点击同一文件不再重复发 git diff IPC,
// 直接复用上次结果回填。切模块/refreshKey 重拉状态均经 loadStatus,缓存在彼处失效,
// 防 AI 改文件后旧 diff 被复用(单槽不设 Map,免过期条目堆积)
let lastDiffKey = ''
let lastDiffContent = ''
/** 单条提交记录形状(对齐 getModuleCommits / GitRecentCommit)。 */
interface CommitItem {
hash: string
@@ -353,6 +357,10 @@ async function loadStatus() {
const mid = props.moduleId
if (!mid) return
const seq = ++statusReqSeq
// UX走查 P3-4: 状态重拉(切模块/外部 refreshKey,如 AI 改文件)即失效 diff 去重缓存,
// 防改文件后旧 diff 被复用
lastDiffKey = ''
lastDiffContent = ''
loading.value = true
loadError.value = ''
actionError.value = ''
@@ -448,23 +456,35 @@ async function switchToHistory() {
async function selectFile(path: string) {
selectedFile.value = path
// 先切预览到该文件(内容视图),diff 拉到后回填,点文件即展示变化
// 先切预览到该文件(内容视图兜底),diff 拉到后回填切 diff 视图,点文件即展示变化
emit('select-file', path)
diffContent.value = ''
actionError.value = ''
diffLoading.value = true
// UX走查 P3-4 同参数去重:重复点击同一文件直接复用缓存 diff,不再发 IPC
const key = `${props.moduleId}::${path}`
if (key === lastDiffKey) {
emit('select-file', path, lastDiffContent)
return
}
// 捕获请求时的状态序号:期间 refreshKey 重拉(缓存已失效)则本次结果不入缓存,防改文件前旧 diff 滞留
const seqAtReq = statusReqSeq
let diff = ''
try {
const res = await moduleApi.getModuleFileDiff(props.moduleId, path)
diffContent.value = res.diff || ''
diff = res.diff || ''
if (seqAtReq === statusReqSeq) {
lastDiffKey = key
lastDiffContent = diff
}
} catch (e) {
diffContent.value = ''
// 失败清缓存使下次点击可重试;不回填 diff,预览停在内容视图(错误经 actionError 条就近提示)
lastDiffKey = ''
lastDiffContent = ''
actionError.value = String(e)
} finally {
diffLoading.value = false
return
}
// 仅当仍是当前选中文件时才回填 diff,防快速切换时旧响应覆盖新文件
if (selectedFile.value === path) {
emit('select-file', path, diffContent.value)
emit('select-file', path, diff)
}
}