Skip to content

The agent that grows with you

fix(tui): /rollback N --all reaches the gateway as all, not a file path

unsupportedpastels9cbe5c63e0b4
diff --git a/locales/_keys.tui.json b/locales/_keys.tui.json
index 8b78b97e20a..80f2553dd35 100644
--- a/locales/_keys.tui.json
+++ b/locales/_keys.tui.json
@@ -950,7 +950,11 @@
"slashCmd.ops.replayDiff.usage",
"slashCmd.ops.rollback.diffTitle",
"slashCmd.ops.rollback.failed",
+ "slashCmd.ops.rollback.failedDeletes",
+ "slashCmd.ops.rollback.keptOversize",
+ "slashCmd.ops.rollback.keptUserEdits",
"slashCmd.ops.rollback.listTitle",
+ "slashCmd.ops.rollback.morePaths",
"slashCmd.ops.rollback.noChanges",
"slashCmd.ops.rollback.noMetadata",
"slashCmd.ops.rollback.noSession",
diff --git a/ui-tui/src/__tests__/canonicalTuiOps.test.ts b/ui-tui/src/__tests__/canonicalTuiOps.test.ts
index e69e281bed3..e9df45df8ac 100644
--- a/ui-tui/src/__tests__/canonicalTuiOps.test.ts
+++ b/ui-tui/src/__tests__/canonicalTuiOps.test.ts
@@ -89,7 +89,14 @@ it('/rollback list, diff and restore call the owner\'s rollback verbs with main\
'rollback.restore': { success: true, reason: 'before write_file', history_removed: 2 }
})
- for (const cmd of ['/rollback', '/rollback diff 1', '/rollback 1 src/a.py', '/rollback 1']) {
+ for (const cmd of [
+ '/rollback',
+ '/rollback diff 1',
+ '/rollback 1 src/a.py',
+ '/rollback 1',
+ '/rollback 1 --all',
+ '/rollback 1 src/a.py --force'
+ ]) {
slash(cmd)
await flush()
}
@@ -98,14 +105,43 @@ it('/rollback list, diff and restore call the owner\'s rollback verbs with main\
['rollback.list', { session_id: 'owner' }],
['rollback.diff', { hash: '1', session_id: 'owner' }],
['rollback.restore', { file_path: 'src/a.py', hash: '1', session_id: 'owner' }],
- ['rollback.restore', { hash: '1', session_id: 'owner' }]
+ ['rollback.restore', { hash: '1', session_id: 'owner' }],
+ // Main's --all/--force reverts hand-edits too; it is a flag, never part of the file path.
+ ['rollback.restore', { all: true, hash: '1', session_id: 'owner' }],
+ ['rollback.restore', { file_path: 'src/a.py', hash: '1', session_id: 'owner' }]
])
expect(panel).toHaveBeenCalledWith('Rollback checkpoints', [{ rows: [['1. abcdef1234', 't1 · before write_file']] }])
expect(page).toHaveBeenCalledWith(' a.txt | 2 +-\n\n-old\n+new', expect.any(String))
expect(notices(sys)).toEqual([
'rollback restored src/a.py: before write_file',
- 'rollback restored workspace: before write_file'
+ 'rollback restored workspace: before write_file',
+ 'rollback restored workspace: before write_file',
+ 'rollback restored src/a.py: before write_file'
])
// A whole-tree restore rewound the transcript (history_removed > 0): the view drops the exchange.
expect(setHistoryItems).toHaveBeenCalled()
})
+
+it('/rollback restore names the hand-edits it kept, oversize skips and failed deletions, as main\'s CLI does', async () => {
+ const { slash, sys } = harness({
+ 'rollback.restore': {
+ failed_deletes: ['locked.txt'],
+ history_removed: 0,
+ reason: 'before write_file',
+ skipped_oversize: ['big.bin'],
+ skipped_user_edits: ['a.md', 'b.md', 'c.md', 'd.md', 'e.md', 'f.md', 'g.md'],
+ success: true
+ }
+ })
+
+ slash('/rollback 1')
+ await flush()
+
+ // The gateway-backed classic CLI's lines (hermes_cli/gateway_rollback.py), with its --all hint.
+ expect(notices(sys)).toEqual([
+ 'rollback restored workspace: before write_file',
+ '↷ Kept your hand-edits: a.md, b.md, c.md, d.md, e.md (+2 more)\nUse /rollback <N> --all to restore those too.',
+ '↷ Kept (too large for checkpoints, no stored copy to revert to): big.bin',
+ '⚠️ Could not remove (left in place): locked.txt'
+ ])
+})
diff --git a/ui-tui/src/app/slash/commands/ops.ts b/ui-tui/src/app/slash/commands/ops.ts
index fba074b6aaf..61dc60e312d 100644
--- a/ui-tui/src/app/slash/commands/ops.ts
+++ b/ui-tui/src/app/slash/commands/ops.ts
@@ -306,11 +306,20 @@ export const opsCommands: SlashCommand[] = [
}
const hash = first
- const filePath = rest.join(' ').trim()
+ // Main's --all/--force: a whole-tree restore also reverts hand-edits. A flag, never a path.
+ const isAll = (arg: string) => ['--all', '--force'].includes(arg.toLowerCase())
+
+ const filePath = rest
+ .filter(arg => !isAll(arg))
+ .join(' ')
+ .trim()
+
+ const all = !filePath && rest.some(isAll)
return ctx.gateway
.rpc<RollbackRestoreResponse>('rollback.restore', {
...(filePath ? { file_path: filePath } : {}),
+ ...(all ? { all } : {}),
hash,
session_id: ctx.sid
})
@@ -326,6 +335,20 @@ export const opsCommands: SlashCommand[] = [
const detail = r.reason || r.message || r.restored_to || t('slashCmd.ops.rollback.restoredDetail')
ctx.transcript.sys(t('slashCmd.ops.rollback.restored', target, detail))
+ // What a safe whole-tree restore left alone, as main's CLI lists it: the first five paths.
+ const summarize = (paths: string[]) =>
+ paths.slice(0, 5).join(', ') + (paths.length > 5 ? t('slashCmd.ops.rollback.morePaths', paths.length - 5) : '')
+
+ for (const [key, paths] of [
+ ['keptUserEdits', r.skipped_user_edits],
+ ['keptOversize', r.skipped_oversize],
+ ['failedDeletes', r.failed_deletes]
+ ] as const) {
+ if (paths?.length) {
+ ctx.transcript.sys(t(`slashCmd.ops.rollback.${key}`, summarize(paths)))
+ }
+ }
+
if ((r.history_removed ?? 0) > 0) {
ctx.transcript.setHistoryItems(prev => ctx.transcript.trimLastExchange(prev))
}
diff --git a/ui-tui/src/gatewayTypes.ts b/ui-tui/src/gatewayTypes.ts
index 0425df917e7..23ab3536d9d 100644
--- a/ui-tui/src/gatewayTypes.ts
+++ b/ui-tui/src/gatewayTypes.ts
@@ -544,10 +544,13 @@ export interface RollbackDiffResponse {
export interface RollbackRestoreResponse {
error?: string
+ failed_deletes?: string[]
history_removed?: number
message?: string
reason?: string
restored_to?: string
+ skipped_oversize?: string[]
+ skipped_user_edits?: string[]
success?: boolean
}
diff --git a/ui-tui/src/i18n/en/slashCmd/ops.ts b/ui-tui/src/i18n/en/slashCmd/ops.ts
index 443ffbed2ae..5bd4385ee05 100644
--- a/ui-tui/src/i18n/en/slashCmd/ops.ts
+++ b/ui-tui/src/i18n/en/slashCmd/ops.ts
@@ -47,7 +47,13 @@ export const slashCmdOpsEn = {
workspaceTarget: 'workspace',
restoredDetail: 'restored',
// {0}=target (file path or "workspace"), {1}=detail
- restored: (target: string, detail: string) => `rollback restored ${target}: ${detail}`
+ restored: (target: string, detail: string) => `rollback restored ${target}: ${detail}`,
+ // {0}=summarized paths; main's CLI lines for what a safe whole-tree restore left alone
+ keptUserEdits: (files: string) => `↷ Kept your hand-edits: ${files}\nUse /rollback <N> --all to restore those too.`,
+ keptOversize: (files: string) => `↷ Kept (too large for checkpoints, no stored copy to revert to): ${files}`,
+ failedDeletes: (files: string) => `⚠️ Could not remove (left in place): ${files}`,
+ // {0}=count of paths not listed
+ morePaths: (count: number) => ` (+${count} more)`
},
agents: {
paused: 'delegation · paused',