refactor: ponytail dead-code cleanup (frontend + server, ~-1060 lines) #1

Open
1337hero wants to merge 2 commits from refactor/ponytail-deadcode-cleanup into main
Owner

Over-engineering audit + cleanup across the whole app. Pure refactor — no behavior changes, no deps added or removed.

Results

52 files · +160 / −1223 (~−1060 net) · 11 files deleted · 0 deps

  • Frontend: 26/26 tests pass, build clean
  • Server: 403/403 tests pass, build clean

Frontend (refactor(frontend))

  • Delete 7 unused components (BranchNavigator, KnowledgeBaseSelector, Avatar, Radio, dropdown, text, textarea) + dead button color palette (24→4 colors)
  • Drop dead hooks/clients/state (useDeleteMessageMutation, useUnarchiveChatMutation, useImageStatus, formatDate, dead auth/ui actions, Settings placeholders)
  • Replace hand-rolled Modal (focus-trap/Esc/scroll-lock/portal) with Headless UI Dialog (already a dep); fix MoveToFolderModal double-portal
  • ModelsTab focus useEffect → ref callback
  • Extract FormError / ModalActions / RoleSelect shared across 6 admin modals
  • Fix color=plain typo → plain prop; remove dead autoScroll state

Server + shared (refactor(server))

  • Delete 14 unused db functions (chats/files/models/providers/folders)
  • Delete optionalAuth middleware (+ its test), dead shared types/*.js + search.js, getOfficial/getOpenAICompatibleProviders, stopModelsDevTimers, getCachedDatabase, isOfficeLegacyAttachment + dead office re-export
  • Collapse pin/unpin/archive/unarchive → one setChatFlag helper; drop chatStateHandler thunk, dead /:chatId/stream route, 2 dead HTTP_STATUS members, Ollama-pull debug scaffolding
  • Hoist coerceModelForProvider (4×→1×), privatize memory.js internals
  • Drop redundant inner import try/catch and manual content-length check (covered by outer catch / bodyLimit)

Intentionally preserved (not dead / not equivalent)

  • DB migrations 002 & 004 — deleting applied migrations corrupts the ledger on deployed DBs
  • import.js outer catches + /validate catch — distinct error contracts the global handler does not replicate
  • keyFn param, test-only db trio, generateEncryptionKey — each backed by a real test
  • HTTP_STATUS→literals, image-size dep — churn/dep cost over value
Over-engineering audit + cleanup across the whole app. Pure refactor — no behavior changes, no deps added or removed. ## Results **52 files · +160 / −1223 (~−1060 net) · 11 files deleted · 0 deps** - Frontend: 26/26 tests pass, build clean - Server: 403/403 tests pass, build clean ## Frontend (`refactor(frontend)`) - Delete 7 unused components (BranchNavigator, KnowledgeBaseSelector, Avatar, Radio, dropdown, text, textarea) + dead button color palette (24→4 colors) - Drop dead hooks/clients/state (useDeleteMessageMutation, useUnarchiveChatMutation, useImageStatus, formatDate, dead auth/ui actions, Settings placeholders) - Replace hand-rolled Modal (focus-trap/Esc/scroll-lock/portal) with Headless UI Dialog (already a dep); fix MoveToFolderModal double-portal - ModelsTab focus useEffect → ref callback - Extract FormError / ModalActions / RoleSelect shared across 6 admin modals - Fix color=plain typo → plain prop; remove dead autoScroll state ## Server + shared (`refactor(server)`) - Delete 14 unused db functions (chats/files/models/providers/folders) - Delete optionalAuth middleware (+ its test), dead shared types/*.js + search.js, getOfficial/getOpenAICompatibleProviders, stopModelsDevTimers, getCachedDatabase, isOfficeLegacyAttachment + dead office re-export - Collapse pin/unpin/archive/unarchive → one setChatFlag helper; drop chatStateHandler thunk, dead /:chatId/stream route, 2 dead HTTP_STATUS members, Ollama-pull debug scaffolding - Hoist coerceModelForProvider (4×→1×), privatize memory.js internals - Drop redundant inner import try/catch and manual content-length check (covered by outer catch / bodyLimit) ## Intentionally preserved (not dead / not equivalent) - DB migrations 002 & 004 — deleting applied migrations corrupts the ledger on deployed DBs - import.js outer catches + /validate catch — distinct error contracts the global handler does not replicate - keyFn param, test-only db trio, generateEncryptionKey — each backed by a real test - HTTP_STATUS→literals, image-size dep — churn/dep cost over value
Squash-graft of PR #16 (improvements/attachments) onto main. The original
branch shared no git ancestor with main (severed history from a re-init),
so it could not be reopened/merged directly. Fork point e5a033d had a tree
identical to main's tip, so this commit replays exactly the 15 attachment
commits with no regression to main.
Re-lands the work from #16, which could not be reopened/merged because
its branch shared **no common git history with main** (severed by a
re-init — two separate `feat: init` roots, empty merge-base).

Recovery: the branch's fork-point commit `e5a033d` has a tree
**identical to main's current tip**, proving the branch = main's content
+ attachments commits stacked on top. This PR is a single squash whose
tree exactly matches the original branch tip — so it adds the full
attachments feature with **zero regression** to main's 120 exclusive
commits.

Closes #16 (superseded; original unmergeable due to history split).

### Included
- Message-files junction table + migrations
- Drag-and-drop upload area
- Attachment security & data-integrity fixes
- Python test suite ported to Bun (accounts for the large deletions)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Over-engineering cleanup (ponytail audit):
- Delete 7 unused files (BranchNavigator, KnowledgeBaseSelector, Avatar,
  Radio, dropdown, text, textarea) + dead button color palette (24->4)
- Drop dead hooks/clients/state: useDeleteMessageMutation,
  useUnarchiveChatMutation, useImageStatus, formatDate, auth/ui dead actions
- Replace hand-rolled Modal (focus-trap/Esc/scroll-lock/portal) with
  Headless UI Dialog; fix MoveToFolderModal double-portal
- ModelsTab focus effect -> ref callback
- Extract FormError/ModalActions/RoleSelect shared by 6 admin modals
- Fix color="plain" typo -> plain prop; remove dead autoScroll state
refactor(server): remove dead db helpers, exports, and redundant guards
Some checks failed
CI / format-check (pull_request) Has been cancelled
CI / build-frontend (pull_request) Has been cancelled
CI / build-server (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
Auto Label PRs / label (pull_request) Has been cancelled
ca6f6e0114
Over-engineering cleanup (ponytail audit):
- Delete 14 unused db functions (chats/files/models/providers/folders)
- Delete optionalAuth middleware (+ its test), dead shared types/*.js and
  search.js, getOfficial/getOpenAICompatibleProviders, stopModelsDevTimers,
  getCachedDatabase, isOfficeLegacyAttachment + dead office re-export
- Collapse pin/unpin/archive/unarchive into one setChatFlag helper
- Remove chatStateHandler thunk, dead /:chatId/stream route, 2 dead
  HTTP_STATUS members, Ollama-pull debug scaffolding
- Hoist coerceModelForProvider (4x->1x), privatize memory.js internals
- Drop redundant inner import try/catch and manual content-length check
  (covered by outer catch / bodyLimit)

Migrations and distinct error-response contracts intentionally preserved.
Some checks failed
CI / format-check (pull_request) Has been cancelled
CI / build-frontend (pull_request) Has been cancelled
CI / build-server (pull_request) Has been cancelled
CI / test (pull_request) Has been cancelled
Auto Label PRs / label (pull_request) Has been cancelled
This pull request has changes conflicting with the target branch.
  • server/src/index.js
  • server/src/lib/db/chats.js
  • server/src/lib/db/files.js
  • server/src/lib/fileUtils.js
  • server/src/routes/chats.js
  • server/src/routes/import.js
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin refactor/ponytail-deadcode-cleanup:refactor/ponytail-deadcode-cleanup
git switch refactor/ponytail-deadcode-cleanup

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff refactor/ponytail-deadcode-cleanup
git switch refactor/ponytail-deadcode-cleanup
git rebase main
git switch main
git merge --ff-only refactor/ponytail-deadcode-cleanup
git switch refactor/ponytail-deadcode-cleanup
git rebase main
git switch main
git merge --no-ff refactor/ponytail-deadcode-cleanup
git switch main
git merge --squash refactor/ponytail-deadcode-cleanup
git switch main
git merge --ff-only refactor/ponytail-deadcode-cleanup
git switch main
git merge refactor/ponytail-deadcode-cleanup
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
1337hero/faster-chat!1
No description provided.