8000 refactor(web): resolve admin scope to an Office; share status page and response helpers by geminixiang · Pull Request #199 · geminixiang/mikan · GitHub
[go: up one dir, main page]

Skip to content

refactor(web): resolve admin scope to an Office; share status page and response helpers - #199

Merged
geminixiang merged 3 commits into
mainfrom
refactor/simplify-web-portals
Oct 26, 2026
Merged

geminixiang merged 3 commits into
mainfrom
refactor/simplify-web-portals

Conversation

@geminixiang
Copy link
Copy Markdown
Owner

Stage 5 of docs/research/simplify-modules-2026-10.md (#196). 7 files, +277 / −202; production code +201 / −190, so this does not shrink the code as the survey estimated (~90 lines). It removes concepts rather than lines: the formatter splits each htmlResponse(...) call over several lines.

Change Note
Admin: officeFromQuery / officeFromBody return Office | undefined at all 16 call sites Removes AdminConversationScope and three resolvers
One renderStatusPage in portal-shell.ts for login, Session View, and admin Shared CSS moved to the shell
Login: 26 hand-written responses go through jsonResponse / a new htmlResponse; oauthStates uses InMemoryTokenStore Same random key, expiry, single use, and purge

Visible and header changes

  • /link, /api/link/complete, /api/oauth/start, /oauth/callback now send Cache-Control: no-store; JSON responses add charset=utf-8. A new test asserts both and fails on main.
  • Admin "Access Denied": left-aligned instead of centred, default card padding, and the message box loses its border (0.88rem → 0.9rem).
  • Session View error page: eyebrow uses PRODUCT_NAME (still "mikan"); no longer ships the session inline script.
  • Login pages: unchanged.

Verification

Check main branch
npm run typecheck pass pass
npm test 2033 passed 2034 passed (+1 header test)
npm run duplication 1 clone 1 clone (unchanged)

Outside the Slack message path (Admin portal), so done when CI passes. Draft pending a decision on whether the admin visual change and the line-count result are acceptable.

@geminixiang
geminixiang marked this pull request as ready for review October 26, 2026 09:31
@geminixiang
geminixiang force-pushed the refactor/simplify-web-portals branch from dd8568d to a534d97 Compare October 26, 2026 10:49
…page

Admin handlers take the office from officeFromQuery/officeFromBody, which
answer 403 themselves, replacing AdminConversationScope,
resolveConversationScope and scopedOffice.

Login, Session View and the admin access-denied page render through
portal-shell's renderStatusPage. Session View's eyebrow uses PRODUCT_NAME;
the admin access-denied page takes the shared card layout instead of its
centered inline-styled card.
The login portal answers through portal-shell's jsonResponse and a new
htmlResponse instead of hand-written writeHead/end pairs, and keeps
pending OAuth states in an InMemoryTokenStore, whose random 16-byte key,
expiry check and delete-before-check consume match the Map it replaces.

Behavior change: every /link, /api/link/complete, /api/oauth/start and
/oauth/callback response now carries Cache-Control: no-store, and JSON
responses declare charset=utf-8. A test asserts both headers.
@geminixiang
geminixiang force-pushed the refactor/simplify-web-portals branch from a534d97 to 6231a23 Compare October 26, 2026 10:53
@geminixiang
geminixiang merged commit 4f0312d into main Oct 26, 2026
5 checks passed
@geminixiang
geminixiang deleted the refactor/simplify-web-portals branch October 26, 2026 10:56
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

0