Repository navigation
feat(task-comments): allow editing own recent human comments - #441
Merged
Merged
Conversation
Add the ability to edit a task comment, restricted to the comment's own
author, human-authored comments only, and comments younger than 3 hours.
The three rules live in TaskComment#editable_by? (window TaskComment::
EDIT_WINDOW = 3.hours) and are enforced server-side in the controller
rather than the policy: the authorize-by-default path (AuthorizationConcern)
hands the policy a namespace symbol, not the record, so the policy keeps the
plain project-write check (mirroring assets#destroy) and the record-level
rules are applied in the action, returning 403 on a violation. The update
permits only :body, so tags and author_type cannot be changed. A successful
edit records a comment_updated board activity.
The frontend offers an inline Edit affordance in the comment actions row,
gated by the same rules (canEditComment); the server remains the source of
truth.
Backend:
- route: add update to task comments
- TaskComment: EDIT_WINDOW + editable_by?
- BoardActivity: add comment_updated event type
- TaskService.update_comment (records comment_updated)
- CommentsController#update (record-level 403, body-only)
- CommentsPolicy#update? = project_writable? (api + web)
Frontend:
- thread currentUserId into TaskDetailSidebar
- canEditComment helper (own + human + <3h)
- inline edit form (PATCH + partial reload)
- apiV1ProjectTaskCommentPath route helper
Tests:
- model: editable_by? (owner/other/agent/system/age/edge)
- integration: update authz (owner ok; non-author/viewer/agent/stale 403;
tags/author_type unchanged)
- frontend: canEditComment gating
Signed-off-by: Evgeniy Yagnenkov <[email protected]>
Merged
artempartos
added a commit
that referenced
this pull request
Oct 8, 2026
Adds the entries #441, #445 and #447 merged without, then moves [Unreleased] into 1.1.0. Minor, not patch: the release carries new features (comment editing, custom analytics range, Sessions & Runs sorting and date filters, /changelog, Managed by Aixle). Signed-off-by: Artem Petrov <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the ability to edit comments on tasks. Editing is allowed only when all
three conditions hold:
author_type == human, not agent/system);The server is the source of truth; the UI only hides the Edit affordance when
the rules are not met.
Design notes
TaskComment#editable_by?withTaskComment::EDIT_WINDOW = 3.hours.CommentsController#update, not in the policy. Thistree uses authorize-by-default (
AuthorizationConcern#dynamic_authorize!),which passes the policy a namespace symbol rather than the record, so a
record-level
update?cannot inspect the comment. The policy therefore keepsthe plain
project_writable?check (the same shape asassets#destroy), andthe own/human/age rules run in the action, returning
403on a violation.updatepermits only:body—tagsandauthor_typecannot bechanged through it.
comment_updatedboard activity (new event type),mirroring
comment_added.task_commentshas noupdated_at, and edits are notmarked "edited". Age is computed from
created_at.Changes
Backend
config/routes.rb: addupdateto task comments.app/models/task_comment.rb:EDIT_WINDOW+editable_by?.app/models/board_activity.rb:comment_updatedevent type.app/services/task_service.rb:update_comment(saves body, records activity).app/controllers/api/v1/projects/board/task/comments_controller.rb:update.app/policies/{api/v1,web/company}/.../comments_policy.rb:update?.Frontend
canEditComment.ts: pure gating helper (own + human + <3h).TaskDetailSidebar.tsx:currentUserIdprop, Edit button + inline form,PATCH via
apiMutatewith a partial reload oftask_comments.BoardPage.tsx: passcurrentUserId.shared/routes.ts:apiV1ProjectTaskCommentPathhelper.Tests
editable_by?across owner / other user / agent / system / over-window/ edge cases.
collaborator, read-only viewer, agent-authored, and over-3h comments all get
403;tags/author_typeare not changed by an edit.canEditCommentgating.Verification
yarn tsc,yarn eslint(0 errors),canEditComment.test.ts(6/6),
BoardPage.test.tsx(129/129).ruby -c.Please run
make rails-testandmake rubocopin CI / a networked env.app/frontend/shared/routes.tswas edited by hand following the generator'sexact format; regenerate with
bin/rails ts:routesto confirm no drift.Related issues
Type of change
Checklist
git commit -s).organization has executed the Corporate CLA.
make check_allpasses locally (tests, rubocop, brakeman, eslint, typescript).