diffx-finish-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Finish diffx Review

完成diffx评审

Fetch all review comments from the running diffx server, apply the requested changes, and mark each comment as resolved.
从运行中的diffx服务器拉取所有评审评论,应用所要求的变更,并将每条评论标记为已解决。

What to do

操作步骤

1. Fetch comments from the API

1. 从API拉取评论

The diffx server is running locally. Check the earlier conversation context for the port diffx reported on startup. Fetch all comments:
bash
curl -s http://localhost:<port>/api/comments
Replace
<port>
with the port number diffx reported on startup (visible in the server log output).
The response is a JSON array of comment objects:
json
[
  {
    "id": "uuid",
    "filePath": "src/utils/parser.ts",
    "side": "additions",
    "lineNumber": 42,
    "lineContent": "const x = tokenize(input)",
    "body": "Rename x to parsedToken for clarity",
    "status": "open",
    "createdAt": 1234567890,
    "replies": []
  }
]
diffx服务器运行在本地。查看之前的对话上下文获取diffx启动时上报的端口。拉取所有评论:
bash
curl -s http://localhost:<port>/api/comments
<port>
替换为diffx启动时上报的端口号(可在服务器日志输出中查看)。
返回结果是由评论对象组成的JSON数组:
json
[
  {
    "id": "uuid",
    "filePath": "src/utils/parser.ts",
    "side": "additions",
    "lineNumber": 42,
    "lineContent": "const x = tokenize(input)",
    "body": "Rename x to parsedToken for clarity",
    "status": "open",
    "createdAt": 1234567890,
    "replies": []
  }
]

2. Process each comment

2. 处理每条评论

For each comment with
"status": "open"
, first determine the intent — is it a change request or a question?
对于每条
"status": "open"
的评论,首先判断其意图——是变更请求还是问题咨询

Change requests (e.g., "Rename x to parsedToken", "Extract this into a helper")

变更请求(例如:"Rename x to parsedToken"、"Extract this into a helper")

  1. Read the file at
    filePath
  2. Find the relevant code using
    lineContent
    as context
  3. Apply the change described in
    body
  4. Reply to the comment explaining what you did, then mark it as resolved:
bash
undefined
  1. 读取
    filePath
    对应路径的文件
  2. lineContent
    为上下文找到相关代码
  3. 应用
    body
    中描述的变更
  4. 回复评论说明你做了什么,然后将其标记为已解决:
bash
undefined

Reply to the comment

Reply to the comment

curl -s -X POST http://localhost:<port>/api/comments/<id>/replies
-H "Content-Type: application/json"
-d '{"body": "Done. Renamed x to parsedToken."}'
curl -s -X POST http://localhost:<port>/api/comments/<id>/replies
-H "Content-Type: application/json"
-d '{"body": "Done. Renamed x to parsedToken."}'

Mark as resolved

Mark as resolved

curl -s -X PUT http://localhost:<port>/api/comments/<id>
-H "Content-Type: application/json"
-d '{"status": "resolved"}'
undefined
curl -s -X PUT http://localhost:<port>/api/comments/<id>
-H "Content-Type: application/json"
-d '{"status": "resolved"}'
undefined

Questions (e.g., "Why not use a Map here?", "Is this thread-safe?")

问题咨询(例如:"Why not use a Map here?"、"Is this thread-safe?")

Just reply with an answer. Do not modify code or resolve the comment — leave it open for the user to read and follow up if needed.
bash
curl -s -X POST http://localhost:<port>/api/comments/<id>/replies \
  -H "Content-Type: application/json" \
  -d '{"body": "A Map would work too, but we use a plain object here because..."}'
The
side
field tells you whether the comment is on an added line (
additions
) or a deleted line (
deletions
).
直接回复答案即可。不要修改代码或将评论标记为已解决——保持其开放状态,方便用户阅读并在需要时跟进。
bash
curl -s -X POST http://localhost:<port>/api/comments/<id>/replies \
  -H "Content-Type: application/json" \
  -d '{"body": "A Map would work too, but we use a plain object here because..."}'
side
字段会告知你该评论是针对新增行(
additions
)还是删除行(
deletions
)的。

3. Handle edge cases

3. 处理边界情况

  • If a comment is ambiguous, reply to ask for clarification rather than guessing.
  • If multiple comments interact (e.g., a rename that affects several places), handle them together.
  • If there are no open comments, tell the user there's nothing to process.
  • 如果评论表述模糊,请回复请求澄清,而不是自行猜测。
  • 如果多条评论存在关联(例如一次重命名会影响多处代码),请一并处理。
  • 如果没有未解决的评论,请告知用户没有需要处理的内容。

4. Summary

4. 总结

After processing all comments, give a brief summary of what you did: how many changes were applied, how many questions were answered.
处理完所有评论后,简要总结你所做的操作:应用了多少处变更,回答了多少个问题。