Skip to content
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

[workspace] show rich difference info on save #17

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CNSeniorious000
Copy link
Member

@CNSeniorious000 CNSeniorious000 commented Jul 29, 2024

Summary by Sourcery

Enhance the workspace save functionality to provide rich difference information when saving files. Introduce a new diff function to compute text differences and update the Workspace.svelte component to display these differences in toast notifications. Adjust styling in CodeBlock.svelte and md.css for better text presentation.

New Features:

  • Introduce a new function to compute and return the differences between two text contents in the workspace module.

Enhancements:

  • Enhance the save functionality to return a formatted diff string if changes are detected, improving the feedback provided to users.
  • Update the Workspace.svelte component to display a rich diff in the toast notification when a file is saved and changes are detected.

@CNSeniorious000 CNSeniorious000 added the enhancement New feature or request label Jul 29, 2024
@CNSeniorious000 CNSeniorious000 self-assigned this Jul 29, 2024
@CNSeniorious000 CNSeniorious000 added this to the Ready to show milestone Jul 29, 2024
Copy link

codesandbox bot commented Jul 29, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

stackblitz bot commented Jul 29, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

render bot commented Jul 29, 2024

Copy link
Contributor

sourcery-ai bot commented Jul 29, 2024

Reviewer's Guide by Sourcery

This pull request enhances the workspace save functionality by introducing a new diff function to compute and display rich difference information when saving files. The changes improve the user experience by providing more detailed feedback on file modifications.

File-Level Changes

Change Details Files
Implemented a new diff function to compute differences between file contents
  • Created a new file diff.py with a diff function using difflib.ndiff
  • The diff function returns a string of differences, excluding unchanged lines
src/python/workspace/diff.py
Updated the save method in the workspace to use the new diff function and return formatted diff string
  • Imported the new diff function
  • Replaced the existing diff computation with the new diff function
  • Modified the save method to return a formatted diff string
src/python/workspace/__init__.py
Enhanced the UI to display detailed diff information in save notifications
  • Updated the save event handler to use the new diff return value
  • Modified the toast notification to include the diff information when changes are detected
  • Added a condition to show different messages for changed and unchanged files
src/routes/(workspace)/Workspace.svelte
Adjusted styling for code blocks and diff display
  • Modified the font size for code blocks in the CodeBlock component
  • Updated the CSS for code elements in the markdown prose
src/lib/components/CodeBlock.svelte
src/lib/md.css
Updated TypeScript definition for the workspace API
  • Modified the return type of the save method to include the possibility of returning a string
src/python/workspace/workspace.d.ts

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

netlify bot commented Jul 29, 2024

Deploy Preview for pyth-on-line ready!

Name Link
🔨 Latest commit d114c3d
🔍 Latest deploy log https://app.netlify.com/sites/pyth-on-line/deploys/66ab10f721b74b000853b6cc
😎 Deploy Preview https://deploy-preview-17--pyth-on-line.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98
Accessibility: 91
Best Practices: 100
SEO: 82
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @CNSeniorious000 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -3,5 +3,5 @@ import type { PyProxy } from "pyodide/ffi";
export class WorkspaceAPI extends PyProxy {
close(): void;
sync(sources: Record<string, string>, reload = true): void;
save(path: string, content: string, reload = true): void;
save(path: string, content: string, reload = true): string | void;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Clarify the return type of save method.

The save method now returns string | void. It would be helpful to document under what conditions each type is returned to avoid confusion.

Suggested change
save(path: string, content: string, reload = true): string | void;
/**
* Saves the content to the specified path.
*
* @param path - The path where the content should be saved.
* @param content - The content to save.
* @param reload - Whether to reload after saving. Defaults to true.
* @returns A string message if an error occurs, otherwise void.
*/
save(path: string, content: string, reload = true): string | void;

@CNSeniorious000 CNSeniorious000 changed the title basic implementation [workspace] show rich difference info on save Jul 29, 2024
@CNSeniorious000
Copy link
Member Author

These styles are broken:

image


image

@CNSeniorious000 CNSeniorious000 added the wontfix This will not be worked on label Sep 2, 2024
@CNSeniorious000 CNSeniorious000 removed their assignment Sep 2, 2024
@CNSeniorious000
Copy link
Member Author

@sourcery-ai review

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @CNSeniorious000 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Review instructions: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@CNSeniorious000 CNSeniorious000 marked this pull request as draft September 2, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant