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

Code Diff Viewer, version switching on Autograder Output #2093

Merged
merged 13 commits into from
Feb 28, 2024
Merged

Conversation

damianhxy
Copy link
Member

@damianhxy damianhxy commented Feb 17, 2024

Description

  • Add a code diff viewer tab to golden layout
  • All submissions now display an "Autograder Output" file for uniformity
  • Added version switching for Autograder Output
  • "Run Autograder" button added when autograder defined and viewing autograding output
  • Fix check for detecting if announcements exist
  • Tweak heights to ensure that speedgrader is usable with and without announcements
  • Remove dead bootstrap tooltip code
  • Add titles to access code buttons
  • Refactor submissions controller

Motivation and Context

Closes #2090
Closes #1743

How Has This Been Tested?

Version switching on autograder output

Now able to switch between versions when viewing autograder output. Will always go to the immediate next / previous version, with a message if the output does not exist.

Output exists (and autograder exists)
Screenshot 2024-02-17 at 17 04 28
Note the "Run Autograder" button

Output does not exist, autograder exists
Screenshot 2024-02-17 at 17 04 36
Note the message, and the "Run Autograder" button

Output does not exist, autograder does not exist
Screenshot 2024-02-17 at 17 04 49
Note the message, and NO "Run Autograder" button

Code Diff Viewer

Text file - changes exist
Screenshot 2024-02-18 at 00 57 37

Text file - no changes
Screenshot 2024-02-18 at 00 57 40

Version 1 of a file
Screenshot 2024-02-18 at 00 57 08

Other error, e.g. viewing a PDF or Binary file
Screenshot 2024-02-18 at 00 57 23

Autograder Output
Screenshot 2024-02-18 at 00 58 32

Large files
Screenshot 2024-02-18 at 00 56 55

Height tweaks

  • In normal use, there is no longer any extraneous scrollbar at the side. Content of all panels (e.g. code viewer, diff viewer) are fully accessible through scrolling if necessary.
  • In the presence of announcements, the speedgrader is made "shorter" accordingly, but all content is still accessible through scrolling if necessary.

Before (CMU prod)
Screenshot 2024-02-18 at 01 00 52

After
Screenshot 2024-02-18 at 01 00 57

With announcements
Screenshot 2024-02-18 at 01 02 24

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run rubocop and erblint for style check. If you haven't, run overcommit --install && overcommit --sign to use pre-commit hook for linting
  • My change requires a change to the documentation, which is located at Autolab Docs
  • I have updated the documentation accordingly, included in this PR

Allow version switching on autograder output
@damianhxy damianhxy changed the title Add Diff Viewer Code Diff Viewer, version switching on Autograder Output Feb 17, 2024
@damianhxy damianhxy marked this pull request as ready for review February 18, 2024 06:08
Copy link
Contributor

coderabbitai bot commented Feb 18, 2024

Walkthrough

Walkthrough

The recent updates introduce a diff viewer for comparing submission versions and enhance autograding output versioning. Cosmetic changes improve code readability and UI adjustments for better user experience. The integration of the diffy gem and diff2html library powers the diff viewer functionality, while controller and view updates support version switching and better file handling for submissions.

Changes

Files Change Summary
Gemfile, .../application_helper.rb, .../submissions/view.html.erb Added diffy gem and diff2html library for diff viewing capabilities.
.../javascripts/annotations.js, .../javascripts/diff_viewer.js, .../javascripts/app-level.js, .../submissions/_annotations_js.html.erb, .../submissions/view.js.erb Enhanced and introduced JavaScript logic for diff viewer and UI adjustments.
.../stylesheets/annotations.scss, .../submissions/_diff_viewer.html.erb Styling adjustments for diff viewer and elements' heights.
app/controllers/submissions_controller.rb Updated file handling and version navigation for submissions.
app/views/... excluding .../submissions/_diff_viewer.html.erb and .../submissions/view.html.erb Minor UI and functionality changes, including tooltip adjustments and condition refinements.
.../submissions/_golden-layout.html.erb Introduced "diff_viewer" component in the layout.

Assessment against linked issues

Objective Addressed Explanation
Allow version switching on autograding output (#2090)
Ability to view differences between 2 submissions side-by-side (#1743)

The code changes effectively address the objectives laid out in the linked issues. The addition of a diff viewer for submission versions aligns with the requirements of issue #1743, providing a side-by-side comparison feature. Similarly, the updates to the submissions controller and related views support version switching for autograding output, meeting the needs of issue #2090.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@gitstream-cm gitstream-cm bot requested review from a team and KesterTan and removed request for a team February 18, 2024 06:09
@gitstream-cm gitstream-cm bot added large Pull request is large waiting-for-review labels Feb 18, 2024
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@KesterTan
Copy link
Contributor

KesterTan commented Feb 24, 2024

I think it would be better if the whole line is new, to just remove the highlighting and have the line highlighted light green.

For eg, in this case, maybe just the light green highlight without the dark green.

Screenshot 2024-02-24 at 2 58 25 AM

Actually, maybe something like, if there are more than a percentage difference between two functions, just use light highlighting to show the entire function as a difference (if that makes sense).

Not sure if this is possible or not, but I think you can specify configurations of lines/words and the maximum number of configurations so that might fix this.

@KesterTan
Copy link
Contributor

Also, I am a little confused about the selective strong highlighting. If these are 2 extremely different files so shouldn't everything be light green?

Screenshot 2024-02-24 at 3 00 23 AM

@KesterTan
Copy link
Contributor

Personally prefer non-synchronized scrolling on both files, especially if file sizes are pretty different.

@damianhxy
Copy link
Member Author

I think it would be better if the whole line is new, to just remove the highlighting and have the line highlighted light green.

Seems to be a limitation of the library, as I don't see a way to specify a "line similarity score threshold".

In general, there is no semantic info associated with a diff, so the library can and will match stuff like whitespace, brackets, and parenthesis.

Personally prefer non-synchronized scrolling on both files, especially if file sizes are pretty different.

Discussed offline as a won't change, since it would make comparisons more tedious in general and doesn't really bring any benefit.

Copy link
Contributor

@KesterTan KesterTan left a comment

Choose a reason for hiding this comment

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

LGTM

@damianhxy damianhxy added this pull request to the merge queue Feb 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 28, 2024
@damianhxy damianhxy added this pull request to the merge queue Feb 28, 2024
Merged via the queue into master with commit 7bb5fef Feb 28, 2024
5 checks passed
@damianhxy damianhxy deleted the diff-viewer branch February 28, 2024 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
large Pull request is large waiting-for-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow version switching on autograding output Submission version diff viewer
2 participants