Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

fix(turnrewind): diffs in pending previews, awaited confirm submission

yingtianlan952a80e68cc6
diff --git a/plugins/dsh-tauri-turnrewind/lib/client.js b/plugins/dsh-tauri-turnrewind/lib/client.js
index 44e71a5b..f6ecd2ea 100644
--- a/plugins/dsh-tauri-turnrewind/lib/client.js
+++ b/plugins/dsh-tauri-turnrewind/lib/client.js
@@ -205,24 +205,33 @@ globalThis.__ModuleLoader__.load({
const summary = parsed.summary || (state === 'error' ? '失败' : state === 'running' ? '运行中' : '完成')
const [expanded, setExpanded] = React.useState(hasDiff)
const [submitted, setSubmitted] = React.useState(null)
+ const [submitError, setSubmitError] = React.useState(null)
const titleColor = state === 'error' ? 'var(--dsw-alias-state-error-primary, #f85149)' : 'var(--dsw-alias-label-primary, #cccccc)'
const showBody = expanded && (hasDiff || parsed.files.length > 0)
// Buttons only on a pending preview (plan id present, command finished).
const actionable = parsed.planId !== undefined && state === 'ok'
- function submit(kind) {
+ async function submit(kind) {
if (submitted || !parsed.planId)
return
const line = kind === 'confirm'
? `/undo --confirm ${parsed.planId}`
: `/undo --cancel ${parsed.planId}`
- const sent = submitLine ? submitLine(line) : false
- setSubmitted(sent ? kind : 'failed')
+ const failure = submitLine ? await submitLine(line) : 'submit channel unavailable'
+ if (failure)
+ setSubmitError(failure)
+ else
+ setSubmitted(kind)
}
- const confirmLabel = submitted === 'confirm' ? '已确认,执行中…' : '✓ 执行撤销'
+ const confirmLabel = submitted === 'confirm' ? '已提交执行确认' : '✓ 执行撤销'
const cancelLabel = submitted === 'cancel' ? '已取消' : '✕ 取消'
+ const hint = submitError
+ ? `执行确认失败:${submitError}`
+ : submitted === 'confirm'
+ ? '已提交,执行结果见下方新的 undo 卡片'
+ : submitted === 'cancel' ? '已取消' : '执行将恢复下方文件到本轮改动前'
return jsxs('div', {
style: { border: `1px solid ${DIFF_COLORS.border}`, background: 'var(--dsw-alias-bg-layer-1, transparent)', borderRadius: 12, margin: '4px 0 4px 4px', overflow: 'hidden', maxWidth: '100%' },
@@ -266,7 +275,7 @@ globalThis.__ModuleLoader__.load({
children: cancelLabel,
}),
jsx('span', { style: { flex: 1 } }),
- jsx('span', { style: { color: 'var(--dsw-alias-label-tertiary, #8b8b8b)', fontSize: 11.5 }, children: submitted === 'failed' ? '发送失败,请手动输入 /undo --confirm' : '执行将恢复下方文件到本轮改动前' }),
+ jsx('span', { style: { color: submitError ? 'var(--dsw-alias-state-error-primary, #f85149)' : 'var(--dsw-alias-label-tertiary, #8b8b8b)', fontSize: 11.5, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: hint }),
],
})
: null,
@@ -455,22 +464,24 @@ globalThis.__ModuleLoader__.load({
const sessions = ctx.get('sessions')
// The ✓ button sends the confirm/cancel command line as a user prompt on
// the current session — the same path the input box uses. The host
- // parses it server-side and executes the parked pending plan.
- submitLine = (line) => {
+ // parses it server-side and executes the parked pending plan. Returns
+ // an error string so the card can surface real failures instead of
+ // silently swallowing an async rejection.
+ submitLine = async (line) => {
try {
const sessionId = sessions.list.getSnapshot().current
if (sessionId === undefined)
- return false
+ return 'no active session in the client session list'
const connection = ctx.get('connection')
const api = connection?.api ?? connection?.remote?.api
if (typeof api?.sessions?.prompt !== 'function')
- return false
- api.sessions.prompt({ sessionId, mode: 'queue', content: line })
- return true
+ return 'connection api has no sessions.prompt (service shape mismatch)'
+ await api.sessions.prompt({ sessionId, mode: 'queue', content: line })
+ return null
}
catch (error) {
console.error('[turnrewind] failed to submit undo confirmation:', error)
- return false
+ return String(error?.message ?? error)
}
}
diff --git a/plugins/dsh-tauri-turnrewind/lib/index.js b/plugins/dsh-tauri-turnrewind/lib/index.js
index f5b06fa4..699cf51b 100644
--- a/plugins/dsh-tauri-turnrewind/lib/index.js
+++ b/plugins/dsh-tauri-turnrewind/lib/index.js
@@ -161,7 +161,7 @@ async function formatPlan(runtime, target, entries, options) {
const flag = entry.conflict ? ' [conflict]' : ''
lines.push(` ${entry.change.padEnd(8)} ${entry.path}${flag}`)
}
- if (options.preview) {
+ if (options.preview || options.withDiffs) {
lines.push('')
lines.push('Undo will apply (turn output → restored state):')
for (const entry of entries) {
@@ -433,9 +433,10 @@ async function applyUndo(runtime, active, invocation) {
// Bare /undo and --preview park a pending plan; execution waits for the
// ✓ button (which sends /undo --confirm <plan-id>) so the user cannot
- // accidentally skip the preview.
+ // accidentally skip the preview. The card always carries the per-file
+ // diffs — seeing what will be reverted is the point of the preview.
if (!directExecute && !parsed.confirm) {
- const planText = await formatPlan(runtime, target, entries, parsed)
+ const planText = await formatPlan(runtime, target, entries, { ...parsed, withDiffs: true })
if (conflicts.length > 0)
return { kind: parsed.preview ? 'success' : 'error', text: planText }
const planId = createPendingPlan(runtime.db, {