Skip to content

[Task 9] Staff Support Desk queue and ticket surface - #31

Merged
FlyOverCoderKY merged 4 commits into
mainfrom
grok/buildout-task-9-staff-surfaces
Jul 29, 2026
Merged

FlyOverCoderKY merged 4 commits into
mainfrom
grok/buildout-task-9-staff-surfaces

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Plan

docs/BUILDOUT.md Task 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

  • Staff surface uses Task 4/5 application services (listStaffQueue, readStaffTicket, replyAsStaff, addNote, assign/priority/lifecycle)
  • Compose mode makes public reply vs internal note visually distinct and requires explicit selection (no default)
  • Separate admin HTTP endpoints for messages vs notes
  • Staff gated by env allowlist (SUPPORT_STAFF_EMAILS / SUPPORT_STAFF_PRINCIPALS); non-staff 403
  • Internal notes never appear on customer ticket reads
  • No shared control plane with retiregolden.org
  • Mail/notification still deferred (Task 10)

Test evidence

  • npm run check — clean
  • npm test — node 152 + d1 2 tests green (including staff API suite)

Residual risks

  • Empty staff allowlist fails closed (all staff routes 403) until env is set
  • Staff pages unlisted (/staff/support); operators bookmark URLs
  • Queue list shows projection fields only; subject on detail
  • Outbound mail not activated

Docs

Updated docs/SUPPORT_COMPOSITION.md and worker/.dev.vars.example.

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.
Copilot AI review requested due to automatic review settings July 29, 2026 15:12
@cursor

cursor Bot commented Jul 29, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Grok Grok Build Review — no issues

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.

Reviewed commit c96c09e · workflow run

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

@codex review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Grok 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.

🐞 0 bugs · ⚠️ 1 warnings · 🤏 0 nits

Reviewed commit 428cac1 · workflow run

Comment thread worker/src/support-api.ts Resolved

Copilot AI 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.

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.
worker/src/support-api.ts Implements staff admin routes (queue/read/messages/notes/patch) with authn + CSRF + rate limiting + DTO mapping.
worker/src/support-api.test.ts Adds staff allowlist parsing/access tests and end-to-end staff API route coverage (401/403, queue/read/reply/note/patch).
worker/src/support-access.ts Adds staff policy constants and allowlist-based staff access resolution helpers.
worker/src/index.ts Injects parsed staff allowlist into the support API handler from env.
worker/.dev.vars.example Documents staff allowlist env vars and health probe toggle for local dev.
src/styles/global.css Adds styling for staff queue/ticket status + compose mode and message visibility distinctions.
src/pages/staff/support.astro Adds staff queue page shell (signed-out/forbidden states, filters, list container).
src/pages/staff/support/ticket.astro Adds staff ticket detail/compose/lifecycle page shell with required compose-mode selection.
public/staff-support.js Implements client-side staff queue loading, filtering, and error-state handling.
public/staff-support-ticket.js Implements client-side staff ticket load, lifecycle actions, and distinct public vs internal compose posting.
docs/SUPPORT_COMPOSITION.md Documents staff allowlist policy, staff endpoints, patch body contract, and staff page URLs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 428cac1413

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread worker/src/support-api.ts
Comment on lines +734 to +736
return json({
items: result.items.map(staffQueueItemDto),
csrfToken: authenticated.csrfToken,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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.

Non-staff sessions must not consume the shared customer reply limiter before receiving 403 on admin message and note routes.
@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

@codex review

2 similar comments
@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

@codex review

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ebeca41b2e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread worker/src/support-api.ts
Comment on lines +734 to +736
return json({
items: result.items.map(staffQueueItemDto),
csrfToken: authenticated.csrfToken,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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.

Comment on lines +284 to +289
try {
showStatus(mode === 'public' ? 'Sending public reply…' : 'Saving note…');
const view = await api(path, {
method: 'POST',
body: JSON.stringify({ body }),
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in latest push: composeInFlight flag + submit disabled for the duration of the POST; re-enabled in finally via updateComposeEnabled.

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7df2990889

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread worker/src/support-api.ts
Comment on lines +770 to +774
const body = optionalKeysObject(
await readJson(request),
['action'],
['priority'],
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in latest push: staff PATCH rejects priority unless action is change_priority, so clients cannot assume both resolve and priority applied.

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: c96c09ebd5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@FlyOverCoderKY
FlyOverCoderKY merged commit 6b92d48 into main Jul 29, 2026
2 checks passed
@FlyOverCoderKY
FlyOverCoderKY deleted the grok/buildout-task-9-staff-surfaces branch July 29, 2026 15:48
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.

2 participants