16 KiB

Task 9 implementation report — dedicated single-task work page

Status and scope

CODE-FROZEN at acdc5427. The controller may reload the HMR-disabled frontend and perform the real browser/API journey. No live fixture, browser, local API process, proxy, company service, BOS, push or deployment mutation was performed by this implementer. Browser GREEN remains controller-owned; implementation completion is not a claim that the full acceptance gate has passed.

Implemented behavior and composition

  • Added /plugins/annotation-qa/workflows/:workflowId/work, guarded by the same annotation plugin guard, rendering AnnotationOperations workPage. The existing coordinator, CaptureAnnotationWorkbench, media, keyboard handling, dictionaries, write/version fencing, recovery dialogs and submission callbacks are reused without a second editor.
  • Authorized annotators select a project and explicitly click 开始工作 from the existing annotation page. The action performs a fresh public GET /api/human-items?pluginId=annotation-qa&projectId=...&pool=mine, prioritizes the currently selected owned unfinished annotation task, then another owned unfinished annotation task. Owned quality-review tasks are excluded. If no such task exists, it uses the existing blind project-random claim operation.
  • An unresolved random-claim request reuses the existing account/project request ID before considering another allocation. Existing session storage, response fencing, empty-pool notices and random-claim error behavior are retained. Entry loading is guarded against repeated clicks; changed account/project/task or new dirty edits cancel the read-side entry action.
  • Work is entered through same-tab navigation to /plugins/annotation-qa/workflows/all/work?projectId=...&taskId=.... The dedicated presentation removes pool/sidebar controls while retaining task status, errors, materialization/recovery states, complete shared workbench/help and an explicit return link. Layout uses the full editor row, including smaller-width row sizing.
  • Header and workbench return actions use the existing router blocker. Native reload protection remains unchanged. Completion keeps the existing authoritative quality-handoff notice and pauses on the page; there is no automatic next claim.
  • Selecting another task clears prior task error, submission success, processing, stage recovery and claim notices. Completion's new success notice is still set after the old task is closed.
  • Existing global/project role handling and all backend ownership/supplier/review contracts remain unchanged. No production backend change was needed.

TDD evidence and approved boundary

Primary seam remains real browser interaction plus existing public API readback, as approved in the parent spec. The controller supplied RED before implementation: on the actual authorized project pool after task08 QA, the exact 开始工作 button count was 0, and only the existing inline editor entry existed. The production change addresses that missing action and its complete task journey.

No new pure business module or test-only seam was introduced. No new source-string assertion was added. One obsolete source-shape test for the exact bookmarked-task effect was removed from annotation-random-claim.test.mjs; the behavior now also includes work-page selection and is covered by the controller's browser gate. The other pre-existing source assertions in that file remain upstream debt and are not claimed as new interaction proof.

Browser GREEN has not been run by this implementer. The controller must record it after the final build, using the instructions below. Passing supplemental tests is not a substitute for this gate.

Focused verification

node --test tests/frontend/annotation-random-claim.test.mjs tests/frontend/annotation-shortcuts.test.mjs tests/frontend/annotation-submission-state.test.mjs tests/frontend/annotation-authoritative-mutation.test.mjs

32/32 pass, 0 failures, no test warnings. This supplements the browser gate with existing claim-ID, keyboard, stage-completion and authoritative mutation behavior.

go test ./internal/api -run 'TestRandomClaim|TestAnnotatorCannotReleaseOrSelectUnclaimedTaskButAdminStillCanRelease|TestPendingCombinedSubmissionBlocksWorkspaceMutations|TestCombinedAnnotationDraftRejectsNonAnnotatorEvenWhenTaskIsVisible|TestCombinedAnnotationDraftRejectsAnnotatorWhoDidNotClaimTheItem' -count=1

Passed: ok droboticflow/internal/api 3.689s. Existing isolated HTTP fixtures cover random claim replay/concurrency, role/project/supplier restrictions, no self-release/named claim, ownership and processing mutation restrictions. No live fixture writes occur in these unit tests.

npm run lint:web
npm run build
npx prettier --check src/pages/AnnotationOperations.tsx src/App.tsx src/styles/capture-workspace.css tests/frontend/annotation-random-claim.test.mjs
git diff --check

All exit 0. Vite transformed 3203 modules, and all three Go binaries built. Existing Node module.register() deprecation and >500 kB chunk warnings remain. No full suite was run, as instructed; controller owns that final comparison against upstream debt.

Controller browser / public API acceptance

Use only frontend http://127.0.0.1:5173, API http://127.0.0.1:3001, and isolated snapshot Mongo27018 fixtures. Reload after CODE-FROZEN because HMR is disabled. Do not run defaults that point at company services.

  1. On the authorized annotation project's existing pool, verify 开始工作 exists and is enabled after project loading. Preserve existing owned fixtures. Select one current unfinished task if a particular fixture should be resumed, then click Start Work. Observe the same browser tab, the new /work URL with the same task, no pool sidebar, videos/editor/help/stage state present. Network should show owned-task GET/summary/detail reads and no random-claims POST while a resumable owned task exists.
  2. For the full slice-stage journey, use the selected isolated owned fixture's normal 重新切片 action if it starts in annotation. Exercise slice split/frame mapping/dictionary naming, keyboard undo/redo, two-step generate confirmation, actual processing state, and read back completed sliceWorkflow via GET /api/plugins/annotation-qa/tasks/<id> before annotating. Do not reload or rebuild during history checks.
  3. Exercise description draft selection/navigation, dictionary/text save, persisted undo/readback, Ctrl+X blank-invalid behavior, separate stage confirmation and actual quality handoff in this new presentation. Verify keep/blank/invalid/discard semantics remain distinct through the same public task/item reads used for phase1. Confirm completion stays paused, shows a success notice, clears the editor and performs no next random claim.
  4. Create an unsaved draft or slice edit; use the work-page header 返回任务池 or the workbench return action. Verify the existing leave dialog, Esc/continue preservation, and discard/return. Verify native reload retains the existing unsaved warning. Refresh/multipage continuation protocol beyond these existing protections is ticket10, not claimed here.
  5. Only after owned tasks are legitimately completed, or with a controller-approved clean isolated annotator fixture, exercise Start Work without resumable work: exactly one existing random claim, returned task/item readback, same-tab complete shared editor. Empty and unknown outcomes show notices. Unknown replay retains the same request identifier. Do not release pre-existing owned work merely to force this branch.
  6. Switch tasks after a conflict or completed-task success banner. Verify the prior banner is cleared; no old task error/recovery state leaks into the selected task. Unauthorized projects/reviewer roles continue to use the existing guards and public API enforcement.

Files and commit

  • src/App.tsx
  • src/pages/AnnotationOperations.tsx
  • src/styles/capture-workspace.css
  • tests/frontend/annotation-random-claim.test.mjs

acdc5427 — ✨ Add dedicated single-task annotation work page

Only those four task files were committed on feature/local-dev-toolkit. The controller-owned modified ticket was excluded. Initial sandbox denial creating .git/index.lock was resolved by the authorized elevated local git operation. This report is an ignored task artifact, matching previous task reports.

Self-review and limits

Reviewed route guarding, shared composition, owned-task preference, completed-stage exclusion, ambiguous claim replay, repeated entry locking, account/project/task fences, dirty departure handling, success-banner reset ordering, no next-task effect, desktop/mobile row sizing, and exact staged file list. Most textual diff size is Prettier indentation from conditional wrappers around existing header/pool markup; no editor copy or business model rewrite occurred.

The existing large coordinator remains large; only local composition and entry behavior changed. No new backend permission or assignment algorithm was added. Browser GREEN, actual slice materialization/quality handoff, clean no-owned random entry, and role/leave regression acceptance remain the controller's gates. Ticket10 refresh/multipage protocol and ticket11 automatic next-task behavior are intentionally not delivered or claimed complete.

Fix round 1 — application role guard rejected the work route

The controller's first browser GREEN attempt against acdc5427 exposed a real missed integration: after a fresh reload and authorized project selection on completed slice-primary's item route, 开始工作 was enabled, but clicking it ended at /plugins/annotation-qa/workflows/all/annotate without query parameters. The ordinary heading and unselected project confirmed that entry failed. This observed public browser case is the regression RED; the original implementation was not accepted.

Systematic tracing found the exact cause in src/App.tsx's outer RoleRouteGuard: annotators were allowed only the /annotate stage path, item paths and dashboard. The added /work route therefore hit the existing <Navigate to="/plugins/annotation-qa/workflows/all/annotate" replace /> fallback before its plugin guard/coordinator rendered. The fallback's exact URL explains both the ordinary page and lost query. The initial self-review checked the inner plugin/coordinator guards but missed this outer gate.

The smallest fix adds /work alongside /annotate to that existing annotator condition. Reviewer/acceptance/supplier-manager conditions are unchanged. There is no new public helper, test-only seam, copied editor or unrelated change. The browser regression procedure is step 1 above, specifically starting from the same completed item route and asserting the /work URL retains projectId and an unfinished owned taskId, the workbench/media actually operate, and no random claim occurs while owned unfinished work exists. Controller owns that GREEN rerun.

Verification after the one-line fix:

node --test tests/frontend/annotation-random-claim.test.mjs tests/frontend/annotation-shortcuts.test.mjs tests/frontend/annotation-submission-state.test.mjs tests/frontend/annotation-authoritative-mutation.test.mjs tests/frontend/fanyu-v5-four-stage.test.mjs

35/35 pass, 0 failures. Existing source-shape checks are supplementary upstream tests, not proof of the browser fix. No new source assertion was added.

npm run lint:web
npm run build
npx prettier --check src/App.tsx
git diff --check

All exit 0. Vite transformed 3203 modules; all three Go binaries compiled; the same existing Node deprecation and chunk-size warnings remain. No full suite, browser, live fixture or service restart was run by this implementer.

Fix commit: ce012f8a — 🐛 Allow annotators to enter the dedicated work route. Only src/App.tsx was staged. CODE-FROZEN again after all checks/build; controller may reload and retry. Real browser GREEN and complete task-stage acceptance remain pending until controller evidence confirms them.

Fix round 2 — delayed claim continuation and stale entry notices

Read and verified the Important P2 finding in task-9-review.md. The new owned-task entry reads checked task/account/project/dirty state, but both random-claim branches omitted that predicate; the random claim handler checked only actor/project before navigation and notices. This allowed a response from the earlier Start Work action to take over a newly selected task or interrupt new edits.

Browser RED before production changes

The controller reproduced against ce012f8a: an ordinary random claim with request ID 8bb22e0cfb569533ef21b61591d23f5c returned HTTP200 but its response was dropped by the local proxy. Start Work replayed the same ID with its response delayed 30 seconds. During the delay the controller selected annotate-delayed, observing the normal /all/annotate?...taskId=...annotate-delayed page. When the replay resolved, the old response forced /all/work?...taskId=...pool-03, without a leave dialog. This is the public browser RED for the actual stale-navigation defect, not a source assertion. One isolated pool item was genuinely claimed; the controller retains ownership and controls all fixture/network operations.

Change and preservation

  • Both Start Work claim paths now pass their origin predicate into randomClaimTask. Dedicated entry is fail-closed without that predicate.
  • Navigation, pool-view changes, loading/error resets and success/empty/error notices occur only while the originating entry session is current and there are no current dirty edits.
  • The entry captures the existing authoritative task/account context identity, not just the task ID. A switch A → B → A cannot revive the earlier action. Stable account/project/router-location context identity additionally invalidates account/project/route round trips, and cleanup invalidates a pending entry when the page unmounts.
  • A confirmed claim is still merged into My Tasks for the current matching account/project before a stale continuation exits. This preserves the real allocated task without changing selection, focus, page, or current editor. Authoritative success and existing terminal errors clear their request receipt; network/unknown errors continue to retain the same request ID for retry.
  • Owned-task read errors now use the same entry predicate. No stale entry error replaces another task's notice.

The changes stay in AnnotationOperations.tsx; no new business/test-only interface, backend change, release, fixture mutation, service restart, or auto-next behavior was introduced.

Verification

Before editing, the existing focused claim + authoritative mutation tests passed 12/12. After editing:

node --test tests/frontend/annotation-random-claim.test.mjs tests/frontend/annotation-authoritative-mutation.test.mjs tests/frontend/annotation-shortcuts.test.mjs tests/frontend/annotation-submission-state.test.mjs

32/32 pass, 0 failures and no test warnings. These are supplemental existing tests; controller browser GREEN below is required to verify the new async UI continuation. No new source-string assertion was added.

npm run lint:web
npm run build
npx prettier --check src/pages/AnnotationOperations.tsx
git diff --check

All exit 0. Vite transformed 3203 modules; all three Go binaries compiled. Existing Node deprecation and >500 kB chunk warnings remain. No full test suite was run.

Self-review checked both claim callsites, successful/empty/error outcomes, current dirty state, task/account/project/route switch-back invalidation, unmount, preserved unresolved IDs, and reconciliation without selection or global-notice changes. The ordinary existing random-claim button behavior is otherwise unchanged.

Fix commit: 97fe6c77 — 🐛 Fence delayed work entry to its originating task session. Only the coordinator file was staged; controller ticket changes remain untouched. CODE-FROZEN after compilation and checks.

Controller GREEN required

After reload, repeat the actual same-ID delayed replay; switch to another clean task and verify URL/editor/selection remain on that task when the result arrives, while the genuinely claimed item remains in My Tasks. Repeat while creating a dirty description draft: no stale automatic navigation or leave dialog, draft retained. A delayed error or empty result should likewise leave the new task's notices alone; unknown failure must retain its request ID. Replaying a confirmed receipt can reuse the already claimed isolated pool-03 task rather than consume another task. Also check an unswitched clean entry still opens the returned task normally, and task/account/project/route round trips cannot restore an old continuation. Controller owns the final public API readback and scoped review.