Repository navigation
fix(task): don't lose chat box input when resuming a task with Continue #1901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nh2
wants to merge
1
commit into
Zoo-Code-Org:main
Choose a base branch
from
nh2:issue-487-fix-continue-losing-input-text
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2217,6 +2217,83 @@ describe("Task persistence", () => { | |
| }) | ||
|
|
||
| describe("resumeTaskFromHistory", () => { | ||
| const userMessageBlock = { type: "text", text: "<user_message>\nAlso fix the tests\n</user_message>" } | ||
| const imageBlock = { type: "image", source: { type: "base64", media_type: "image/png", data: "AAA" } } | ||
|
|
||
| it.each([ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a text-only Continue case so removing the independent
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @taltas Fair point, done |
||
| { | ||
| name: "text and image via Continue", | ||
| response: "yesButtonClicked" as const, | ||
| text: "Also fix the tests", | ||
| images: ["data:image/png;base64,AAA"], | ||
| expected: [userMessageBlock, imageBlock], | ||
| }, | ||
| { | ||
| name: "image only via Continue", | ||
| response: "yesButtonClicked" as const, | ||
| text: "", | ||
| images: ["data:image/png;base64,AAA"], | ||
| expected: [imageBlock], | ||
| }, | ||
| { | ||
| name: "text and image via Send", | ||
| response: "messageResponse" as const, | ||
| text: "Also fix the tests", | ||
| images: ["data:image/png;base64,AAA"], | ||
| expected: [userMessageBlock, imageBlock], | ||
| }, | ||
| ])("forwards chat box input ($name) to the resumed task", async ({ response, text, images, expected }) => { | ||
| mockReadApiMessages.mockResolvedValue([{ role: "assistant", content: [{ type: "text", text: "Working" }] }]) | ||
| const task = new Task({ | ||
| provider: mockProvider, | ||
| apiConfiguration: mockApiConfig, | ||
| historyItem: { | ||
| id: "resume-with-input", | ||
| number: 1, | ||
| ts: Date.now(), | ||
| task: "Original task", | ||
| tokensIn: 10, | ||
| tokensOut: 5, | ||
| totalCost: 0.001, | ||
| }, | ||
| startTask: false, | ||
| }) | ||
| vi.spyOn(task, "ask").mockResolvedValue({ response, text, images }) | ||
| const say = vi.spyOn(task, "say").mockResolvedValue(undefined) | ||
| const initiate = vi.spyOn(getTaskPersistenceAccess(task), "initiateTaskLoop").mockResolvedValue(undefined) | ||
|
|
||
| await getTaskPersistenceAccess(task).resumeTaskFromHistory() | ||
|
|
||
| expect(say).toHaveBeenCalledWith("user_feedback", text, images) | ||
| expect(initiate).toHaveBeenCalledWith(expected) | ||
| }) | ||
|
|
||
| it("resumes without user feedback when Continue is clicked with an empty chat box", async () => { | ||
| mockReadApiMessages.mockResolvedValue([{ role: "assistant", content: [{ type: "text", text: "Working" }] }]) | ||
| const task = new Task({ | ||
| provider: mockProvider, | ||
| apiConfiguration: mockApiConfig, | ||
| historyItem: { | ||
| id: "resume-without-input", | ||
| number: 1, | ||
| ts: Date.now(), | ||
| task: "Original task", | ||
| tokensIn: 10, | ||
| tokensOut: 5, | ||
| totalCost: 0.001, | ||
| }, | ||
| startTask: false, | ||
| }) | ||
| vi.spyOn(task, "ask").mockResolvedValue({ response: "yesButtonClicked" }) | ||
| const say = vi.spyOn(task, "say").mockResolvedValue(undefined) | ||
| const initiate = vi.spyOn(getTaskPersistenceAccess(task), "initiateTaskLoop").mockResolvedValue(undefined) | ||
|
|
||
| await getTaskPersistenceAccess(task).resumeTaskFromHistory() | ||
|
|
||
| expect(say.mock.calls.filter(([type]) => type === "user_feedback")).toEqual([]) | ||
| expect(initiate).toHaveBeenCalledWith([{ type: "text", text: "[TASK RESUMPTION] Resuming task..." }]) | ||
| }) | ||
|
|
||
| it.each(["not_found", "invalid", "io_error"] as const)( | ||
| "does not persist when hydration fails with %s", | ||
| async (kind) => { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.