From 1c6264dd87acd4f3f6b2da6be04b8e6be0e4d01b Mon Sep 17 00:00:00 2001 From: mesalogo Date: Mon, 28 Sep 2026 19:27:52 +0800 Subject: [PATCH] fix: group worktree diff actions with the file path Move file actions above the divider alongside the path, allowing wrapping in narrow panels. Hide the redundant worktree heading unless staged changes also need a separate section. Release note: Worktree diffs now group file actions above the divider and omit the redundant heading when only unstaged changes are shown. --- docs/features/assistant-workbar/prd.md | 1 + src/renderer/src/WorkspaceFilesPanel.tsx | 16 +++++++++------- src/renderer/src/styles.css | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/docs/features/assistant-workbar/prd.md b/docs/features/assistant-workbar/prd.md index d5690a66..a2ed1b8c 100644 --- a/docs/features/assistant-workbar/prd.md +++ b/docs/features/assistant-workbar/prd.md @@ -447,6 +447,7 @@ Renderer 不接收任意系统 PID 控制能力。控制动作引用 Main 签发 - 文件预览提供复制项目相对路径、刷新,以及仅本机项目可用的“使用默认应用打开”。 刷新失败保留此前内容并显示错误;Markdown 默认渲染预览,可切换源码。 - Diff 提供刷新、复制项目相对路径和“查看当前文件”;删除项不显示查看当前文件入口。 + 文件路径与操作按钮位于分隔线上方,空间不足时换行;只有未暂存差异时省略“工作树更改”标题,同时存在已暂存差异时保留分区标题。 - 手动刷新或任务结束更新 Git 状态时,同步重读根目录、当前浏览目录和已展开目录并去重,保留目录展开状态, 刷新失败保留已有目录列表;重新展开目录时重读。目录读取错误在对应目录旁显示, 可就地重试。正在查看的单文件 Diff 同时重读,旧请求不得覆盖新结果。 diff --git a/src/renderer/src/WorkspaceFilesPanel.tsx b/src/renderer/src/WorkspaceFilesPanel.tsx index e805ab27..7ee66c43 100644 --- a/src/renderer/src/WorkspaceFilesPanel.tsx +++ b/src/renderer/src/WorkspaceFilesPanel.tsx @@ -473,17 +473,19 @@ export function WorkspaceFilesPanel({ setDiff(undefined) setActionError('') }}>{t('files.backToChanges')} - {diff.path} +
+ {diff.path} +
+ {!changedByPath.get(diff.path)?.status.includes('D') && } + + +
+
-
- {!changedByPath.get(diff.path)?.status.includes('D') && } - - -
{diff.error ?

{diff.error}

: !diff.value ?

{t('files.reading')}

: <> {diff.value.stagedPatch && <>

{t('files.staged')}

{renderPatch(diff.value.stagedPatch)}} - {diff.value.patch && <>

{t('files.unstaged')}

{renderPatch(diff.value.patch)}} + {diff.value.patch && <>{diff.value.stagedPatch &&

{t('files.unstaged')}

}{renderPatch(diff.value.patch)}} {!diff.value.patch && !diff.value.stagedPatch &&

{t('files.noDiff')}

} {diff.value.truncated &&

{t('files.diffTruncated')}

} } diff --git a/src/renderer/src/styles.css b/src/renderer/src/styles.css index 017149e7..16786e3b 100644 --- a/src/renderer/src/styles.css +++ b/src/renderer/src/styles.css @@ -4674,6 +4674,23 @@ button > svg { justify-content: flex-end; } +.workspace-files__diff-heading { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: var(--space-2) var(--space-4); +} + +.workspace-files__diff-heading > strong { + min-width: 0; + flex: 1 1 auto; + overflow-wrap: anywhere; +} + +.workspace-files__diff-heading > .workspace-files__toolbar { + justify-content: flex-start; +} + .assistant-sidebar__body--browser { overflow: hidden; }