Skip to content

feat: 2.22.0 context menus, focus mode, 409 lock conflicts, batched boards read - #124

Open
HecFranco wants to merge 5 commits into
mainfrom
feat/2.22-menus-focus
Open

HecFranco wants to merge 5 commits into
mainfrom
feat/2.22-menus-focus

Conversation

@HecFranco

Copy link
Copy Markdown
Contributor

TaskBoardBundle 2.22.0: context menus, focus mode, lock conflicts 409 + Retry-After

Owner requests relayed by Beacon. One minor release; no schema change. The only behaviour change is the documented status of Task API lock conflicts, which moves from 500/503 to 409.

1. Task and column menus (UiKit 2.54 context menus)

  • Every board card and list row has a «⋮» menu, drawn with UiKit's menu partial. Its entries are Open, Edit, Assign (Assign to me / Remove me / Other people…), Status (the board's other columns), Priority, Due date (Today / Tomorrow / In a week / No due date), Tags…, Start timer (only with the TimeTrack integration), Copy link, Duplicate… / Move to… (move.enabled), Archive and Delete.
  • Column headers have Rename, Add task and Hide / collapse. Collapse is kept per board in localStorage; nothing is written on the server.
  • When context menus are on, a right-click, Shift+F10 / the ContextMenu key, or a long press opens the same items. UiKit mirrors the kebab, so there is only one list of items.
  • web_ui.context_menus: null follows theme.context_menus; true or false forces it on or off.
  • Cards, rows and headers are focusable, and Tab reaches the kebab toggle.
  • An entry is printed only when it is allowed (Menu\TaskMenuBuilder):
    • canEditTask(): Edit, Assign, Status, Priority, Due date, Tags, Archive
    • canTrackTime() and the time tracker: Start timer
    • move.enabled, canEditTask() and canEditBoard(): Duplicate, Move to
    • canManageBoard(): Delete
    • canManageColumns(): Rename
    • canEditBoard(): Add task
  • The board's access decision is taken once per page (taskEditDecider()), not once per card.
  • New route task_menu: POST /tools/task-board/menu/task, CSRF token task_board_task_menu, same origin only (Sec-Fetch-Site, else Origin).
    • Each right is checked again on the server; a hidden entry posted directly returns 403.
    • The route reuses TaskManager (with the ordered locking from 2.21), TaskMemberAssigner, TaskBoardEraserInterface and TimeTrack's TimerService.
    • The page has one CSRF-only form, nowo-task-menu-form (REQ-TWIG-005).
  • User HTML goes through Text\ReservedAttributeStripper, which fails closed as ChatKit 1.33 does. This covers task descriptions, comment bodies and Markdown board descriptions.

2. Focus mode (UiKit 2.55)

  • focus_mode_toggle (area tasks) is on the board, list, calendar and task pages. It renders nothing while the host has focus mode off.
  • The constraint is now nowo-tech/ui-kit-bundle ^2.55.

3. 409 + Retry-After (transaction-doctrine ^1.3)

  • When a lock conflict appears anywhere in the failure's chain, the Task API answers the shared ConflictResponsePolicy: 409 by default, or 503 when the host keeps it.
    • Before, the answer was 500 SERVER_001 from the bundle, or 503 from the host responder on transaction-doctrine 1.2.
    • The chain is checked for LockConflictExceptionInterface, TransientStorageFailure, a DBAL RetryableException or PostgreSQL 55P03.
    • The answer is Retry-After with {err, ECODE: CONFLICT_001}.
    • After a partial commit (ConcurrencyConflict::committed), it is CONFLICT_002 with no Retry-After.
  • ?ConflictResponsePolicy is injected and falls back to new ConflictResponsePolicy().
  • TaskApiConflictResponseFormatter (ConflictResponseFormatterInterface) is registered only when the interface exists. It finds API requests by their route flag, so Beacon can drop its route-prefix formatter (the codes are the same).
  • UPGRADING covers the 503→409 change, including hosts that do not register NowoTransactionDoctrineBundle.

4. Beacon asks

  • Calendar on phones:
    • .nowo-task-cal is now the positioned ancestor of its screen-reader text and clips sideways overflow.
    • The toolbar wraps, and the tabs lose their row margin.
    • Beacon's _tasks.scss block can go.
  • TaskApiReadOperations::boardsOfTeam(): spaces, boards with their columns, and counts are read in one batch (2 queries for 1 space × 1 board, and also for 3 spaces × 4 boards).

5. Audit follow-ups

  • SF4-I1: config.process-timeout: 0 (composer igor).
  • SF4-I2: HostRoutingControllersTest also runs with every feature on (API, sync, calendar, task numbers, move, recurrence, multi-board, templates).

Tests

  • PHPUnit 100% coverage gate.
  • New tests:
    • Permission matrix per role (manager / editor / reader) and per entry.
    • Direct calls to hidden entries return 403.
    • Wrong CSRF token, cross-site and wrong origin return 403; an unknown action returns 400; a missing task returns 404.
    • Refusals from the transition policy, a task changed meanwhile, the assignee policy, the time tracker, and a synced task on delete.
    • 409 / Retry-After / committed cases (unit and HTTP).
    • boardsOfTeam() query count.
    • Reserved-attribute stripping.
    • The taskEditDecider() equivalence matrix.
    • Context-menu option and focus toggle rendering.
    • Routing with every feature on.
  • Vitest at 100% (column collapse and rename).
  • Playwright (demo/symfony8/e2e/tests/task-menus.spec.ts), run on the demo in FrankenPHP worker mode:
    • Right-click with a submenu write (Chromium, Firefox, WebKit).
    • Shift+F10 on a card and on a column header; Tab reaches the kebab.
    • Long press (Chromium phone).
    • Focus toggle on board, list and calendar.
    • Calendar at phone width (no page widening, toolbar inside the viewport).
  • The demo turns on theme.context_menus and theme.focus_mode, and its shell is the focus mode root.

Verification (local, tb222 stacks)

  • composer test-coverage-100: 2807 tests, 100.00% statements and elements; phpstan clean; cs-fix clean; Igor 759/759 stateless; twig lint and REQ-TWIG-005 OK; translations 7 locales.
  • New functional tests also green under phpunit.private-em.xml.dist (private EM + XML mapping, the DDD host setup) and TASK_BOARD_TEST_PORTS=twin.
  • Note: uikit-migration.spec.ts › "task page: show scaffold…" (inline subtask treeitem) fails on this demo with the 2.21.1 src too (checked with src stashed); it is unrelated to this PR.

…ed boards read

Owner requests relayed by Beacon (TaskBoard 2.22.0):

- Context menus: a menu on every board card, list row and column header
  (UiKit menu partial), mirrored by UiKit 2.54's context menu (right-click,
  Shift+F10, long press). web_ui.context_menus null|true|false. Entries are
  printed only when allowed (Menu\TaskMenuBuilder, one board decision per
  page through taskEditDecider()); the writes go through the new task_menu
  route (POST, CSRF task_board_task_menu, same origin) that checks every
  right again and reuses TaskManager, TaskMemberAssigner, the eraser and
  TimeTrack's TimerService. User HTML is stripped of UiKit's context-menu
  attributes (Text\ReservedAttributeStripper, fail closed).
- Focus mode toggle (UiKit 2.55, area tasks) on board, list, calendar and
  task pages; ui-kit-bundle ^2.55.
- Task API lock conflicts answer transaction-doctrine 1.3's shared policy
  (409 + Retry-After, CONFLICT_001; CONFLICT_002 without Retry-After after a
  partial commit), was 500; TaskApiConflictResponseFormatter for the
  responder; transaction-doctrine ^1.3.
- Calendar does not widen the page on phones; its toolbar wraps.
- TaskApiReadOperations::boardsOfTeam(): spaces, boards with columns and
  counts in one batch.
- composer process-timeout 0 (SF4-I1); HostRoutingControllersTest with
  every feature on (SF4-I2); PHPUnit memory limit 2G for the HTML report.
CHANGELOG (Unreleased), UPGRADING (To 2.22.0: 503/500 to 409, hosts without NowoTransactionDoctrineBundle, new task_menu route), USAGE (task and column menus, focus mode), CONFIGURATION (web_ui.context_menus), SECURITY, API (CONFLICT_001/002, boardsOfTeam), OpenAPI error codes and the worker audit row.
The demo turns on UiKit's theme.context_menus and theme.focus_mode, its shell is the focus mode root, and requires ui-kit-bundle ^2.55. task-menus.spec.ts: right-click with a submenu write, Shift+F10 on a card and a column header, Tab to the kebab, long press on a phone, the focus toggle on board, list and calendar, and the calendar at phone width.
The board page with 500 cards carried a copy of the three submenus per card and went past 128 MB on PHP 8.4 / 8.5 in ImportControllerMemoryTest (the import's redirect renders the board). They are now one <template id="nowo-task-menu-shared"> per page; task-board.js (task-menu-shared.ts) copies them into a card's or row's hidden slot, with its task id and without its own column and priority, on pointer, key or focus in the capture phase, before UiKit's context menu reads the kebab. Same memory as 2.21.1 for that test; e2e unchanged (Chromium, Firefox, WebKit, phone).
…udit SU)

SU-L1: a Task API lock conflict answered CONFLICT_001 ("send the same
request") after the request had committed part of its work, and a retry
with the same Idempotency-Key could write twice.
- TaskApiCommitWatermark keeps transaction-doctrine's commit-ledger count
  in the request attributes when the API controller is chosen (after the
  idempotency claim). The ledger is fed by its DBAL middleware, registered
  on the connections; transaction-doctrine's own ledger is used when its
  commit detection is on. Any later commit makes the conflict CONFLICT_002
  without Retry-After, in the API listener and in the responder formatter.
- The idempotency key keeps a CONFLICT_002 answer, so the same key replays
  it and writes nothing.
- createTask (task and assignees) and deleteTask run in TaskApiTransaction,
  their events dispatched after the commit.
SU-I1: a MySQL lost savepoint (1305) without a deadlock or lock wait
timeout in the chain is CONFLICT_002.
SU-I2: MariaDB 1020 counts as a lock conflict.
SU-I3: UPGRADING notes trusted_proxies for the menu's same-origin check.
SU-I6: column-collapse.ts and task-menu-shared.ts in Vitest coverage.
SU-I8: demo PLAYWRIGHT_IMAGE v1.65.0-jammy.
SECURITY, UPGRADING, API and CHANGELOG wording follows.
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