Skip to content

Support editing comments and replies on the frontend - #247

Merged
ruibaby merged 5 commits into
mainfrom
feat/edit-comment-content
Sep 24, 2026
Merged

ruibaby merged 5 commits into
mainfrom
feat/edit-comment-content

Conversation

@ruibaby

@ruibaby ruibaby commented Sep 14, 2026

Copy link
Copy Markdown
Member

Port the comment content editing capability from Halo Console (halo-dev/halo#10302) to the comment widget, so users with comment management permission can edit comment and reply bodies directly on the frontend.

  • Add an "Edit" entry to the per-comment/reply management dropdown, shown only to users with the system:comments:manage permission and hidden for deleted targets
  • Open an inline editor in place of the content, reusing the widget's rich text editor; the latest body and resource version are loaded when the editor opens
  • Save through the new PUT /apis/api.console.halo.run/v1alpha1/{comments|replies}/{name}/content endpoints with raw, content, and the loaded version, preserving moderation state and authorship
  • Match Console error handling: a 409 conflict (stale version) keeps the draft and asks the user to reopen the editor; load failures and already-deleted targets show inline messages
  • Disable image upload while editing, because the widget's upload tickets bind to comment creation and the content endpoint does not accept upload bindings; existing images remain editable
  • Fix the editor focus ring being clipped on three sides in editing state by disabling content-visibility: auto paint containment on the item content container while editing

Requires a Halo version that includes halo-dev/halo#10302. On older versions, saving fails with an inline error and the draft is kept; nothing else in the widget is affected.

Validation:

  • pnpm build, tsc --noEmit, biome check, and vitest run (122 tests) all pass
  • Manually verified in the example app against a local Halo instance: opening the editor, save button enablement, and light/dark appearance

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T15:18:59.154142Z d43f286 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

- Preserve newlines and consecutive spaces when editing plain-text
  comments created from the Console textarea editor
- Show a dedicated message when saving fails with 404 on Halo
  versions without the content endpoints
- Allow canceling while the latest content is loading and retrying
  after a load failure
- Focus the editor once it is ready and confirm before discarding
  unsaved changes
- Rename the generic close event to edit-close
- Cover the new content endpoints and plain-text conversion with tests

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e68dda894f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/comment-widget/src/utils/html.ts
Comment thread packages/comment-widget/src/comment-edit-form.ts
- Join plain-text lines with hard breaks instead of paragraphs so line
  spacing matches the pre-wrap rendering of existing comments
- Keep existing HTML entities encoded once and expand tabs
- Treat angle-bracket text that cleaning would strip as plain text
- Record the editor-normalized content as the dirty-check baseline so
  undoing back to the original no longer prompts or enables save
- Cover concurrent deletion in the 404 save error message

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab186fb9b4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/comment-widget/src/comment-edit-form.ts
Comment thread packages/comment-widget/src/comment-edit-form.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d43f286ce9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/comment-widget/src/comment-edit-form.ts
Comment thread packages/comment-widget/src/comment-item.ts
@ruibaby
ruibaby merged commit 5dac47c into main Sep 24, 2026
2 checks passed
@ruibaby
ruibaby deleted the feat/edit-comment-content branch September 24, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant