Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/remember-initial-prompts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Remember initial session prompts when navigating chat input history with the arrow keys.
14 changes: 14 additions & 0 deletions packages/kilo-vscode/tests/unit/prompt-send-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ describe("PromptInput send origin contract", () => {
expect(source).toMatch(/session\.sendMessage\([\s\S]*origin \?\? null\)/)
expect(source).toMatch(/session\.sendCommand\([\s\S]*origin \?\? null\)/)
})

it("records sent prompts before a pending session key change can return", () => {
const start = source.indexOf("const handleSend = async () =>")
const end = source.indexOf("\n return (", start)
const body = source.slice(start, end)
const send = Math.max(body.indexOf("session.sendMessage("), body.indexOf("session.sendCommand("))
const append = body.lastIndexOf("history.append(draft)")
const guard = body.indexOf("if (draftKey() !== key) return")

expect(send).toBeGreaterThan(-1)
expect(append).toBeGreaterThan(send)
expect(append).toBeLessThan(guard)
expect(body.indexOf('setText("")', guard)).toBeGreaterThan(guard)
})
})

describe("SessionContext userClearedSession contract", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,9 +1119,9 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
reviewDrafts.delete(key)
imageDrafts.delete(key)
scrollDrafts.delete(key)
history.append(draft)
if (draftKey() !== key) return

history.append(draft)
history.reset()
setText("")
clearReviewComments()
Expand Down
Loading