Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: rewind cannot show all changed files

ldstyle82acdeb36e5ff
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/rewind.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/rewind.ts
index 5a3532449a..91a99e6ab3 100644
--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/rewind.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/rewind.ts
@@ -48,8 +48,15 @@ const RESET = "\x1b[0m";
function toRelativePath(absPath: string, workspaceDir?: string): string {
if (!workspaceDir) return absPath;
- const prefix = workspaceDir.endsWith("/") ? workspaceDir : workspaceDir + "/";
- if (absPath.startsWith(prefix)) return absPath.slice(prefix.length);
+ // Normalize separators to / for cross-platform comparison
+ const normAbs = absPath.replace(/\\/g, "/");
+ const normBase = workspaceDir.replace(/\\/g, "/");
+ const prefix = normBase.endsWith("/") ? normBase : normBase + "/";
+ if (normAbs.toLowerCase().startsWith(prefix.toLowerCase())) {
+ const rel = normAbs.slice(prefix.length);
+ // Preserve original separators from absPath for display
+ return absPath.slice(absPath.length - rel.length);
+ }
return absPath;
}
@@ -110,25 +117,26 @@ export function createRewindCommand(): SlashCommand {
} else {
const workspaceDir = ctx.getWorkspaceDir();
- const turnOptions: { label: string; description: string }[] = [
+ const turnOptions: { label: string; description: string; details?: string[] }[] = [
{
label: "current",
description: "Stay at current session (no change)",
},
];
for (const t of turns) {
- let desc = t.content_preview;
+ const desc = t.content_preview;
+ const details: string[] = [];
if (t.files && t.files.length > 0) {
- const fileList = t.files
- .map((f) => formatFileChange(f, workspaceDir))
- .join(", ");
- desc += ` [${fileList}]`;
+ for (const f of t.files) {
+ details.push(formatFileChange(f, workspaceDir));
+ }
} else if (t.stats.filesChanged > 0) {
- desc += ` [files: ${t.stats.filesChanged} +${t.stats.linesAdded}/-${t.stats.linesRemoved}]`;
+ details.push(`files: ${t.stats.filesChanged} +${t.stats.linesAdded}/-${t.stats.linesRemoved}`);
}
turnOptions.push({
label: String(t.turn_index),
description: desc,
+ details: details.length > 0 ? details : undefined,
});
}
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/event-handlers.ts b/jiuwenswarm/channels/tui/frontend/src/core/event-handlers.ts
index 58558a4070..f3a5607921 100644
--- a/jiuwenswarm/channels/tui/frontend/src/core/event-handlers.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/core/event-handlers.ts
@@ -39,6 +39,7 @@ export interface PendingQuestionItem {
export interface PendingQuestionOption {
label: string;
description?: string;
+ details?: string[];
}
export interface UserAnswer {
diff --git a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
index ea8b66e9d7..01bf620b8c 100644
--- a/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/ui/app-screen.ts
@@ -490,6 +490,7 @@ export class AppScreen implements Component, Focusable {
private syncingComposerInput = false;
private pendingQuestionAnswers = new Map<number, string>();
private questionList: SelectList | null = null;
+ private questionDetailsMap: Map<string, string[]> | null = null;
private otherInputMode = false;
private resumeSessionList: ResumeSessionListState | null = null;
private modelList: ModelListState | null = null;
@@ -1354,6 +1355,7 @@ export class AppScreen implements Component, Focusable {
this.activeQuestionIndex = 0;
this.pendingQuestionAnswers.clear();
this.questionList = null;
+ this.questionDetailsMap = null;
if (!this.editor.getText() && this.draftBeforeQuestion) {
this.editor.setText(this.draftBeforeQuestion);
}
@@ -3123,6 +3125,16 @@ export class AppScreen implements Component, Focusable {
if (this.questionList !== null) {
lines.push(...this.questionList.render(width));
+ // Render details sub-lines for the currently highlighted option
+ const selectedItem = this.questionList.getSelectedItem();
+ if (selectedItem && this.questionDetailsMap) {
+ const details = this.questionDetailsMap.get(selectedItem.value);
+ if (details && details.length > 0) {
+ for (const detail of details) {
+ lines.push(padToWidth(palette.text.dim(` ${detail}`), width));
+ }
+ }
+ }
lines.push(
padToWidth(
palette.text.dim(
@@ -3141,12 +3153,14 @@ export class AppScreen implements Component, Focusable {
const pendingQuestion = snapshot.pendingQuestion;
if (!pendingQuestion) {
this.questionList = null;
+ this.questionDetailsMap = null;
return;
}
const question = pendingQuestion.questions[this.activeQuestionIndex];
if (!question || question.options.length === 0) {
this.questionList = null;
+ this.questionDetailsMap = null;
return;
}
@@ -3158,11 +3172,27 @@ export class AppScreen implements Component, Focusable {
: option.label,
description: option.description,
}));
+
+ // Build details map for options that have sub-lines (e.g. rewind file changes)
+ const detailsMap = new Map<string, string[]>();
+ for (const option of question.options) {
+ if (option.details && option.details.length > 0) {
+ detailsMap.set(option.label, option.details);
+ }
+ }
+ this.questionDetailsMap = detailsMap;
+
const maxVisible = pendingQuestion.source === "permission_interrupt" ? 4 : 6;
+ // For questions with details sub-lines (e.g. rewind), use a narrower label column
+ // so the description starts sooner and details can align beneath it.
+ const layout = detailsMap.size > 0
+ ? { minPrimaryColumnWidth: 10, maxPrimaryColumnWidth: 10 }
+ : {};
const list = new SelectList(
items,
Math.min(Math.max(items.length, 1), maxVisible),
selectListTheme,
+ layout,
);
list.onSelect = (item) => {
this.handleQuestionSelection(item.value);
@@ -3175,6 +3205,9 @@ export class AppScreen implements Component, Focusable {
this.handleQuestionSelection("");
}
};
+ list.onSelectionChange = () => {
+ this.invalidate();
+ };
const selectedValue = this.pendingQuestionAnswers.get(this.activeQuestionIndex);
const selectedIndex = selectedValue
? items.findIndex((item) => item.value === selectedValue)
diff --git a/jiuwenswarm/server/utils/diff_service.py b/jiuwenswarm/server/utils/diff_service.py
index c039a59f35..f69d9db273 100644
--- a/jiuwenswarm/server/utils/diff_service.py
+++ b/jiuwenswarm/server/utils/diff_service.py
@@ -51,15 +51,11 @@ class DiffService:
if record["role"] == "user":
turn_start = record["timestamp"]
- turn_end = None
-
- for j in range(i + 1, len(history)):
- next_record = history[j]
- if next_record["role"] == "user":
- break
- if self._is_turn_end(next_record):
- turn_end = next_record["timestamp"]
- break
+ # Use next user message timestamp as turn end boundary.
+ # A turn logically spans from one user message to the next,
+ # so this captures all file edits within the turn's scope
+ # (including those after chat.final but before the next user msg).
+ turn_end = self._find_next_user_time(history, i)
turns.append({
"turnIndex": len(turns) + 1,