Skip to content

chore: run the m1 code audit - #54

Merged
kixelated merged 8 commits into
mainfrom
quest/m1/audit-code
Nov 26, 2026
Merged

kixelated merged 8 commits into
mainfrom
quest/m1/audit-code

Conversation

@kixelated

@kixelated kixelated commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

This is the first run of the code audit (quest/m1/audit-code.md), checked against main after #47–#52.

Problem

api/ and app/ (about 18k lines) held dead code, overbuilt helpers, stale config from before Tauri was removed, and one lint suppression with no reason given. A Knip pass plus a read of every area turned up the following.

Approach

Dead code deleted

  • API: OAuth.Context.getLinks and the Row/NewRow types, the unused loginSchema/loginResponseSchema/Login/LoginResponse, the idSchema alias, the default export in database.ts, the unused expiresIn parameter on Auth.create (now a named SESSION_LIFETIME), and a redundant Apple-only guard.
  • Room: the Bounds.create/dom/mult/div/clone/lerp and Vector.clone/lerp methods, ChatMessage, ALL_EMOJIS, PreviewInfo, and FakeBroadcast.enabled. Also the TTS worker's quality switching (only "high" ever reached it) plus detectWebGPU, ready, supportsHigh, resume, and the voice/speed options. Also the TTSProps, SoundProps.tts, and AudioProps.pan props, the unread hovering render modifier, dead ?? 1 scale fallbacks, the optional PannedSound.analyser (it is always created), the unreachable % branch in the meme position parser, and chat.message.enabled/chat.typing.enabled (never false or never read), along with their guards in controls.tsx and meme-selector.tsx.
  • App: Badge.get, the Login error prop, the PreviewRoom name prop, FavoriteRoom createdAt, the "chat" mobile section and chatRef, the #support divs, unused CSS (.controls, .pointer-gaps, .potato), Tooltip's unused left/right placements, the dev-only duplicate check in random.ts, the duplicate named Settings export, and the vite-env.d.ts entries that vite/client already declares.
  • Exports used only inside their own file are no longer exported (LoginPage, Visualize, supportsWebGPU, Textures, LocationValue, ChatValue, appleName, callbackSchema, ROOM_NAME_REGEX, the test Bucket).

Simplified

  • metadata.ts now takes TRACK, PRIORITY, HangCatalog, and TrackRef from @moq/room instead of keeping local copies, and builds RequestSchema from PositionSchema's shape.
  • Account.Context reads the avatar columns through one #avatar(id) helper instead of three copies. api.ts builds Hono routes in one routes(token) helper. TTS join and leave announcements share pick(). space.ts handles mouseup and mouseleave with one handler. Both audio.ts and sound.ts use the one FADE_TIME constant from sound.ts. meme.load drops a fallback that could never match, and matches only the lookup tables' own keys (Object.hasOwn), so a peer's /constructor stays plain chat.

Config and recipes

  • Deleted: biome.jsonc noTsIgnore: off (no @ts-ignore remains), .rustfmt.toml (no Rust remains), app/tailwind.config.js (Tailwind v4 never loads it), the vscode-pnpm recommendation, the app upgrade/bundle recipes and dev script, and the deprecated devShell flake output.
  • Kept useMediaCaption: off, now with its reason. Replaced the useAltText: no suppression in icons.tsx with real alt text.
  • Renamed just api fix to just api types, since it regenerates worker-configuration.d.ts. Fixed stale comments: "Cloudflare Pages", APPLE_PRIVATE_KEY (the code reads APPLE_CLIENT_SECRET), the @hang/api package description ("tRPC"), and leftover TODOs.
  • app/package.json build now passes --mode live. Without a mode, just build (what CI runs) built in production mode with every VITE_* variable undefined.
  • Dropped the dev server's CORS and Range headers. The app loads memes from its own origin, and Vite serves Range requests by itself.

Bug fixed (reproduced first)

  • A watched tile started with a random location handle, so it looked movable and published moves keyed to a handle no peer had, until its location track arrived. locationFields() now starts the handle unset. The local and fake sources already set their own. New test: a watched window stays locked until its location arrives.

Left to sibling PRs, to avoid conflicts

Kept on purpose (recorded in the next stub):

  • Settings.captions and the commented-out ClosedCaptions, which captions-ai-voice re-enables.
  • The noStaticElementInteractions suppression on the tooltip wrapper.
  • The generated worker-configuration.d.ts.

Merged main (after #53, #56, #67): auth.ts keeps both SESSION_LIFETIME and #53's GUEST_TYPE. Deleting app/tailwind.config.js hid @iconify-json/material-symbols and @iconify-json/mdi from #56's fallow gate, which only saw them through that file's dynamic imports. @iconify/tailwind4 in app/index.css loads them by name from icon-[set--name] classes, so .fallowrc.jsonc now lists them under ignoreDependencies.

Next run: deleted quest/m1/audit-code.md and planned quest/m2/audit-code.md (requires m1, scheduled 2026-12-02) with the baseline, the excluded scope, and what to check first.

Impact

  • Public API and wire: none. @hang/api is private to this repo, and every removed export had no consumer.
  • Behavior: remote tiles stay locked until their location arrives (the bug above). just build now builds what deploy ships.
  • Dev: the just api fix recipe is now just api types, and the app's bun run dev script is gone (just app dev is the entry point).

Alternatives

  • Knip as a dead-code gate. I first added Knip to just check: it takes about 1 s and failed on a planted dead export. I dropped it once I saw chore(deps): patch advisories, drop unused dependencies, gate them with fallow #56 adds fallow, moq's tool. Two analyzers would overlap, so widening fallow to files and exports is the follow-up instead.
  • Doing the remaining duplicate-helper merges here. They touch most room files and would make this diff hard to review, so they are a follow-up quest.

Choices made without asking

  • Narrowed Tooltip to top/bottom: all 18 call sites use those.
  • Removed the dev-server CORS headers (Tauri-era).
  • Deleted the runtime duplicate check in random.ts instead of moving it to a test: a duplicated word only skews odds.
  • Declined the reported canvas.ts loseContext "stale context" issue: a canvas returns the same WebGL2RenderingContext across loss and restore.

Decisions

  • 2026-11-26 (maintainer, /quest-run, comment): ✅ /quest-merge this PR (rejected: iterate, skip).
  • Keep dead-code-gate, dedupe-room-helpers, and prune-dev-icons-and-assets as follow-ups.
  • prune-dev-icons-and-assets: ✅ (a) delete the /dev/icons generator, icons.tsx and jszip (rejected: (b) keep only the favicon and Discord banner, (c) keep it); ✅ (a) delete every unreferenced app/public file (rejected: (b) only the commented-out memes and sounds, (c) keep them). Recorded in the quest's Plan.

Caused by

  • moq-dev/hang.live#28 - gave watched and published location fields the same random-handle default, so remote tiles looked movable before their location arrived (found by reviewer, this audit).

Follow-ups

Validation

  • quest gate just check passes: quest check, TypeScript, Biome, 39 API tests, 59 app tests (including the new handle test and a meme.load test for inherited keys such as /constructor, each failing without its fix), and 2 Chromium media tests against a local relay. quest gate just build passes, and the bundle now embeds the api.hang.live URLs.
  • Real surface: ran the full stack (relay, auth, API, Vite) on offset ports, since another session held the defaults. Joined a room as a guest (POST /room/…/join 200). The meme selector tooltip sits above its button, with the arrow on the button's center (361 px). Dragging my tile set grabbing, and releasing reset the cursor. meme.load resolves another-one, AnotherOne, and anotherone, and rejects unknown names. No page errors. Chrome didn't run requestAnimationFrame in the shared window, so I patched it to a 16 ms timer for the tooltip and drag checks.
  • After merging main: quest gate just check (now with fallow) and quest gate just build pass; just build still compiles the iconify classes. Review round 1 then caught two audit deletions that were wrong, both restored: Tailwind 4.3 does ship the scrollbar-* utilities the room preview list used (Firefox lost its thin bar), and app/wrangler.jsonc dev.port keeps a wrangler dev preview on the one origin the local API allows.
  • Did not run: high-quality (WebGPU) TTS.

Models

  • Size: L
  • Implementer: Claude Code, claude-opus-5-5, high
  • Implementer: Claude Code, claude-opus-5-5, medium effort (iterate, S)

🤖 Generated with Claude Code

(Written by Claude Opus 5.5 with medium)

Review

Rewritten by quest review after each round.

  • Head: d1075b8

  • Base: origin/main at 2b42a80

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

  • Reviewer: Codex, gpt-6.2-sol, xhigh effort

  • Session: 01a21955-f033-7950-8333-69bd491dbbd2, round 3

  • Score: 10/10, The local Worker preview works with the local API again, and the head is ready to land.

  • Rounds: 3; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0

  • Findings: none

  • The last round's findings, at c11147b:

    • Fixed: medium, app/wrangler.jsonc:12: Keep the local Worker preview on port 1420; `app/wrangler.jsonc:16` restores `dev.port` to 1420, matching the development build’s app URL (`app/.env.development:2`) and the local API’s allowed origin (`api/wrangler.jsonc:42`, `api/src/rpc.ts:23`).

kixelated and others added 3 commits November 25, 2026 22:46
Quest-Claim: 2e6e398a0d06b03e
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Audit the code chore: run the m1 code audit Nov 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 26, 2026 07:12
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1765849d-6171-498a-a1f9-5da410798fce
Commits

Reviewing files that changed from the base of the PR and between c3af25a and 6177c60.

Files selected for processing: 59

  • .fallowrc.jsonc
  • .rustfmt.toml
  • .vscode/extensions.json
  • api/justfile
  • api/package.json
  • api/src/account.ts
  • api/src/auth.ts
  • api/src/client.ts
  • api/src/database.ts
  • api/src/oauth.ts
  • api/src/rpc.ts
  • api/test/harness.ts
  • api/tsconfig.json
  • api/wrangler.jsonc
  • app/index.css
  • app/justfile
  • app/package.json
  • app/src/account.tsx
  • app/src/api.ts
  • app/src/components/badge.ts
  • app/src/components/login.tsx
  • app/src/components/meme-selector.tsx
  • app/src/components/tooltip.tsx
  • app/src/controls.tsx
  • app/src/home.tsx
  • app/src/icons.tsx
  • app/src/layout/app.tsx
  • app/src/layout/web.tsx
  • app/src/preview.tsx
  • app/src/room/audio.ts
  • app/src/room/broadcast.ts
  • app/src/room/fake.ts
  • app/src/room/geometry.ts
  • app/src/room/gl/broadcast.ts
  • app/src/room/meme.test.ts
  • app/src/room/meme.ts
  • app/src/room/metadata.test.ts
  • app/src/room/metadata.ts
  • app/src/room/physics.test.ts
  • app/src/room/sound.ts
  • app/src/room/space.ts
  • app/src/room/tts/index.ts
  • app/src/room/tts/kokoro.ts
  • app/src/room/tts/worker.ts
  • app/src/room/video.ts
  • app/src/settings.test.ts
  • app/src/settings.tsx
  • app/src/util/random.ts
  • app/src/vite-env.d.ts
  • app/tailwind.config.js
  • app/vite.config.ts
  • app/wrangler.jsonc
  • biome.jsonc
  • flake.nix
  • quest/m1/audit-code.md
  • quest/m1/dead-code-gate.md
  • quest/m1/dedupe-room-helpers.md
  • quest/m1/prune-dev-icons-and-assets.md
  • quest/m2/audit-code.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@kixelated

Copy link
Copy Markdown
Collaborator Author

Maintainer decision (via /quest-run): ✅ /quest-merge this PR (rejected: iterate, skip).

Follow-ups:

  • quest/m1/dead-code-gate.md: ✅ keep (rejected: drop).
  • quest/m1/dedupe-room-helpers.md: ✅ keep (rejected: drop).
  • quest/m1/prune-dev-icons-and-assets.md: ✅ keep (rejected: drop).
    • /dev/icons generator: ✅ (a) delete icons.tsx and jszip (rejected: (b) keep only favicon and Discord banner, (c) keep it).
    • Unreferenced app/public files: ✅ (a) delete them all (rejected: (b) only the commented-out memes and sounds, (c) keep them).

(Written by Claude Opus 5.5)

kixelated and others added 3 commits November 26, 2026 11:15
Resolve the auth.ts conflict by keeping both SESSION_LIFETIME and #53's
GUEST_TYPE. Deleting app/tailwind.config.js hid the iconify icon sets from
#56's fallow gate, so .fallowrc.jsonc now names them: @iconify/tailwind4
loads them by name from icon classes. Record the maintainer's answers on
prune-dev-icons-and-assets and clear dead-code-gate's wait on #56.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tailwind 4.3 ships scrollbar-thin and scrollbar-thumb/track utilities, so
the WebKit-only custom-scrollbar class dropped Firefox's thin, themed bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The local API allows only the http://localhost:1420 origin, so a
wrangler dev preview of a development build needs that port.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated merged commit 3843371 into main Nov 26, 2026
2 checks passed
@kixelated
kixelated deleted the quest/m1/audit-code branch November 26, 2026 20:34
kixelated added a commit that referenced this pull request Nov 26, 2026
Main's code audit (#54) dropped the export because nothing imported it,
but this branch's test page patches Textures.prototype.upload to read
which frame each tile drew.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated added a commit that referenced this pull request Nov 26, 2026
Main dropped Bounds.create in the code audit (#54).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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