Skip to content

[Task 8] Authenticated Support Desk feedback - #29

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

FlyOverCoderKY merged 4 commits into
mainfrom
grok/buildout-task-8

Conversation

@FlyOverCoderKY

Copy link
Copy Markdown
Contributor

Summary

Implements Support Desk Buildout Task 8 (first pegma.dev host PR): authenticated customer feedback create / list / read / reply using published exact @pegma/support-desk-*@0.1.0 over D1.

Plan / phase

  • Plan: support-desk docs/BUILDOUT.md Task 8
  • Host repo: pegma.dev only
  • Out of scope: staff UI, public tickets, mail provider activation

Exit criteria checklist

  • Namespaced D1 Store (same IDENTITY_DB, Support Desk collection isolation)
  • Existing Identity / Sessions / CSRF (X-Pegma-CSRF) / rate-limit composition
  • Customer permissions for authenticated accounts (no paid entitlement)
  • Categories: feedback, bug, feature_request, documentation, question
  • [PEG-…] marker helpers + ticket URLs
  • Authenticated feedback form + own-ticket tracking pages
  • Missing / non-owned → same content-free 404
  • Independent maintenance cursors (not shared with Identity mail)
  • Health without message content (store probe gated)
  • Public-safe composition docs

Routes

Method Path
GET /api/support/categories
GET /api/support/tickets
POST /api/support/tickets
GET /api/support/tickets/:id
POST /api/support/tickets/:id/replies

UI: /feedback, /feedback/[ticketId]

Test evidence

  • npm run test:node — 141 passed (10 new support-api tests)
  • npm run test:d1 — D1 support-desk test passed
  • npm run check — clean

Residual risks

  • Mail notifications omitted until provider PR
  • Staff surface deferred
  • Full retention/export procedures still host policy before sensitive production data

Buildout Task 8 first host PR: compose published @pegma/support-desk-*@0.1.0
on D1 with Identity session CSRF, authenticated-user permission defaults,
durable create/reply rate limits, feedback pages, and independent maintenance
cursors. Staff UI and mail activation stay deferred.
Copilot AI review requested due to automatic review settings July 29, 2026 14:36
@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 — 3 issues found

Review complete. Findings are listed below.

The Support Desk host composition is structurally sound: authentication reuses the Identity session contract, customer AccessContext defaults are explicit, mutations enforce CSRF and same-origin Fetch Metadata, and missing versus non-owned tickets share a content-free 404. Storage namespace isolation, independent maintenance cursors, and gated health probing match the stated Task 8 exit criteria. Residual defects are limited to session-cookie lifecycle parity with Identity, incomplete client error handling on the ticket page, and an incorrect public tracking path in worker documentation.

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

See the review — 3 inline comments. Commit 0234452.

workflow run

Static output cannot prerender unknown ticket paths; ticket detail lives at /feedback/ticket/?id=.

@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: 63064b6e1b

ℹ️ 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 src/pages/feedback/[ticketId].astro Resolved
Comment thread src/pages/feedback/[ticketId].astro 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

Implements Support Desk Buildout Task 8 in the pegma.dev host by composing the published @pegma/support-desk-*@0.1.0 packages over the existing IDENTITY_DB D1 binding, exposing authenticated customer feedback create/list/read/reply APIs plus the corresponding /feedback UI.

Changes:

  • Added authenticated Support Desk API routes (/api/support/*) with CSRF + same-origin Fetch Metadata enforcement and durable rate limiting.
  • Added feedback UI pages (/feedback, /feedback/[ticketId]) and client scripts to create tickets, list owned tickets, and reply to owned tickets.
  • Added host-owned Support Desk maintenance (queue repair + inactive sweep + limiter sweeps) plus health detail/probe wiring and composition docs.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
worker/src/support-maintenance.ts Adds Support Desk maintenance tasks (queue repair/sweep + limiter sweeps) with independent cursors.
worker/src/support-desk.ts Defines Support Desk composition/runtime, category allowlist, marker/url helpers, and health probe.
worker/src/support-desk.d1.test.ts Adds an integration-style D1 test proving support create/list/read/reply over real D1 schema.
worker/src/support-cursors.ts Adds host-owned cursor persistence for Support Desk maintenance loops.
worker/src/support-api.ts Implements authenticated Support Desk HTTP API boundary with CSRF + rate limiting and error mapping.
worker/src/support-api.test.ts Adds unit tests covering API auth, CSRF, ownership 404 behavior, markers/URLs, and maintenance cursors.
worker/src/support-access.ts Defines AccessContext defaults granting customer permissions to authenticated principals.
worker/src/index.ts Wires Support Desk health detail/probe, API routing, and scheduled maintenance execution.
worker/README.md Documents Support Desk composition, routes, maintenance, and health probe behavior.
src/styles/global.css Extends account-form styling and adds ticket/message list styles used by feedback UI.
src/pages/feedback/[ticketId].astro Adds ticket detail page shell for viewing/replying to a single owned ticket.
src/pages/feedback.astro Adds feedback create/list page shell for authenticated product feedback.
src/pages/account.astro Adds a link from the account page to the feedback area.
src/layouts/Base.astro Adds “Feedback” to the main navigation.
public/feedback.js Client script for feedback page: session check, ticket create, and owned ticket list rendering.
public/feedback-ticket.js Client script for ticket page: load owned ticket, render messages, and send replies.
package.json Adds Support Desk and authorization-core dependencies.
package-lock.json Locks newly added dependencies to specific resolved artifacts.
docs/SUPPORT_COMPOSITION.md Adds public, host-safe composition notes for the Support Desk integration.

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

Comment thread src/styles/global.css Resolved
Comment thread worker/src/support-cursors.ts Resolved
Comment thread worker/src/support-api.ts Resolved

@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 Support Desk host composition is otherwise disciplined: session-derived principals, CSRF and same-origin gates on mutations, ownership-collapsing 404s, namespaced D1 collections, and independent maintenance cursors are correctly wired. Two defects remain at the HTTP boundary. Ticket url values point at a path that does not exist on this site, and message-body validation rejects newlines that the multi-line feedback and reply forms are designed to submit.

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

Reviewed commit cf73bf7 · workflow run

Comment thread worker/src/support-api.ts Resolved
Comment thread worker/src/support-api.ts Resolved
Allow multiline message bodies, emit publicTicketUrl in API summaries, share category list from one constant, drop unused limiter cursors, and stretch secondary links on mobile.
@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 Support Desk host composition is structurally sound: authentication reuses the Identity session contract, customer AccessContext defaults are explicit, mutations enforce CSRF and same-origin Fetch Metadata, and missing versus non-owned tickets share a content-free 404. Storage namespace isolation, independent maintenance cursors, and gated health probing match the stated Task 8 exit criteria. Residual defects are limited to session-cookie lifecycle parity with Identity, incomplete client error handling on the ticket page, and an incorrect public tracking path in worker documentation.

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

Reviewed commit 0234452 · workflow run

Comment thread worker/src/support-api.ts
if (mapped.retryAfterSeconds !== undefined) {
headers['Retry-After'] = String(mapped.retryAfterSeconds);
}
return json(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ [warning] Invalidated sessions do not clear the Host session cookie

Identity's API clears __Host-pegma_session on InvalidatedSessionError via Set-Cookie Max-Age=0. Support mirrors the same authenticate/invalidateSession path (destroy server-side session when data is corrupt, principal mismatch, or the account is inactive/unverified) but the error response at this catch only returns { error } with no cookie expiry. After server-side destruction, the browser continues to present a dead credential on subsequent Support calls until an Identity route performs the clear. That breaks session-lifecycle parity across /api/* and leaves a sticky 401 state for Support-only clients.

Suggestion: Match identity-api: on InvalidatedSessionError, append Set-Cookie: __Host-pegma_session=; Path=/; Max-Age=0; Secure; HttpOnly; SameSite=Strict (extend the local json() helper or share a clearSessionCookie utility).

Comment thread public/feedback-ticket.js
showStatus('Sign in to view this ticket.');
return;
}
throw error;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ [warning] Non-401 identity failures abort loadTicket without UI recovery

loadTicket() preflights /api/identity/account and rethrows any error that is not status 401. loadTicket() is invoked without a rejection handler. Identity runtime unavailability (503), network failure, or non-JSON responses therefore become unhandled promise rejections while the page remains on "Loading ticket…". The list page (feedback.js) handles the same class of failure with a user-visible status message; the ticket page does not.

Suggestion: In the identity preflight catch, treat non-401 failures the same way as the ticket-load catch: set detail hidden, call showStatus with a clear unavailable message, and return. Do not rethrow.

Comment thread worker/README.md
session rows. Customer permissions are granted to any authenticated account
via AccessContext defaults (not a paid entitlement). Categories:
`feedback`, `bug`, `feature_request`, `documentation`, `question`. Subject
marker: `[PEG-…]`. Tracking pages: `/feedback` and `/feedback/{ticketId}`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤏 [nit] Documented ticket tracking path does not exist

The Support Desk section states tracking pages are /feedback and /feedback/{ticketId}. There is no dynamic /feedback/{ticketId} route. The implemented shell is /feedback/ticket/?id={ticketId}, which is what publicTicketUrl(), feedback.js links, and docs/SUPPORT_COMPOSITION.md already emit. Operators or agents following the Worker README will request a path that 404s.

Suggestion: Replace /feedback/{ticketId} with /feedback/ticket/?id={ticketId} so the README matches the live static route and publicTicketUrl().

@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: 0234452b1c

ℹ️ 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 public/feedback-ticket.js
showStatus('Sign in to view this ticket.');
return;
}
throw error;

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 Handle identity preflight failures inside the ticket page

When /api/identity/account returns anything other than 401, or its fetch/JSON parsing fails, this rethrow escapes loadTicket(), which is invoked without awaiting or catching its promise. The page consequently remains stuck on “Loading ticket…” with an unhandled rejection instead of showing an availability error; handle these failures here or wrap the entire load flow in the existing status-rendering catch.

Useful? React with 👍 / 👎.

Comment thread public/feedback.js
}),
});
createForm.reset();
await refreshTickets();

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 Separate ticket creation success from list refresh failure

If the POST succeeds but this follow-up list request fails, the shared catch reports “Could not create ticket” even though the ticket was already committed. A user who retries can therefore create duplicate feedback tickets; preserve and report the successful creation independently, then handle a refresh failure as a separate list-loading error.

Useful? React with 👍 / 👎.

@FlyOverCoderKY
FlyOverCoderKY merged commit 60427ac into main Jul 29, 2026
2 checks passed
@FlyOverCoderKY
FlyOverCoderKY deleted the grok/buildout-task-8 branch July 29, 2026 14:57
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