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.
This commit is contained in:
mesalogo
2026-09-28 19:27:52 +08:00
parent 120076a13d
commit 1c6264dd87
3 changed files with 27 additions and 7 deletions
+1
View File
@@ -447,6 +447,7 @@ Renderer 不接收任意系统 PID 控制能力。控制动作引用 Main 签发
- 文件预览提供复制项目相对路径、刷新,以及仅本机项目可用的“使用默认应用打开”。
刷新失败保留此前内容并显示错误;Markdown 默认渲染预览,可切换源码。
- Diff 提供刷新、复制项目相对路径和“查看当前文件”;删除项不显示查看当前文件入口。
文件路径与操作按钮位于分隔线上方,空间不足时换行;只有未暂存差异时省略“工作树更改”标题,同时存在已暂存差异时保留分区标题。
- 手动刷新或任务结束更新 Git 状态时,同步重读根目录、当前浏览目录和已展开目录并去重,保留目录展开状态,
刷新失败保留已有目录列表;重新展开目录时重读。目录读取错误在对应目录旁显示,
可就地重试。正在查看的单文件 Diff 同时重读,旧请求不得覆盖新结果。
+9 -7
View File
@@ -473,17 +473,19 @@ export function WorkspaceFilesPanel({
setDiff(undefined)
setActionError('')
}}><ChevronLeft size={14} />{t('files.backToChanges')}</button>
<strong>{diff.path}</strong>
<div className="workspace-files__diff-heading">
<strong>{diff.path}</strong>
<div className="workspace-files__toolbar">
{!changedByPath.get(diff.path)?.status.includes('D') && <button type="button" className="secondary-button" onClick={() => onOpenFile(diff.path)}>{t('files.viewCurrentFile')}</button>}
<button type="button" className="secondary-button" disabled={!diff.value && !diff.error} onClick={() => openDiff(diff.path)}>{t(!diff.value && !diff.error ? 'sidebar.workspace.refreshing' : 'sidebar.workspace.refresh')}</button>
<button type="button" className="secondary-button" onClick={() => void copyPath(diff.path)}>{t('sidebar.workspace.copyPath')}</button>
</div>
</div>
</header>
<div className="workspace-files__toolbar">
{!changedByPath.get(diff.path)?.status.includes('D') && <button type="button" className="secondary-button" onClick={() => onOpenFile(diff.path)}>{t('files.viewCurrentFile')}</button>}
<button type="button" className="secondary-button" disabled={!diff.value && !diff.error} onClick={() => openDiff(diff.path)}>{t(!diff.value && !diff.error ? 'sidebar.workspace.refreshing' : 'sidebar.workspace.refresh')}</button>
<button type="button" className="secondary-button" onClick={() => void copyPath(diff.path)}>{t('sidebar.workspace.copyPath')}</button>
</div>
{diff.error ? <p role="alert">{diff.error}<button type="button" onClick={() => openDiff(diff.path)}>{t('files.retry')}</button></p>
: !diff.value ? <p>{t('files.reading')}</p> : <>
{diff.value.stagedPatch && <><h4>{t('files.staged')}</h4>{renderPatch(diff.value.stagedPatch)}</>}
{diff.value.patch && <><h4>{t('files.unstaged')}</h4>{renderPatch(diff.value.patch)}</>}
{diff.value.patch && <>{diff.value.stagedPatch && <h4>{t('files.unstaged')}</h4>}{renderPatch(diff.value.patch)}</>}
{!diff.value.patch && !diff.value.stagedPatch && <p>{t('files.noDiff')}</p>}
{diff.value.truncated && <p>{t('files.diffTruncated')}</p>}
</>}
+17
View File
@@ -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;
}