Repository navigation
feat(app): copy full file contents from review #59785
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
lancy69
wants to merge
4
commits into
anomalyco:dev
Choose a base branch
from
lancy69:review-copy-content
base: dev
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.
+226
−13
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
16 changes: 16 additions & 0 deletions
16
packages/session-ui/component-tests/session-review-copy.spec.ts
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,16 @@ | ||
| import { expect, story } from "../../stories/playwright/story" | ||
|
|
||
| for (const empty of [false, true]) { | ||
| story( | ||
| `copies ${empty ? "an empty snapshot without a disk reader" : "the reviewed snapshot instead of later disk edits"}`, | ||
| async ({ mount, page, context }) => { | ||
| await context.grantPermissions(["clipboard-read", "clipboard-write"]) | ||
| const root = await mount("review-file-preview-v2--copy-snapshot", { args: { empty, reader: !empty } }) | ||
| await page.evaluate(() => navigator.clipboard.writeText("previous clipboard")) | ||
| await root.getByRole("button", { name: "Copy file contents", exact: true }).click() | ||
| await expect | ||
| .poll(() => page.evaluate(() => navigator.clipboard.readText())) | ||
| .toBe(empty ? "" : "export const value = 'reviewed'\n// unchanged beyond the edit\n") | ||
| }, | ||
| ) | ||
| } |
31 changes: 31 additions & 0 deletions
31
packages/session-ui/src/v2/components/session-review-file-preview-v2.stories.tsx
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,31 @@ | ||
| import { CurrentSessionProviders } from "../../storybook/current-session-story" | ||
| import { editThenTestDocument } from "../../storybook/current-session-fixtures" | ||
| import { SessionReviewFilePreviewV2 } from "./session-review-file-preview-v2" | ||
|
|
||
| export default { | ||
| title: "OpenCode/Review/File preview", | ||
| id: "review-file-preview-v2", | ||
| } | ||
|
|
||
| export const CopySnapshot = { | ||
| args: { empty: false, reader: true }, | ||
| render: (args: { empty: boolean; reader: boolean }) => ( | ||
| <CurrentSessionProviders document={editThenTestDocument}> | ||
| <div data-component="session-review-v2" style={{ height: "400px" }}> | ||
| <SessionReviewFilePreviewV2 | ||
| file="example.ts" | ||
| diff={{ | ||
| file: "example.ts", | ||
| before: "export const value = 'before'\n", | ||
| after: args.empty ? "" : "export const value = 'reviewed'\n// unchanged beyond the edit\n", | ||
| additions: args.empty ? 0 : 2, | ||
| deletions: 1, | ||
| status: "modified", | ||
| }} | ||
| diffStyle="unified" | ||
| readFile={args.reader ? async () => ({ type: "text", content: "later disk contents\n" }) : undefined} | ||
| /> | ||
| </div> | ||
| </CurrentSessionProviders> | ||
| ), | ||
| } |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This README covers building and testing the app, not individual UI features, and nothing else documents single buttons here. The behaviour is already described in the code and the tests, so this section can be dropped to keep the change focused.