Skip to content

fix: comment module upload function issue fixed#4444

Merged
Ricbet merged 14 commits intomainfrom
fix/comment_update_file
Mar 18, 2025
Merged

fix: comment module upload function issue fixed#4444
Ricbet merged 14 commits intomainfrom
fix/comment_update_file

Conversation

@wangxiaojuan
Copy link
Copy Markdown
Contributor

@wangxiaojuan wangxiaojuan commented Mar 6, 2025

Types

  • 🎉 New Features
  • 🐛 Bug Fixes
  • 📚 Documentation Changes
  • 💄 Code Style Changes
  • 💄 Style Changes
  • 🪚 Refactors
  • 🚀 Performance Improvements
  • 🏗️ Build System
  • ⏱ Tests
  • 🧹 Chores
  • Other Changes

Background or solution

image

Changelog

feat: 评论支持复制粘贴图片

Summary by CodeRabbit

  • 新功能

    • 评论输入区现已支持直接粘贴文件,用户可以更便捷地通过粘贴方式上传文件,同时系统将自动聚焦文本区域。
  • 改进

    • 优化了评论线程的匹配逻辑,现在将基于文件路径展示相关评论,使评论显示更加准确。

@opensumi opensumi Bot added the 🐞 bug Something isn't working label Mar 6, 2025
@wangxiaojuan
Copy link
Copy Markdown
Contributor Author

/next

@opensumi
Copy link
Copy Markdown
Contributor

opensumi Bot commented Mar 6, 2025

🎉 PR Next publish successful!

3.8.1-next-1741251026.0

@wangxiaojuan wangxiaojuan requested review from Ricbet and hacke2 March 6, 2025 11:34
event.stopPropagation();
event.preventDefault();

const files = event.dataTransfer?.files; // FileList object.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

为啥把这个删了?我记得这个是支持文件拖拽的

@wangxiaojuan
Copy link
Copy Markdown
Contributor Author

/next

@opensumi opensumi Bot added the 🎨 feature feature required label Mar 6, 2025
@opensumi
Copy link
Copy Markdown
Contributor

opensumi Bot commented Mar 6, 2025

🎉 PR Next publish successful!

3.8.1-next-1741262660.0

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 6, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 53.13%. Comparing base (420eda0) to head (151aed4).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
packages/comments/src/browser/comments.service.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4444   +/-   ##
=======================================
  Coverage   53.13%   53.13%           
=======================================
  Files        1665     1665           
  Lines      102649   102649           
  Branches    22225    22217    -8     
=======================================
+ Hits        54538    54545    +7     
+ Misses      40025    40019    -6     
+ Partials     8086     8085    -1     
Flag Coverage Δ
jsdom 48.62% <0.00%> (+<0.01%) ⬆️
node 12.12% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread packages/comments/src/browser/comments-textarea.view.tsx Outdated
@wangxiaojuan wangxiaojuan requested review from erha19 and hacke2 March 10, 2025 07:53
@wangxiaojuan wangxiaojuan changed the base branch from v3.8 to main March 12, 2025 07:05
@wangxiaojuan
Copy link
Copy Markdown
Contributor Author

/next

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 12, 2025

Walkthrough

此次修改分别在评论文本区域组件和评论服务中进行了增强。在文本区域组件中,新增了 handleFilePaste 方法用于处理剪贴板粘贴文件事件,通过阻止默认行为和事件传播,实现了提取剪贴板中的文件并调用相应的回调。在评论服务中,调整了匹配评论线程的逻辑,从使用深度比较 URI 改为仅比较 codeUri.path 属性,从而改变了评论线程的匹配方式。

Changes

文件路径 更改概述
packages/comments/.../comments-textarea.view.tsx 新增 handleFilePaste 方法处理粘贴事件;为 MentionsInput 组件添加 onPaste 属性;新增对 ClipboardEvent 类型的引入。
packages/comments/.../comments.service.ts 修改 provideEditorDecoration 方法中比较评论线程 URI 的逻辑,从深度比较改为比较 codeUri.path

Sequence Diagram(s)

sequenceDiagram
    participant U as 用户
    participant M as MentionsInput
    participant T as CommentsTextArea
    participant D as dragFiles(可选)

    U->>M: 执行粘贴操作 (onPaste 事件)
    M->>T: 调用 handleFilePaste(event)
    T-->>T: 阻止默认粘贴行为与事件传播
    T->>T: 检查剪贴板数据是否包含文件
    alt 文件存在且 dragFiles 被提供
        T->>D: 调用 dragFiles(pasted files)
    end
    T->>T: 聚焦文本区域并更新光标位置
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
error Couldn't find any versions for "@opensumi/ide-dev-tool" that matches "workspace:*"
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1cbd37c and 570615f.

📒 Files selected for processing (2)
  • packages/comments/src/browser/comments-textarea.view.tsx (3 hunks)
  • packages/comments/src/browser/comments.service.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: 🚀🚀🚀 Next Version for pull request
  • GitHub Check: unittest (ubuntu-latest, 18.x, jsdom)
  • GitHub Check: unittest (ubuntu-latest, 18.x, node)
  • GitHub Check: build (ubuntu-latest, 20.x)
  • GitHub Check: build-windows
  • GitHub Check: ubuntu-latest, Node.js 20.x
🔇 Additional comments (4)
packages/comments/src/browser/comments.service.ts (1)

1024-1024:

Details

❓ Verification inconclusive

修改了评论线程匹配逻辑

将从使用 thread.uri.isEqual(uri) 完整比较 URI 改为只比较 codeUri.path 属性。这个修改可能是为了解决跨不同 URI 协议但路径相同的文件间的评论匹配问题。


🏁 Script executed:

#!/bin/bash
# 查找 URI 比较相关的代码,以确认此更改的合理性
rg "isEqual\(.*uri" --type typescript

Length of output: 74


请确认 isEqual 的使用情况
目前,由于先前的命令因指定文件类型出错而未能返回预期的结果,我们建议您使用上面的新脚本在整个代码库中搜索 isEqual( 的调用。请运行此脚本并确认以下几点:

  • 检查是否有其他地方仍在使用 isEqual 方法(例如完全比较 URI),从而确保此次修改(仅比较 codeUri.path)不会影响其他逻辑。
  • 核实 packages/comments/src/browser/comments.service.ts 中的更改是有意为之,以解决跨协议文件匹配问题,而不会引入新的潜在问题。

请手动验证新的输出结果后,再确认代码逻辑是否符合预期。


🏁 Script executed:

#!/bin/bash
# 在所有 *.ts 文件中搜索对 isEqual( 的调用,以确认该方法是否在其他地方仍有使用
rg "isEqual\(" --glob "*.ts"

Length of output: 13453


请核实跨协议文件评论匹配行为
此处将原先的 thread.uri.isEqual(uri) 修改为直接比较 codeUri.path 的变化,旨在解决不同 URI 协议下但路径一致的文件评论匹配问题。从代码库搜索结果来看,其它模块在需要完整匹配 URI 时仍一律使用 isEqual 方法,因此该修改看似只针对评论匹配场景的特殊需求。请开发者手动验证以下几点:

  • 确认该修改确实解决了跨协议文件匹配问题。
  • 检查此处更改不会引入其他潜在错误,即只比较 codeUri.path 能够满足业务需求(例如避免误匹配导致的评论显示问题)。
packages/comments/src/browser/comments-textarea.view.tsx (3)

13-13: 添加了 ClipboardEvent 类型导入

添加了 React 的 ClipboardEvent 类型导入,用于支持新增的粘贴事件处理。


50-67: 实现了粘贴图片功能

新增了 handleFilePaste 方法,用于处理剪贴板中的图片和文件粘贴事件。该方法与已有的拖拽文件功能类似,可以获取剪贴板中的文件并调用 dragFiles 方法处理。

实现合理,正确阻止了默认粘贴行为,并在处理完粘贴内容后重新聚焦文本框。


187-188: 为文本输入框添加粘贴事件处理

在 MentionsInput 组件上添加了 onPaste 属性,关联到新实现的 handleFilePaste 方法。这样用户既可以通过拖拽也可以通过复制粘贴向评论中添加图片。

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@opensumi
Copy link
Copy Markdown
Contributor

opensumi Bot commented Mar 12, 2025

🎉 PR Next publish successful!

3.8.3-next-1741763546.0

@wangxiaojuan
Copy link
Copy Markdown
Contributor Author

/next

@opensumi
Copy link
Copy Markdown
Contributor

opensumi Bot commented Mar 12, 2025

🎉 PR Next publish successful!

3.8.3-next-1741772268.0

@Ricbet Ricbet merged commit ee5c308 into main Mar 18, 2025
@Ricbet Ricbet deleted the fix/comment_update_file branch March 18, 2025 09:36
@erha19 erha19 mentioned this pull request May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working 🎨 feature feature required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants