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

Support Notebook comments on Markup cells #214332

Closed
rehmsen opened this issue Jun 5, 2024 · 6 comments · Fixed by #219657
Closed

Support Notebook comments on Markup cells #214332

rehmsen opened this issue Jun 5, 2024 · 6 comments · Fixed by #219657
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders notebook-commenting Commenting support for notebooks verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@rehmsen
Copy link
Contributor

rehmsen commented Jun 5, 2024

I would like code review comments in notebooks to also work on non-code cells. Currently the code explicitly filters to only code cells, I am not sure why:

override didRenderCell(element: ICellViewModel): void {
if (element.cellKind === CellKind.Code) {
this.currentElement = element as CodeCellViewModel;
this.initialize(element);
this._bindListeners();
}
}

Is there a reason why comments on markup cells should be hidden, or would you accept a PR to add support for comments on Markup Cells?

@alexr00

@rebornix
Copy link
Member

rebornix commented Jun 5, 2024

@rehmsen that was a pretty early exploration and we don't have support for the notebook commenting officially. With that said, I'm good with PRs for enabling it for Markup cell.

@rebornix rebornix added feature-request Request for new features or functionality notebook-commenting Commenting support for notebooks labels Jun 13, 2024
@VSCodeTriageBot VSCodeTriageBot added this to the Backlog Candidates milestone Jun 13, 2024
@VSCodeTriageBot
Copy link
Collaborator

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@rehmsen
Copy link
Contributor Author

rehmsen commented Jun 26, 2024

I took a look at this today and wanted to propose a rough plan for how to implement this:

  1. Add a new property commentOffset to the CodeCellLayoutInfo, so that cellComments does not need to know that the comments should go below the outputs - that computation would move into CodeCellViewModel.layoutChange. This is the first step to making cellComments.ts agnostic of the type of cell.
  2. Extract shared interfaces CellLayoutInfo and CellLayoutChangeEvent from CodeCellLayoutInfo/MarkupCellLayoutInfo and CodeCellLayoutChangeEvent/MarkupCellLayoutChangeEvent. They already share a bunch of fields, and actually putting them into a parent interface means that cellComments.ts can read and write the relevant fields (commentHeight and commentOffset) without needing to distinguish between Code and Markup cells.
  3. (Optional) share some of the logic of how these shared layout values are computed. That is not strictly necessary and in the case of offsets might not be possible because they depend on which UI elements are above them pushing them down. But those things that are the same could benefit from some deduping. That code could live in BaseCellViewModel.
  4. Make MarkupCellViewModel compute commentOffset based on its view hierarchy.
  5. Make cellComments use the commentHeight setter and the cellOffset getter from the ICellViewModel instead of casting to CodeCellViewModel.

@alexr00 @rebornix Please let me know if that sounds good to you.

rehmsen added a commit to rehmsen/vscode that referenced this issue Jul 2, 2024
…layouting function.

microsoft#214332.

The cellComments should not have to know about outputs. The reason this is undesirable is that these exist only for code cells, not for markup cells - and I would like to make cellComments work for markup cells as well.
rehmsen added a commit to rehmsen/vscode that referenced this issue Jul 2, 2024
…llLayoutInfo.

microsoft#214332.

Some layouting tasks, like soon layouting comments, should not have to deal with this distinction. I am extracting the fields that are already shared into an interface that other code can use without differentiating.

I am not yet actually moving their computation into a separate file, as that will require some small behavior changes.
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 3, 2024
aaronchucarroll pushed a commit to aaronchucarroll/vscode that referenced this issue Jul 10, 2024
…layouting function.

microsoft#214332.

The cellComments should not have to know about outputs. The reason this is undesirable is that these exist only for code cells, not for markup cells - and I would like to make cellComments work for markup cells as well.
aaronchucarroll pushed a commit to aaronchucarroll/vscode that referenced this issue Jul 10, 2024
…llLayoutInfo.

microsoft#214332.

Some layouting tasks, like soon layouting comments, should not have to deal with this distinction. I am extracting the fields that are already shared into an interface that other code can use without differentiating.

I am not yet actually moving their computation into a separate file, as that will require some small behavior changes.
aaronchucarroll pushed a commit to aaronchucarroll/vscode that referenced this issue Jul 10, 2024
@rzhao271 rzhao271 added verification-needed Verification of issue is requested verified Verification succeeded verification-steps-needed Steps to verify are needed for verification and removed verified Verification succeeded labels Jul 25, 2024
@rzhao271
Copy link
Contributor

@rehmsen could I get some verification steps for this feature request?
I haven't been able to find a way to add comments to a notebook.
The diff editor is also editable on the right side, which seems off to me.
 
Notebook PR diff view

@rehmsen
Copy link
Contributor Author

rehmsen commented Jul 26, 2024

@rebornix Can you help?

I also do not know how to add a code review comment for a notebook via the UI. We have a closed source extension which registers a comment provider that creates notebook comments, and I verified that those work on Markdown cells with the fix.

Open source I know that the Github Pull Requests extension provides Github comments, but those are always left on the raw file, not on notebook cells, see #214017 - I have suggested some ideas how one might fix that, but we have not reached agreement yet.

I there some other way to create a notebook comment @rebornix? I guess you had some way to verify this when you build the original comment support?

Regarding the diff editor, editing the right side is expected I think - the left side should not be editable. Is it? Is that caused by my change somehow? I tried to repro, but when I run ./scripts/code-web.sh, I cannot install any notebook extension (like jupyter) in the first place.

@rzhao271
Copy link
Contributor

rzhao271 commented Jul 26, 2024

Marking this issue as verified considering the fix works for you.

Also, the left side of the diff editor is not modifiable. I'll check whether the diff editor is modifiable on the right side on Stable.

Edit: I have confirmed that the diff editor has not regressed.

@rzhao271 rzhao271 removed the verification-steps-needed Steps to verify are needed for verification label Jul 26, 2024
@rzhao271 rzhao271 added the verified Verification succeeded label Jul 26, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Aug 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders notebook-commenting Commenting support for notebooks verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants