Repository navigation
fix(chat): write each Action Center event once when an approval or a click repeats - #1935
Merged
Merged
Conversation
…click repeats Follow-ups from the approval notes on ansvisor#1897, ansvisor#1902 and ansvisor#1898. - Add to AC-{n} (attachToAction, W2-10): the evidence_attached event carries its approval's key (`chat:{step}`, as Send to Action Center's payload does), and a retried approval finds that event and returns it instead of adding the finding again. Two calls at the very same moment are already kept apart by the engine's idempotency claim; a database-level guarantee would need a unique index (a migration), not added here. - Card clicks (W2-12): Attach to task & mark done and its Undo write the task's status only when it really changes (`.neq('status', …)` through writeTaskStatus's new onlyIfChanged), so two clicks at once leave one History event. The drawer's own writes are unchanged. - Attach only from a card now records the card's chat and run on its file_attached event, as a mark done's event does. attachFileToTask takes the card's place and reads it on the server (the person's own chat and a run of it) before recording it; no execution mode, as it is the person's own click. - Daily suggestions (W2-26): recordUse skips a removed suggestion (no use, no feed stamp), and the page's last Site Audit matches the action's pages by pageKey (no scheme, www or trailing slash), by the audit's url or final_url, among the brand's latest 500 audits (as the server's recheck reads them). - The test fake reads JSON-path filters (`data->>key`) as PostgREST does. 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
Chat's writes to Action Center could repeat when an approval or a click repeated. Follow-ups from the #1897, #1902 and #1898 reviews. No migration.
attachToAction(feat(chat): let Chat send findings to Action Center, attach files to tasks and set Ready for review, with Undo (W2-10) #1897).idempotencyKey: chat:{step}, the form Send to Action Center uses. Before attaching, an event with the same key is looked up. If there is one, it comes back and nothing is added, even if the action has closed in between.writeTaskStatusgainsonlyIfChanged, a conditional update (.neq('status', …)). The event and the Updated stamp are written only when the row really changed.conversationIdandrunIdinto its event, checked on the server: the conversation must be the person's, and the run that conversation's.executionis null, since it's the person's own click.recordUsereads with.is('removed_at', null), so a removed suggestion writes neither suggestion nor feed stamp.pageKey, so http or https, www and a trailing slash don't matter. It looks at the audit'surlandfinal_url, within the brand's last 500 audits, the limit the server's audit-recheck uses too.Test helper: the fake Supabase client used in tests reads JSON filters such as
data->>keyas PostgREST does.Questions for review:
action_events (action_id, (data->>'idempotencyKey')) where event = 'evidence_attached'. That's a migration, so it isn't here. Today the engine's own idempotency record separates concurrent calls, and the look-up covers repeats.linkedcan belong to the click that didn't link. Undo then leaves the link. This is a small edge case and was left as is.Related issue
None. Follow-ups to the #1897, #1902 and #1898 reviews.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
/dashboard/chat/inbox/{id}), the last audit date now shows when the audited address differs in www, http or a trailing slash.Checklist
yarn lintpasses (0 errors; 7 old warnings in files this PR doesn't touch)yarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)Full checks on this branch (cb68716): web 803 files / 8384 tests pass, and
yarn buildpasses. Serverformat:checkand lint are clean, and 352 files / 4994 tests pass (3 skipped).🤖 Generated with Claude Code