Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): limit prompt recall to one history page per keypress #48260

OpenUtkarshUsername(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/48260/headopened View on GitHub

Showing 5 changed files with 67 additions and 22 deletions (loading 2).

x
0 of 5 viewed, 5 left
54 additions and 2 deletionsapps/web/src/components/chat/composerCommandKey.test.tsModified
View file
@@ -25,7 +25,7 @@
followUpBehavior: "queue",
isSoftwareKeyboardOpen: false,
isLiteralPendingAnswer: false,
- readPromptHistory: () => ({ entries: [], earlier: null }),
+ readPromptHistory: () => ({ entries: [], loadEarlier: null }),
canRecallPromptHistory: () => false,
pendingPromptHistoryRef: { current: null },
promptHistoryPositionRef: { current: null },
@@ -98,7 +98,7 @@
const onKey = composerCommandKeyHandler({
...input,
canRecallPromptHistory: () => true,
- readPromptHistory: () => ({ entries: [], earlier: { cursor: "older", load } }),
+ readPromptHistory: () => ({ entries: [], loadEarlier: load }),
promptHistoryPositionRef: {
current: {
targetKey: composerTargetKey(input.composerDraftTarget),
@@ -113,3 +113,55 @@
expect(load).not.toHaveBeenCalled();
expect(handled).toBe(false);
});
+​
+it("loads one history page per ArrowUp and continues from the new cursor on the next press", async () => {
+ const { input } = setup("", true);
+ const firstPage = Promise.withResolvers<void>();
+ const secondPage = Promise.withResolvers<void>();
+ const loadFirstPage = vi.fn(() => firstPage.promise);