-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add restore-to-message arrow on user messages #3596
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
azizmejri1
wants to merge
19
commits into
dyad-sh:main
Choose a base branch
from
azizmejri1:copy-restore-to-message
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 17 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
cea5387
Add restore-to-message arrow on user messages
azizmejri1 67a63d0
Address PR review comments
azizmejri1 dcd9ee5
Address PR review comments
azizmejri1 8a34188
Address PR review comments
azizmejri1 a2d716a
show restore buttonwhen chat is streaming
azizmejri1 c9875df
Update E2E snapshots for restore button
azizmejri1 ed67970
Address PR review comments
azizmejri1 6fcb1e1
Address PR review comments
azizmejri1 f23081e
Address PR review comments
azizmejri1 2534330
fix
azizmejri1 5e36428
Address PR review comments
azizmejri1 3b82faf
Address PR review comments
azizmejri1 4044717
Add fork-only restore option and allow restoring to first message
azizmejri1 97bdd6d
Revert unrelated package-lock.json change
azizmejri1 f3fdd56
Fix rebase conflict: drop duplicate DB/Supabase restore block
azizmejri1 30ec164
Address PR review comments
azizmejri1 ce8b8b0
Address PR review comments
azizmejri1 11bb576
Use current branch HEAD instead of hardcoded main for fork-only baseline
azizmejri1 f1bfc77
Address PR review comments
azizmejri1 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| import { testSkipIfWindows, Timeout } from "./helpers/test_helper"; | ||
| import { expect } from "@playwright/test"; | ||
| import fs from "node:fs"; | ||
| import path from "node:path"; | ||
|
|
||
| /** | ||
| * E2E test for the per-message "restore" arrow on user messages. | ||
| * | ||
| * Clicking the arrow on a user message should: | ||
| * 1. Create a NEW chat containing only the messages before that message | ||
| * (the original chat stays intact). | ||
| * 2. Restore the app's code to the version that existed right before that | ||
| * message was sent. | ||
| * 3. Navigate the user to the new chat. | ||
| */ | ||
| testSkipIfWindows( | ||
| "restore to message - forks chat and reverts code", | ||
| async ({ po }) => { | ||
| await po.setUp({ autoApprove: true }); | ||
| await po.importApp("minimal"); | ||
|
|
||
| const indexPath = async () => | ||
| path.join( | ||
| await po.appManagement.getCurrentAppPath(), | ||
| "src", | ||
| "pages", | ||
| "Index.tsx", | ||
| ); | ||
|
|
||
| // Turn A: writes src/pages/Index.tsx -> creates a version. | ||
| await po.sendPrompt("tc=write-index"); | ||
| expect(fs.readFileSync(await indexPath(), "utf-8")).toContain( | ||
| "Testing:write-index!", | ||
| ); | ||
|
|
||
| // Turn B: overwrites src/pages/Index.tsx -> creates a newer version. | ||
| await po.sendPrompt("tc=write-index-2"); | ||
| expect(fs.readFileSync(await indexPath(), "utf-8")).toContain( | ||
| "Testing:write-index(2)!", | ||
| ); | ||
|
|
||
| const originalChatId = po.page.url().match(/[?&]id=(\d+)/)?.[1]; | ||
| expect(originalChatId).toBeTruthy(); | ||
|
|
||
| // Importing the "minimal" fixture triggers an auto-generated AI_RULES.md | ||
| // user message, so the chat has three user messages total: AI_RULES, turn | ||
| // A, turn B. Each gets a restore button. | ||
| const restoreButtons = po.page.getByTestId("restore-to-message-button"); | ||
| await expect(restoreButtons).toHaveCount(3); | ||
|
|
||
| // Click the undo icon on the LAST user message (turn B), then confirm in | ||
| // the dialog. This should create a new chat with [AI_RULES, userA, | ||
| // assistantA] and revert the app to the state after turn A (i.e. before | ||
| // turn B). | ||
| await restoreButtons.nth(2).click(); | ||
| await po.page.getByTestId("confirm-restore-to-message-button").click(); | ||
|
|
||
| // We should navigate to a brand-new chat. | ||
| await expect(async () => { | ||
| const newChatId = po.page.url().match(/[?&]id=(\d+)/)?.[1]; | ||
| expect(newChatId).toBeTruthy(); | ||
| expect(newChatId).not.toBe(originalChatId); | ||
| }).toPass({ timeout: Timeout.LONG }); | ||
|
|
||
| // The new chat contains only the messages before turn B: the AI_RULES | ||
| // user message and turn A, so two restore buttons. | ||
| await expect(restoreButtons).toHaveCount(2); | ||
|
|
||
| const messagesList = po.page.getByTestId("messages-list"); | ||
| await expect(messagesList).toContainText("tc=write-index"); | ||
| await expect(messagesList).not.toContainText("tc=write-index-2"); | ||
|
|
||
| // The app code is reverted to the state right before turn B. | ||
| await expect(async () => { | ||
| const content = fs.readFileSync(await indexPath(), "utf-8"); | ||
| expect(content).toContain("Testing:write-index!"); | ||
| expect(content).not.toContain("Testing:write-index(2)!"); | ||
| }).toPass({ timeout: Timeout.LONG }); | ||
|
|
||
| // The original chat must be left intact: the confirmation dialog promises | ||
| // "Your current chat will not be changed". Navigate back to it and verify | ||
| // both turns are still present. | ||
| await po.page.getByRole("link", { name: "Apps" }).hover(); | ||
| await expect(po.page.getByTestId("chat-list-container")).toBeVisible({ | ||
| timeout: Timeout.MEDIUM, | ||
| }); | ||
| await po.page.getByTestId(`chat-list-item-${originalChatId}`).click(); | ||
| await expect(async () => { | ||
| const currentChatId = po.page.url().match(/[?&]id=(\d+)/)?.[1]; | ||
| expect(currentChatId).toBe(originalChatId); | ||
| }).toPass({ timeout: Timeout.MEDIUM }); | ||
| await expect(messagesList).toContainText("tc=write-index"); | ||
| await expect(messagesList).toContainText("tc=write-index-2"); | ||
| }, | ||
| ); | ||
|
|
||
| /** | ||
| * "Fork chat only" forks the conversation into a new chat but leaves the app's | ||
| * code untouched. | ||
| */ | ||
| testSkipIfWindows( | ||
| "restore to message - fork chat only leaves code untouched", | ||
| async ({ po }) => { | ||
| await po.setUp({ autoApprove: true }); | ||
| await po.importApp("minimal"); | ||
|
|
||
| const indexPath = async () => | ||
| path.join( | ||
| await po.appManagement.getCurrentAppPath(), | ||
| "src", | ||
| "pages", | ||
| "Index.tsx", | ||
| ); | ||
|
|
||
| await po.sendPrompt("tc=write-index"); | ||
| await po.sendPrompt("tc=write-index-2"); | ||
| expect(fs.readFileSync(await indexPath(), "utf-8")).toContain( | ||
| "Testing:write-index(2)!", | ||
| ); | ||
|
|
||
| const originalChatId = po.page.url().match(/[?&]id=(\d+)/)?.[1]; | ||
| expect(originalChatId).toBeTruthy(); | ||
|
|
||
| const restoreButtons = po.page.getByTestId("restore-to-message-button"); | ||
| await expect(restoreButtons).toHaveCount(3); | ||
|
|
||
| // Open the dialog on the last user message (turn B) and choose to only fork | ||
| // the chat. | ||
| await restoreButtons.nth(2).click(); | ||
| await po.page.getByTestId("fork-chat-button").click(); | ||
|
|
||
| // We should navigate to a brand-new chat with only the messages before | ||
| // turn B. | ||
| await expect(async () => { | ||
| const newChatId = po.page.url().match(/[?&]id=(\d+)/)?.[1]; | ||
| expect(newChatId).toBeTruthy(); | ||
| expect(newChatId).not.toBe(originalChatId); | ||
| }).toPass({ timeout: Timeout.LONG }); | ||
| await expect(restoreButtons).toHaveCount(2); | ||
|
|
||
| const messagesList = po.page.getByTestId("messages-list"); | ||
| await expect(messagesList).toContainText("tc=write-index"); | ||
| await expect(messagesList).not.toContainText("tc=write-index-2"); | ||
|
|
||
| // The app code must NOT be reverted: forking only touches the chat. | ||
| expect(fs.readFileSync(await indexPath(), "utf-8")).toContain( | ||
| "Testing:write-index(2)!", | ||
| ); | ||
| }, | ||
| ); | ||
|
|
||
| /** | ||
| * Restoring to the very first message is allowed: it restores to "version 1" | ||
| * (the commit before the first message's changes) and forks a new, empty chat. | ||
| */ | ||
| testSkipIfWindows( | ||
| "restore to message - first message forks an empty chat", | ||
| async ({ po }) => { | ||
| await po.setUp({ autoApprove: true }); | ||
| await po.importApp("minimal"); | ||
|
|
||
| await po.sendPrompt("tc=write-index"); | ||
|
|
||
| const originalChatId = po.page.url().match(/[?&]id=(\d+)/)?.[1]; | ||
| expect(originalChatId).toBeTruthy(); | ||
|
|
||
| // The imported "minimal" fixture adds an auto-generated AI_RULES.md user | ||
| // message followed by turn A, so there are two restore buttons. | ||
| const restoreButtons = po.page.getByTestId("restore-to-message-button"); | ||
| await expect(restoreButtons).toHaveCount(2); | ||
|
|
||
| // Restore to the FIRST user message. Previously this failed with "Cannot | ||
| // restore before the first message"; now it forks an empty chat. | ||
| await restoreButtons.nth(0).click(); | ||
| await po.page.getByTestId("confirm-restore-to-message-button").click(); | ||
|
|
||
| // We navigate to a brand-new chat with no prior messages, so no restore | ||
| // buttons are shown. | ||
| await expect(async () => { | ||
| const newChatId = po.page.url().match(/[?&]id=(\d+)/)?.[1]; | ||
| expect(newChatId).toBeTruthy(); | ||
| expect(newChatId).not.toBe(originalChatId); | ||
| }).toPass({ timeout: Timeout.LONG }); | ||
| await expect(restoreButtons).toHaveCount(0); | ||
| }, | ||
| ); | ||
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/approve.spec.ts_write-to-index-approve-check-preview-1.aria.yml
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
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/approve.spec.ts_write-to-index-approve-check-preview-2.aria.yml
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
2 changes: 2 additions & 0 deletions
2
e2e-tests/snapshots/attach_image.spec.ts_attach-image---chat---upload-to-codebase-1.aria.yml
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
2 changes: 2 additions & 0 deletions
2
e2e-tests/snapshots/attach_image.spec.ts_attach-image---chat-1.aria.yml
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
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/attach_image.spec.ts_attach-image---home-chat-1.aria.yml
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
2 changes: 2 additions & 0 deletions
2
e2e-tests/snapshots/attach_image.spec.ts_attach-image-via-drag---chat-1.aria.yml
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
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/auto_approve.spec.ts_auto-approve-1.aria.yml
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
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/azure_send_message.spec.ts_send-message-through-Azure-OpenAI-1.aria.yml
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
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/concurrent_chat.spec.ts_concurrent-chat-1.aria.yml
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| - button "Restore to this point" | ||
| - paragraph: tc=chat2 | ||
| - paragraph: chat2 | ||
| - button "Copy" | ||
|
|
||
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/concurrent_chat.spec.ts_concurrent-chat-2.aria.yml
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 |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| - button "Restore to this point" | ||
| - paragraph: tc=chat1 [sleep=medium] |
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/engine.spec.ts_regular-auto-should-send-message-to-engine-1.aria.yml
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
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/engine.spec.ts_send-message-to-engine-1.aria.yml
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
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/engine.spec.ts_smart-auto-should-send-message-to-engine-1.aria.yml
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
2 changes: 2 additions & 0 deletions
2
e2e-tests/snapshots/fix_error.spec.ts_fix-error-with-AI-3.aria.yml
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
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/import.spec.ts_import-app-with-AI-rules-2.aria.yml
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| - button "Restore to this point" | ||
| - paragraph: "[dump]" | ||
| - paragraph: "[[dyad-dump-path=*]]" | ||
| - button "Copy" | ||
|
|
||
1 change: 1 addition & 0 deletions
1
e2e-tests/snapshots/lm_studio.spec.ts_send-message-to-LM-studio-1.aria.yml
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| - button "Restore to this point" | ||
| - paragraph: hi | ||
| - button "file1.txt file1.txt Edit" | ||
| - paragraph: More EOM | ||
|
|
||
2 changes: 2 additions & 0 deletions
2
...cal_agent_connection_retry.spec.ts_local-agent---recovers-from-connection-drop-1.aria.yml
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
1 change: 1 addition & 0 deletions
1
...apshots/local_agent_explore_code.spec.ts_local-agent---explore-code-experiment-1.aria.yml
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
2 changes: 2 additions & 0 deletions
2
...napshots/local_agent_file_upload.spec.ts_local-agent---upload-file-to-codebase-1.aria.yml
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
2 changes: 2 additions & 0 deletions
2
...ests/snapshots/local_agent_generate_image.spec.ts_local-agent---generate-image-1.aria.yml
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
3 changes: 3 additions & 0 deletions
3
...cal_agent_persistent_todos.spec.ts_local-agent---persistent-todos-across-turns-1.aria.yml
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
1 change: 1 addition & 0 deletions
1
...pshots/local_agent_summarize.spec.ts_local-agent---summarize-to-new-chat-works-1.aria.yml
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
2 changes: 2 additions & 0 deletions
2
.../snapshots/local_agent_todo_followup.spec.ts_local-agent---todo-follow-up-loop-1.aria.yml
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
2 changes: 2 additions & 0 deletions
2
e2e-tests/snapshots/local_agent_web_fetch.spec.ts_local-agent---web-fetch-1.aria.yml
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
Oops, something went wrong.
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.