Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### 未发布

- **Markdown 文件链接错误恢复**:Windows 路径因转义丢失分隔符时,侧栏会检查有限数量的候选路径;唯一命中时自动打开,多个命中时提供选择。文件不存在时显示可读提示,并提供复制路径、文件管理器打开和重试操作。
- **任务图展开修复**:平移画布后,聚合卡和 Agent 卡的下一次点击不再被误判为拖动;展开聚合与查看详情恢复正常。
- **任务图性能**:卡片内容使用独立 memo 边界,平移与布局补间不再重复渲染内容;布局用索引和显式栈替代逐边查找与深递归,同次宽度适配复用相同列数的布局。2000 个非根 Agent 的纯布局对照及 200/500 Agent 真浏览器证据见[验证记录](docs/plans/2026-10-23-tasks-folding-performance-validation.md),布局加速不外推为整页加速。
- **任务页拖拽改为每帧一次更新**:图模式背景平移、后台任务浮窗标题拖动、锚定弹层拖动不再按鼠标事件频率重绘(高回报率鼠标下此前每个 pointermove 都提交整块画布);松手同步落位,点击判定与最终位置不变。实测同一帧内 100 次移动的画布提交由 98 次降到 1 次。
Expand Down
113 changes: 107 additions & 6 deletions src/client/EditorHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
import { createElement } from 'react'
import clsx from 'clsx'
import { IconCheckOutlineRegular, IconFolderOpenRegular, IconRefreshOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
import { Button, IconCheckOutlineRegular, IconFolderOpenRegular, IconRefreshOutlineRegular, writeClipboard } from '@deepseek-ai/dsh-client-ui-primitives'
import type { Context } from '../context-types.ts'
import { api, mediaUrl, type SessionScope } from './api.ts'
import { api, mediaUrl, SidebarApiError, type SessionScope } from './api.ts'
import { BinaryDownload } from './binary-download.tsx'
import { planFirstMatch, planFsReadOutcome, type EditorLoadAction } from './editor-load.ts'
import { isWindowsAbsolutePath, markdownPathRepairCandidates } from './markdown-path-repair.ts'
import { clearEditorDirty, setEditorDirty } from './editor-dirty.ts'
import { baseName } from './FileTree.tsx'
import { createFrameBatcher } from './frame-batcher.ts'
Expand All @@ -49,7 +50,7 @@ import css from './sidebar.module.css'

type EditorLoad =
| { status: 'loading' }
| { status: 'error'; message: string }
| { status: 'error'; message: string; fileNotFound?: boolean; windowsAbsolutePath?: boolean; repairStatus?: 'searching' | 'done'; repairMatches?: string[]; repairError?: string }
| { status: 'ready'; viewer: FileViewerDescriptor; content?: string; size?: number; largeFile?: { size: number }; mtimeMs?: number; mediaUrl?: string; customData?: unknown }
| { status: 'binary' }

Expand Down Expand Up @@ -136,6 +137,7 @@ export function EditorHost(props: {
// the viewer loading flow (a directory is not a file).
const isDir = metaOf(tab).dir === true
const [load, setLoad] = useState<EditorLoad>({ status: 'loading' })
const [fileErrorAction, setFileErrorAction] = useState<string | null>(null)
// Manual refresh (issue #167): bumping the sequence re-runs the load effect
// with the same path/scope — the only reload entry besides open/close.
const [reloadSeq, setReloadSeq] = useState(0)
Expand Down Expand Up @@ -433,6 +435,7 @@ export function EditorHost(props: {
// closed, path changed, session switched) or re-matches the viewer.
const controller = new AbortController()
setLoad({ status: 'loading' })
setFileErrorAction(null)
const mediaUrlOf = (): string => mediaUrl(scope, path)
const apply = (action: EditorLoadAction): void => {
if (cancelled) return
Expand Down Expand Up @@ -470,9 +473,63 @@ export function EditorHost(props: {
// editor uses it as the save baseline (fs-conflict on drift).
if (outcome.kind === 'render') setLoad({ ...outcome, status: 'ready', mtimeMs: result.mtimeMs })
else apply(outcome)
}).catch((error: unknown) => {
}).catch(async (error: unknown) => {
if (cancelled) return
setLoad({ status: 'error', message: error instanceof Error ? error.message : String(error) })
const message = error instanceof Error ? error.message : String(error)
const fileNotFound = error instanceof SidebarApiError
&& error.code === 'fs-error'
&& message.startsWith('File not found: ')
if (!fileNotFound) {
setLoad({ status: 'error', message })
return
}

const candidates = markdownPathRepairCandidates(path)
setLoad({
status: 'error',
message,
fileNotFound: true,
windowsAbsolutePath: isWindowsAbsolutePath(path),
...(candidates.length > 0 ? { repairStatus: 'searching' as const } : {}),
})
if (candidates.length === 0) return

const matches = new Set<string>()
try {
for (let offset = 0; offset < candidates.length; offset += 8) {
const batch = candidates.slice(offset, offset + 8)
const results = await Promise.all(batch.map(candidate => api.fsSearch(scope, candidate, undefined, controller.signal)))
for (const result of results) {
const directories = new Set(result.dirs)
for (const match of result.matches) {
if (!directories.has(match)) matches.add(match)
}
}
}
} catch (repairError: unknown) {
if (cancelled) return
setLoad({
status: 'error',
message,
fileNotFound: true,
windowsAbsolutePath: true,
repairStatus: 'done',
repairError: repairError instanceof Error ? repairError.message : String(repairError),
})
return
}

if (cancelled) return
const repairMatches = [...matches]
if (repairMatches.length === 1) {
const repairedPath = repairMatches[0]!
const betterSidebar = ctx.get('betterSidebar')
if (betterSidebar?.updateTab !== undefined) {
betterSidebar.updateTab(tab.id, { path: repairedPath, title: baseName(repairedPath) }, scope.sessionId)
return
}
}
setLoad({ status: 'error', message, fileNotFound: true, windowsAbsolutePath: true, repairStatus: 'done', repairMatches })
})
return
}
Expand Down Expand Up @@ -652,7 +709,51 @@ export function EditorHost(props: {
<div className={css.editorMain}>
{showEmpty && <div className={css.editorPlaceholder}>{t('editorEmptyHint')}</div>}
{!showEmpty && load.status === 'loading' && <div className={css.editorPlaceholder}>{t('loading')}</div>}
{!showEmpty && load.status === 'error' && <div className={css.editorError}>{load.message}</div>}
{!showEmpty && load.status === 'error' && (
<div className={css.editorError} role="alert">
<div>{load.fileNotFound ? t('editorFileNotFound', { path }) : load.message}</div>
{load.fileNotFound && load.windowsAbsolutePath && (
<div className={css.editorErrorHint}>{t('editorMarkdownPathHint')}</div>
)}
{load.repairStatus === 'searching' && <div className={css.editorErrorHint}>{t('editorPathRepairSearching')}</div>}
{load.repairStatus === 'done' && load.repairMatches?.length === 0 && (
<div className={css.editorErrorHint}>{t('editorPathRepairNone')}</div>
)}
{load.repairMatches !== undefined && load.repairMatches.length > 0 && (
<div className={css.editorErrorCandidates}>
<div>{t('editorPathRepairChoices')}</div>
{load.repairMatches.map(candidate => (
<Button key={candidate} variant="outline" onClick={() => {
ctx.get('betterSidebar')?.updateTab(tab.id, { path: candidate, title: baseName(candidate) }, scope.sessionId)
}}>
{candidate}
</Button>
))}
</div>
)}
{load.repairError !== undefined && (
<div className={css.editorErrorHint}>{t('editorPathRepairFailed', { message: load.repairError })}</div>
)}
<div className={css.editorErrorActions}>
<Button variant="outline" onClick={() => {
void writeClipboard(path).then((copied) => {
setFileErrorAction(copied ? null : t('editorCopyPathFailed'))
})
}}>
{t('editorCopyPath')}
</Button>
<Button variant="outline" onClick={() => {
void openInApp.reveal(path).then((opened) => {
setFileErrorAction(opened ? null : t('editorRevealPathFailed'))
})
}}>
{t('editorOpenInFileManager')}
</Button>
<Button variant="outline" onClick={refreshFile}>{t('retry')}</Button>
</div>
{fileErrorAction !== null && <div className={css.editorErrorHint} role="status">{fileErrorAction}</div>}
</div>
)}
{!showEmpty && load.status === 'binary' && <BinaryDownload scope={scope} path={path} />}
{!showEmpty && load.status === 'ready' && createElement(load.viewer.component, {
ctx, store, scope, path, title,
Expand Down
10 changes: 10 additions & 0 deletions src/client/locales-ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ export const ar: Record<string, string> = {
explorerExcludeAdd: 'إضافة',
explorerExcludeRemove: 'إزالة',
editorTreeToggle: 'لوحة شجرة الملفات',
editorFileNotFound: 'الملف غير موجود: {path}',
editorMarkdownPathHint: 'قد يكون Markdown قد حذف شرطة مائلة عكسية من مسار Windows. جرّب استخدام الشرطات المائلة أو وضع المسار في كتلة تعليمات برمجية.',
editorPathRepairSearching: 'جارٍ فحص مسارات Windows المحتملة…',
editorPathRepairNone: 'لم يتم العثور على مسار مطابق بشكل فريد. تحقّق من المسار ثم أعد المحاولة.',
editorPathRepairChoices: 'تم العثور على عدة مسارات محتملة. اختر المسار الصحيح:',
editorPathRepairFailed: 'تعذّر فحص المسارات المُصلحة: {message}',
editorCopyPath: 'نسخ المسار',
editorOpenInFileManager: 'فتح في مدير الملفات',
editorCopyPathFailed: 'تعذّر نسخ المسار',
editorRevealPathFailed: 'تعذّر فتح هذا المسار في مدير الملفات',
editorPathPlaceholder: 'مسار الملف (نسبي لدليل الجلسة أو مطلق)، Enter للفتح',
editorSearchPlaceholder: 'البحث في الملفات بالاسم…',
editorSearchNoResults: 'لا ملفات مطابقة',
Expand Down
10 changes: 10 additions & 0 deletions src/client/locales-de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ export const de: Record<string, string> = {
explorerExcludeAdd: 'Hinzufügen',
explorerExcludeRemove: 'Entfernen',
editorTreeToggle: 'Dateibaum-Panel',
editorFileNotFound: 'Datei nicht gefunden: {path}',
editorMarkdownPathHint: 'Markdown hat möglicherweise einen Backslash im Windows-Pfad entfernt. Verwende Schrägstriche oder setze den Pfad in einen Codeblock.',
editorPathRepairSearching: 'Mögliche Windows-Pfade werden geprüft…',
editorPathRepairNone: 'Es wurde kein eindeutiger Pfad gefunden. Prüfe den Pfad und versuche es erneut.',
editorPathRepairChoices: 'Mehrere mögliche Pfade gefunden. Wähle den richtigen Pfad:',
editorPathRepairFailed: 'Reparierte Pfade konnten nicht geprüft werden: {message}',
editorCopyPath: 'Pfad kopieren',
editorOpenInFileManager: 'Im Dateimanager öffnen',
editorCopyPathFailed: 'Pfad konnte nicht kopiert werden',
editorRevealPathFailed: 'Pfad konnte nicht im Dateimanager geöffnet werden',
editorPathPlaceholder: 'Dateipfad (relativ zum Sitzungsverzeichnis oder absolut), Enter zum Öffnen',
editorSearchPlaceholder: 'Nach Dateiname suchen…',
editorSearchNoResults: 'Keine passenden Dateien',
Expand Down
10 changes: 10 additions & 0 deletions src/client/locales-fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ export const fr: Record<string, string> = {
explorerExcludeAdd: 'Ajouter',
explorerExcludeRemove: 'Supprimer',
editorTreeToggle: 'Panneau d’arborescence',
editorFileNotFound: 'Fichier introuvable : {path}',
editorMarkdownPathHint: 'Markdown a peut-être supprimé une barre oblique inverse de ce chemin Windows. Essayez les barres obliques ou placez le chemin dans un bloc de code.',
editorPathRepairSearching: 'Recherche de chemins Windows possibles…',
editorPathRepairNone: 'Aucun chemin correspondant unique trouvé. Vérifiez le chemin puis réessayez.',
editorPathRepairChoices: 'Plusieurs chemins possibles trouvés. Choisissez le bon chemin :',
editorPathRepairFailed: 'Impossible de vérifier les chemins réparés : {message}',
editorCopyPath: 'Copier le chemin',
editorOpenInFileManager: 'Ouvrir dans le gestionnaire de fichiers',
editorCopyPathFailed: 'Impossible de copier le chemin',
editorRevealPathFailed: 'Impossible d’ouvrir ce chemin dans le gestionnaire de fichiers',
editorPathPlaceholder: 'Saisissez un chemin de fichier (relatif au répertoire de session ou absolu), Entrée pour ouvrir',
editorSearchPlaceholder: 'Rechercher par nom de fichier…',
editorSearchNoResults: 'Aucun fichier correspondant',
Expand Down
10 changes: 10 additions & 0 deletions src/client/locales-hi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export const hi: Record<string, string> = {
explorerExcludeAdd: 'जोड़ें',
explorerExcludeRemove: 'हटाएँ',
editorTreeToggle: 'फ़ाइल ट्री पैनल',
editorFileNotFound: 'फ़ाइल नहीं मिली: {path}',
editorMarkdownPathHint: 'Markdown ने Windows पथ से बैकस्लैश हटा दिया हो सकता है। फ़ॉरवर्ड स्लैश आज़माएँ या पथ को कोड ब्लॉक में रखें।',
editorPathRepairSearching: 'संभावित Windows पथ जाँचे जा रहे हैं…',
editorPathRepairNone: 'कोई एकल मेल खाता पथ नहीं मिला। पथ जाँचकर फिर प्रयास करें।',
editorPathRepairChoices: 'कई संभावित पथ मिले। सही पथ चुनें:',
editorPathRepairFailed: 'सुधारे गए पथ जाँचे नहीं जा सके: {message}',
editorCopyPath: 'पथ कॉपी करें',
editorOpenInFileManager: 'फ़ाइल प्रबंधक में खोलें',
editorCopyPathFailed: 'पथ कॉपी नहीं हो सका',
editorRevealPathFailed: 'यह पथ फ़ाइल प्रबंधक में नहीं खुल सका',
editorPathPlaceholder: 'फ़ाइल पथ दर्ज करें (सत्र डायरेक्टरी के सापेक्ष या निरपेक्ष), Enter से खोलें',
editorSearchPlaceholder: 'फ़ाइल नाम से खोजें…',
editorSearchNoResults: 'कोई मेल खाती फ़ाइल नहीं',
Expand Down
10 changes: 10 additions & 0 deletions src/client/locales-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ export const id: Record<string, string> = {
explorerExcludeAdd: 'Tambah',
explorerExcludeRemove: 'Hapus',
editorTreeToggle: 'Panel pohon berkas',
editorFileNotFound: 'Berkas tidak ditemukan: {path}',
editorMarkdownPathHint: 'Markdown mungkin menghapus garis miring terbalik dari jalur Windows ini. Coba gunakan garis miring biasa atau letakkan jalur di blok kode.',
editorPathRepairSearching: 'Memeriksa kemungkinan jalur Windows…',
editorPathRepairNone: 'Tidak ditemukan jalur yang cocok secara unik. Periksa jalur lalu coba lagi.',
editorPathRepairChoices: 'Beberapa jalur mungkin ditemukan. Pilih jalur yang benar:',
editorPathRepairFailed: 'Tidak dapat memeriksa jalur yang diperbaiki: {message}',
editorCopyPath: 'Salin jalur',
editorOpenInFileManager: 'Buka di pengelola berkas',
editorCopyPathFailed: 'Jalur tidak dapat disalin',
editorRevealPathFailed: 'Jalur ini tidak dapat dibuka di pengelola berkas',
editorPathPlaceholder: 'Path berkas (relatif terhadap direktori sesi atau absolut), Enter untuk membuka',
editorSearchPlaceholder: 'Cari berkas berdasarkan nama…',
editorSearchNoResults: 'Tidak ada berkas yang cocok',
Expand Down
10 changes: 10 additions & 0 deletions src/client/locales-it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ export const it: Record<string, string> = {
explorerExcludeAdd: 'Aggiungi',
explorerExcludeRemove: 'Rimuovi',
editorTreeToggle: 'Pannello dell’albero dei file',
editorFileNotFound: 'File non trovato: {path}',
editorMarkdownPathHint: 'Markdown potrebbe aver rimosso una barra inversa da questo percorso Windows. Prova con le barre normali oppure inserisci il percorso in un blocco di codice.',
editorPathRepairSearching: 'Controllo dei possibili percorsi Windows…',
editorPathRepairNone: 'Nessun percorso univoco trovato. Controlla il percorso e riprova.',
editorPathRepairChoices: 'Trovati più percorsi possibili. Scegli quello corretto:',
editorPathRepairFailed: 'Impossibile controllare i percorsi corretti: {message}',
editorCopyPath: 'Copia percorso',
editorOpenInFileManager: 'Apri nel file manager',
editorCopyPathFailed: 'Impossibile copiare il percorso',
editorRevealPathFailed: 'Impossibile aprire questo percorso nel file manager',
editorPathPlaceholder: 'Percorso del file (relativo alla directory della sessione o assoluto), Invio per aprire',
editorSearchPlaceholder: 'Cerca file per nome…',
editorSearchNoResults: 'Nessun file corrispondente',
Expand Down
10 changes: 10 additions & 0 deletions src/client/locales-ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export const ja: Record<string, string> = {
explorerExcludeAdd: '追加',
explorerExcludeRemove: '削除',
editorTreeToggle: 'ファイルツリーパネル',
editorFileNotFound: 'ファイルが見つかりません: {path}',
editorMarkdownPathHint: 'Markdown が Windows パスのバックスラッシュを取り除いた可能性があります。スラッシュを使うか、パスをコードブロックに入れてください。',
editorPathRepairSearching: 'Windows パスの候補を確認しています…',
editorPathRepairNone: '一致するパスを一意に特定できませんでした。パスを確認して再試行してください。',
editorPathRepairChoices: '複数の候補が見つかりました。正しいパスを選択してください:',
editorPathRepairFailed: '修復候補を確認できませんでした: {message}',
editorCopyPath: 'パスをコピー',
editorOpenInFileManager: 'ファイルマネージャーで開く',
editorCopyPathFailed: 'パスをコピーできませんでした',
editorRevealPathFailed: 'ファイルマネージャーでこのパスを開けませんでした',
editorPathPlaceholder: 'ファイルパス(セッションディレクトリからの相対 or 絶対)、Enter で開く',
editorSearchPlaceholder: 'ファイル名で検索…',
editorSearchNoResults: '一致するファイルはありません',
Expand Down
Loading
Loading