You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Task 9] Staff Support Desk queue and ticket surface - #31
Adds an allowlisted operator surface over published Support Desk 0.1.0 staff services (queue, detail, public reply, internal note, assign, priority, lifecycle). Customer feedback routes are unchanged.
Allowlist staff via SUPPORT_STAFF_EMAILS / SUPPORT_STAFF_PRINCIPALS, expose /api/support/admin routes for queue/detail/reply/note/lifecycle, and ship authenticated /staff/support pages with explicit public vs internal compose.
Review complete. No issues found — the changes look solid.
This pull request implements the Task 9 staff Support Desk surface with sound authorization and HTTP boundaries. Staff access is gated by a fail-closed env allowlist; non-staff receive 403; mutations require same-origin and CSRF; and staff authorization is evaluated before the shared reply rate limiter is debited. Public replies and internal notes are separated at both the API and UI layers, customer DTOs do not gain staff fields, and the test suite exercises the isolation of internal notes from customer reads. Customer routes remain contractually unchanged. No defects requiring change were identified.
The reason will be displayed to describe this comment to others. Learn more.
Grok Build Review
The staff surface is correctly composed: env allowlist gates AccessContext construction, public reply and internal note are separate admin endpoints, mutations retain same-origin and CSRF controls, and the test suite demonstrates that internal notes never surface on customer reads. One defect remains in the staff message and note handlers: the shared reply rate limiter is charged before staff membership is evaluated, so authenticated non-staff callers debit operator capacity on a path that can only return 403. Correct that ordering before merge; otherwise the change is sound against Task 9 exit criteria.
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds a gated staff/operator surface for Support Desk on pegma.dev, exposing queue + ticket detail + lifecycle controls + distinct public-reply vs internal-note composition, backed by the published Support Desk 0.1.0 staff application services and guarded by an env allowlist.
Changes:
Introduces staff allowlist parsing + staff AccessContext resolution (SUPPORT_STAFF_EMAILS / SUPPORT_STAFF_PRINCIPALS) and wires it into the Worker runtime.
Adds new authenticated staff API endpoints under /api/support/admin/... for queue, ticket read, message reply, internal notes, and lifecycle/assignment/priority changes.
Adds staff UI pages + JS + CSS, plus a comprehensive staff API test suite and updated composition documentation.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
File
Description
worker/src/support-desk.ts
Extends runtime env shape to include staff allowlist variables.
The reason will be displayed to describe this comment to others. Learn more.
Preserve queue pagination in the admin API
Once the queue exceeds the application service's single-page limit, this response discards the continuation cursor and exposes only result.items; parseStaffQueueQuery also provides no way to submit that cursor, so the /staff/support client can never reach tickets beyond the first page. Return the service's next cursor, accept it on subsequent requests, and wire a continuation control into the queue UI.
The reason will be displayed to describe this comment to others. Learn more.
Intentional: Support Desk listStaffQueue always starts from a null request-local cursor and consumes one complete projection scan cycle, returning either the full filtered result or SupportDeskQueueCapacityError with no partial page. There is no client-visible continuation cursor by design (BUILDOUT Task 5 / COLLECTIONS). Online staff requests must not resume another request's cursor. Leaving open for human visibility.
The reason will be displayed to describe this comment to others. Learn more.
Intentional: Support Desk listStaffQueue always starts from a null request-local cursor and consumes one complete projection scan cycle, returning either the full filtered result or SupportDeskQueueCapacityError with no partial page. There is no client-visible continuation cursor by design (BUILDOUT Task 5). Leaving open for human visibility.
The reason will be displayed to describe this comment to others. Learn more.
Preserve queue continuation tokens
When the queue exceeds the application service's first page, this response discards all continuation metadata and parseStaffQueueQuery provides no way to send a cursor back. The staff UI consequently renders only the first page forever, leaving older or lower-sorted tickets unreachable; expose the pagination metadata, accept a continuation cursor, and let the queue surface request subsequent pages.
The reason will be displayed to describe this comment to others. Learn more.
Same intentional design as prior review: listStaffQueue always starts from a null request-local cursor and either returns the full filtered materialization for one complete projection scan cycle or throws SupportDeskQueueCapacityError with no partial page. Client continuation is not part of the Support Desk online queue contract (BUILDOUT Task 5). Leaving open for human visibility after re-review.
The reason will be displayed to describe this comment to others. Learn more.
Block concurrent compose submissions
While a reply or note POST is pending, the submit button remains enabled and there is no in-flight guard. On a slow connection, a double-click or repeated Enter dispatches multiple requests; because the server mints a fresh command and message ID for each request, all of them can succeed and create duplicate public customer replies or internal notes. Disable submission until the request settles, restoring it on failure.
The reason will be displayed to describe this comment to others. Learn more.
Reject priority on unrelated patch actions
For actions other than change_priority, this schema still accepts a priority property and silently ignores it. For example, { "action": "resolve", "priority": "urgent" } returns success after resolving the ticket without changing its priority, which can mislead API clients into believing both requested changes were applied. Validate the permitted keys conditionally after parsing the action.
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
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.
Plan
docs/BUILDOUT.mdTask 9 — staff surfaces (pegma.dev host PR).Summary
Adds an allowlisted operator surface over published Support Desk 0.1.0 staff services (queue, detail, public reply, internal note, assign, priority, lifecycle). Customer feedback routes are unchanged.
Exit criteria
listStaffQueue,readStaffTicket,replyAsStaff,addNote, assign/priority/lifecycle)SUPPORT_STAFF_EMAILS/SUPPORT_STAFF_PRINCIPALS); non-staff 403Test evidence
npm run check— cleannpm test— node 152 + d1 2 tests green (including staff API suite)Residual risks
/staff/support); operators bookmark URLsDocs
Updated
docs/SUPPORT_COMPOSITION.mdandworker/.dev.vars.example.