Skip to content

feat(action-center): change or delete an action from its row menu - #1144

Merged
gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:feature/action-center-row-menu
Oct 18, 2026
Merged

gkhngyk merged 1 commit into
ansvisor:mainfrom
cihan-gyk:feature/action-center-row-menu

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Each Action Center action gets a row menu: In Progress, Completed, Dismiss and Delete, without opening the drawer. This was requested by the product owner.

Web

  • "…" menu: a "…" button ends every row of the Actions list, as on the Signals list. It opens downward with In Progress, Completed, Dismiss, a separator and Delete.
    • The status the action already has is off.
    • The menu cell stops the click, so the drawer doesn't open.
  • Status changes: they use updateActionStatus, as the drawer does. A toast says "Moved to In Progress", and the list reloads.
  • Delete:
    • It asks first ("Delete this action?") and then calls the new server route.
    • It is off, with a tooltip, for members who aren't admins or managers (canManage).
    • If the drawer showed the deleted action, it closes.
  • Busy state: while a change to a row is in flight, its menu waits.
  • Sticky column: the menu column stays at the table's right edge (sticky right-0, with the row's hover tint). The table already scrolls sideways below about 1,100px, and at 1024px the menu sat off-screen.

Delete hides, it doesn't remove: migration 00168_actions_soft_delete.sql

A deleted action becomes dismissed with a new deleted_at, and the row stays.

  • Why: the nightly generator reads completed and dismissed actions to know when a definition last closed (its rest window). Kept as dismissed, a deleted action doesn't come back the next night while its condition still fires. Removed outright, it would.
  • "actions: member select" now requires deleted_at is null. That hides deleted actions from every member read at once: the list, History, and the task, event and signal-link policies, which look actions up through it.
  • sync_opportunity_status (security definer) no longer counts deleted actions. A Content opportunity whose only action is deleted keeps its status.
  • Unchanged: the generator, which treats a deleted action as dismissed.

Server

  • DELETE /api/action-center/actions/:id:
    • Loads the action on the admin client and checks the caller's organization (assertBrandAccess), then the caller's role (admin or manager, else 403).
    • Sets status = 'dismissed', deleted_at, completed_at = null and updated_at, guarded by deleted_at is null.
    • Records a deleted event with the actor.
    • An action that is missing or already deleted is a 404.

Admin reads (MCP, API, exports)

These run on the admin client, past RLS, so they filter deleted_at themselves:

  • listActionsFor, getActionFor, listActionHistoryFor;
  • signalActionRefs (used_by_actions);
  • updateTaskStatusFor, which refuses a deleted action's task;
  • exportActionFor.

Deploy

Apply 00168. It doesn't depend on #1139's 00167; the numbers only keep their order.

Related issue

None. Requested by the product owner.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. Apply 00168 and open Action Center → Actions.
  2. Click a row's "…": the menu opens downward, the current status is off, and the drawer stays closed.
  3. Pick Completed: a toast confirms it and the Status column changes.
  4. As an admin or manager, pick Delete and confirm. The action leaves the list and doesn't show in History; in the database it is dismissed with deleted_at.
  5. As a member who isn't an admin or manager, Delete is off.
  6. Narrow the window to 1024px: the table scrolls, and "…" stays at its right edge.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/): no errors; the 7 warnings are in files this PR does not touch
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Also run:

  • server: npm run format, npm run lint and npm test (1536) pass. routes/action-center-delete.test.js covers the soft delete and its event, the organization check, the role check, and a missing or already deleted action.
  • web: yarn test (1337) and yarn build pass.
    • action-table.test.tsx: the menu's items, the current status off, a status change without opening the drawer, the delete confirmation, Delete off without the role, the busy state, and no menu without handlers.
    • lib/mcp/action-center.test.ts: the task check excludes deleted actions. The other MCP test mocks learned .is.
  • bash supabase/build-schema.sh: regenerated schema.sql.
  • Dev database: a rolled-back dry run, then the migration applied. Existing actions stay visible.
  • Browser: this branch's server and web, with two sample copies of the demo brand's actions.
    • Checked: In Progress from the menu; Delete with its confirmation, after which the action left the list and History, was dismissed with deleted_at in the database, and its trail read status_changed, deleted.
    • Views: 1440px and 1024px, light and dark.
    • Afterwards: the samples were removed.

🤖 Generated with Claude Code

Each row of the Actions list gets a "…" menu that opens downward with In
Progress, Completed, Dismiss and Delete, so an action is moved or removed
without opening its drawer. The status it already has is off, Delete asks
first and is for admins and managers, and the menu column stays at the
table's right edge when the table scrolls sideways.

Delete hides rather than removes (migration 00168): the action becomes
dismissed with deleted_at, so the nightly generator still reads a
dismissed action and keeps its rest window, and a condition that is still
firing doesn't bring it back the next night. Members' select policy leaves
deleted actions out, which covers every list, History and the task, event
and signal-link reads; the admin reads behind MCP, the API and exports
filter them; and sync_opportunity_status no longer counts them.
DELETE /api/action-center/actions/:id does it, checked against the
caller's organization and role, and records the event.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the needs-migration Adds or edits a migration — apply it to the hosted database label Oct 17, 2026
@cihan-gyk

Copy link
Copy Markdown
Collaborator Author

@gkhngyk The product owner asked for a row menu on Action Center actions (In Progress, Completed, Dismiss, Delete without the drawer). Delete hides rather than removes: migration 00168 adds actions.deleted_at, the member select policy leaves deleted rows out, and DELETE /api/action-center/actions/:id (admins and managers) sets dismissed + deleted_at so the generator keeps its rest window. Applied on the dev DB; deploy needs 00168. Thanks!

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Checked on main with the rest of tonight's PRs stacked on top. The delete route tests, action table tests, MCP export tests, typecheck, lint and format pass, and CI is green.

00168 is applied on production. sync_opportunity_status matches the live definition apart from the new deleted_at is null filter. action_events has no check constraint on event, so the deleted event inserts.

Checked as authenticated: a member still reads the brand's 47 actions, and a user from another organization reads none. Deleted rows stay dismissed, so the open-action dedup index (00084) and the generator's rest window treat them as any dismissed action.

@gkhngyk
gkhngyk merged commit a52a5ef into ansvisor:main Oct 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-migration Adds or edits a migration — apply it to the hosted database

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants