Fix so rewind starts at the bottom and loadHistory refreshes static content. (#17335)

This commit is contained in:
Jacob Richman
2026-01-22 12:54:23 -08:00
committed by GitHub
parent fda903587c
commit 6a78632873
10 changed files with 269 additions and 139 deletions
@@ -239,6 +239,7 @@ describe('RewindViewer', () => {
// Select
act(() => {
stdin.write('\x1b[A'); // Move up from 'Stay at current position'
stdin.write('\r');
});
expect(lastFrame()).toMatchSnapshot('confirmation-dialog');
@@ -280,6 +281,7 @@ describe('RewindViewer', () => {
// Select
act(() => {
stdin.write('\x1b[A'); // Move up from 'Stay at current position'
stdin.write('\r'); // Select
});
@@ -188,8 +188,10 @@ export const RewindViewer: React.FC<RewindViewerProps> = ({
<Box flexDirection="column" flexGrow={1}>
<BaseSelectionList
items={items}
initialIndex={items.length - 1}
isFocused={true}
showNumbers={false}
wrapAround={false}
onSelect={(item: MessageRecord) => {
const userPrompt = item;
if (userPrompt && userPrompt.id) {
@@ -5,10 +5,10 @@ exports[`RewindViewer > Content Filtering > 'removes reference markers' 1`] = `
│ │
│ > Rewind │
│ │
some command @file │
some command @file │
│ No files have been changed │
│ │
Stay at current position │
Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
@@ -22,10 +22,10 @@ exports[`RewindViewer > Content Filtering > 'strips expanded MCP resource conten
│ │
│ > Rewind │
│ │
read @server3:mcp://demo-resource hello │
read @server3:mcp://demo-resource hello │
│ No files have been changed │
│ │
Stay at current position │
Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
@@ -72,13 +72,13 @@ exports[`RewindViewer > Navigation > handles 'down' navigation > after-down 1`]
│ Q1 │
│ No files have been changed │
│ │
Q2 │
Q2 │
│ No files have been changed │
│ │
│ Q3 │
│ No files have been changed │
│ │
Stay at current position │
Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
@@ -98,30 +98,7 @@ exports[`RewindViewer > Navigation > handles 'up' navigation > after-up 1`] = `
│ Q2 │
│ No files have been changed │
│ │
Q3 │
│ No files have been changed │
│ │
│ ● Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
│ (Use Enter to select a message, Esc to close, Right/Left to expand/collapse) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
`;
exports[`RewindViewer > Navigation > handles cyclic navigation > cyclic-down 1`] = `
"╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ > Rewind │
│ │
│ ● Q1 │
│ No files have been changed │
│ │
│ Q2 │
│ No files have been changed │
│ │
│ Q3 │
Q3 │
│ No files have been changed │
│ │
│ Stay at current position │
@@ -133,7 +110,7 @@ exports[`RewindViewer > Navigation > handles cyclic navigation > cyclic-down 1`]
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
`;
exports[`RewindViewer > Navigation > handles cyclic navigation > cyclic-up 1`] = `
exports[`RewindViewer > Navigation > handles cyclic navigation > cyclic-down 1`] = `
"╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ > Rewind │
@@ -156,15 +133,38 @@ exports[`RewindViewer > Navigation > handles cyclic navigation > cyclic-up 1`] =
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
`;
exports[`RewindViewer > Navigation > handles cyclic navigation > cyclic-up 1`] = `
"╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ > Rewind │
│ │
│ Q1 │
│ No files have been changed │
│ │
│ Q2 │
│ No files have been changed │
│ │
│ ● Q3 │
│ No files have been changed │
│ │
│ Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
│ (Use Enter to select a message, Esc to close, Right/Left to expand/collapse) │
│ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯"
`;
exports[`RewindViewer > Rendering > renders 'a single interaction' 1`] = `
"╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ │
│ > Rewind │
│ │
Hello │
Hello │
│ No files have been changed │
│ │
Stay at current position │
Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
@@ -178,11 +178,11 @@ exports[`RewindViewer > Rendering > renders 'full text for selected item' 1`] =
│ │
│ > Rewind │
│ │
1 │
1 │
│ 2... │
│ No files have been changed │
│ │
Stay at current position │
Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
@@ -210,13 +210,13 @@ exports[`RewindViewer > updates content when conversation changes (background up
│ │
│ > Rewind │
│ │
Message 1 │
Message 1 │
│ No files have been changed │
│ │
│ Message 2 │
│ No files have been changed │
│ │
Stay at current position │
Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
@@ -230,10 +230,10 @@ exports[`RewindViewer > updates content when conversation changes (background up
│ │
│ > Rewind │
│ │
Message 1 │
Message 1 │
│ No files have been changed │
│ │
Stay at current position │
Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
@@ -251,11 +251,11 @@ exports[`RewindViewer > updates selection and expansion on navigation > after-do
│ Line B... │
│ No files have been changed │
│ │
Line 1 │
Line 1 │
│ Line 2... │
│ No files have been changed │
│ │
Stay at current position │
Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
@@ -269,7 +269,7 @@ exports[`RewindViewer > updates selection and expansion on navigation > initial-
│ │
│ > Rewind │
│ │
Line A │
Line A │
│ Line B... │
│ No files have been changed │
│ │
@@ -277,7 +277,7 @@ exports[`RewindViewer > updates selection and expansion on navigation > initial-
│ Line 2... │
│ No files have been changed │
│ │
Stay at current position │
Stay at current position │
│ Cancel rewind and stay here │
│ │
│ │
@@ -125,6 +125,7 @@ describe('BaseSelectionList', () => {
onHighlight: mockOnHighlight,
isFocused,
showNumbers,
wrapAround: true,
});
});
@@ -30,6 +30,7 @@ export interface BaseSelectionListProps<
showNumbers?: boolean;
showScrollArrows?: boolean;
maxItemsToShow?: number;
wrapAround?: boolean;
renderItem: (item: TItem, context: RenderItemContext) => React.ReactNode;
}
@@ -59,6 +60,7 @@ export function BaseSelectionList<
showNumbers = true,
showScrollArrows = false,
maxItemsToShow = 10,
wrapAround = true,
renderItem,
}: BaseSelectionListProps<T, TItem>): React.JSX.Element {
const { activeIndex } = useSelectionList({
@@ -68,6 +70,7 @@ export function BaseSelectionList<
onHighlight,
isFocused,
showNumbers,
wrapAround,
});
const [scrollOffset, setScrollOffset] = useState(0);