Skip to content

Refactor codebase for improved structure and shared logic - #7

Merged
ZeroElemental merged 9 commits into
mainfrom
dev
Sep 3, 2026
Merged

ZeroElemental merged 9 commits into
mainfrom
dev

Conversation

@ZeroElemental

Copy link
Copy Markdown
Owner

No description provided.

`eslint .` descended into .claude/worktrees/*/.next and reported 30,161
problems from generated chunks, burying every real one. The existing ignore
globs are root-anchored, so they never matched the nested copies.
The 3-24 character rule was written out five times: twice in validation.ts
as an identical regex and message, and three more as HTML pattern attributes.
signUpSchema now reuses usernameSchema, and USERNAME_PATTERN feeds the three
inputs, so the rule has one definition to change.
The select, its two filters and the flattening of the joined profile row were
written out identically on the server (chat page) and in the browser (realtime
refresh). fetchPendingRequests takes whichever Supabase client the caller
already holds, so both sides run the same query.
The avatar/image/initial-fallback block was copied at four call sites, varying
only in size classes. One component now covers all four.
The avatar and attachment pickers ran the same size-then-type sequence with
the same comment above it, differing only in limits and wording. Those now
live beside the limits they enforce, as ATTACHMENT_RULE and AVATAR_RULE.
Channel bookkeeping -- setAuth, per-conversation subscribe, presence, teardown
-- was ~150 lines in the middle of a component that also renders a sidebar.
useConversationChannels and useFriendNotifications now own it.

Two things fall out. setTyping takes a conversation id, so the shell no longer
reaches through a channel map to call track() on an object it should not know
about. And the handlers are held in refs updated after commit, so the
subscription depends only on the client, the user and the conversation ids;
previously a handler identity change could rebuild every channel.
The sidebar list was inline markup with no logic of its own. Moving it leaves
chat-shell reading as state, actions, layout.
It still described login/signup at the app root and predated the site pages.
Adds the conventions a new file has to follow to stay consistent.
The paperclip opened the OS dialog straight away with every permitted type at
once, so the list mixed photos, PDFs and zips and nothing said what was allowed
until an upload was rejected.

It now opens a popover -- Photo, Document, Archive -- and the choice narrows the
input's accept before the dialog opens. The groups are the source ATTACHMENT_MIME
is flattened from, so the allowlist and the bucket's stay one list. accept is only
a hint, so checkFile is still the gate.

The attribute is set on the node rather than through state: React would not flush
a re-render before .click(), and the dialog would open with the last filter.
@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
pixel-chat Ready Ready Preview Sep 3, 2026 3:30pm UTC

@ZeroElemental
ZeroElemental merged commit 1166420 into main Sep 3, 2026
4 checks passed

This branch was successfully deployed

1 active deployment
Preview — 15a389b3 Deployed Sep 2, 2026 by vercel[bot]
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