Skip to content

refactor: split oversized modules and enforce anti-slop lint - #343

Merged
leoisadev1 merged 392 commits into
mainfrom
t3code/codebase-anti-slop-cleanup
Oct 2, 2026
Merged

leoisadev1 merged 392 commits into
mainfrom
t3code/codebase-anti-slop-cleanup

Conversation

@leoisadev1

@leoisadev1 leoisadev1 commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Problem

The codebase had grown 158 TypeScript files past 800 lines, hundreds of rule-evading escapes (431 as unknown as, 291 @effect-diagnostics directives, 32 @ts-* directives, 27 lint disables), and no lint guard to stop new slop or raw palette colors from coming back.

What changed

  • Split oversized modules along real seams (components, services, test fixture groups). On the main source tree, files over 800 lines went from 158 to 22 by raw line count, and every file now passes the max-lines lint rule, which counts code lines. The two generated protocol schemas are untouched.
  • Removed the escapes instead of moving them: 0 as unknown as, 0 @ts-* directives and 0 @effect-diagnostics directives remain in source. The few remaining lint-disable hits are generated files (routeTree.gen.ts, mockServiceWorker.js) and the suppression scanner's own pattern.
  • Typed untrusted boundaries with schemas, used Effect services such as Path, FileSystem and Clock instead of ambient APIs, and moved shared work-log and usage parsing into client-runtime for web and mobile.
  • Vendored oxlint-plugin-anti-slop, added shadcn lint and an Akeru plugin (no raw palette strings, no lint suppressions, no module mocking), and made the satisfied rules errors. scripts/check-lint-suppressions.ts runs in CI.
  • Replaced raw palette classes with semantic theme tokens. Default light and dark themes resolve to the same computed colors, borders and animations as before; new tokens were added where no existing one matched.
  • Removed dependencies with no remaining consumers and updated AGENTS.md and docs/internals/lint.md.

About 250k of the added and removed lines are moved code (the same line deleted in one file and added in another). The genuinely new or changed content is roughly 67k added and 24k removed, mostly import headers in split files, tests, and the vendored lint plugin.

Behavior changes included

These are real fixes rather than mechanical cleanup. Each has a focused test and its own changeset:

  • Migration 023 propagates real failures and matches existing columns case-insensitively, as SQLite does.
  • Positional SQLite queries honor SafeIntegers.
  • The orchestration engine hydrates persisted command state, and failed dispatches clean up uploads on defects and interruption, not just typed failures.
  • A new-chat bootstrap that fails, dies or is cancelled after creating its thread deletes that thread exactly once.
  • Subscription credential access and refresh reload health state again.
  • OAuth completion ownership, bounded image reads, Browserbase validation, Unicode payload bounds, legacy plan compatibility and bounded tool inspection.

Review

The branch went through several rounds of independent per-slice review (27 slices, then a second pass on the approved ones, then re-reviews of every fix commit) until each reviewer approved. Restoring lost behavior covered null handling in bot tool inputs, markdown prop forwarding on mobile, the Alert fragment crash, skeleton, shimmer and splash animations, thread ordering by parsed time, and eight default-theme color drifts.

For local review, git diff --color-moved=dimmed-zebra origin/main... separates moved code from changed code.

Verification

  • tsgo reports 0 errors and 0 Effect diagnostics for server, web, desktop, contracts, shared and client-runtime. Mobile reports the same 33 route-typing errors that exist on main.
  • scripts/check-lint-suppressions.ts passes, and lint and format are clean on touched files.
  • Focused tests for every fix pass.

Not covered

  • No before and after screenshots. The visual goal was exact parity in the default themes, and the reviews checked it by comparing token values, not in a browser.
  • Repository-wide tests run only in CI.
  • Two model-switch cases in orchestrationEngine.integration.test.ts fail on main as well and are unchanged here.

Created with Claude Opus 5.5 and GPT-6.1 Sol in Claude Code.

🤖 Generated with Claude Code


Devin Review

leoisadev1 and others added 30 commits October 1, 2026 01:33
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split payload bounding and retention by responsibility, preserve delimiters as source escapes, and retain tool updates with one completion lookup per identity.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
…ilities

Keep the existing module entry points, share the session settlement rule, and extract projection test cases and fixtures by behavior. Remove attachment materialization effects that only return decoded attachments.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
…d modules

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The memory approval reuses the composer's surface constant, the docked approval and
question panels share one shape constant, the approval dot uses bg-warning, attachment
tiles use border-border, and the channel warning label uses text-warning-foreground.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
useBotThreadRuntime and useGroupThreadRuntime carried identical threadTitle,
readFileAsDataUrl, and attachment-reading code. Both now import them from
threadRuntimeAttachments.ts, which has focused tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…runtimes

useThreadPendingUserInput owns the answer drafts, question index, and responding
request ids both runtime hooks carried in duplicate. groupModelSelection moves to
groupThreadModel.logic.ts. Bot and group send lifecycles stay separate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e logic tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…w out of BotThreadLanding

useBotLandingTimeline owns routine run paging, receipt projection, delegations, and
the merged timeline order. RoutineReceiptRow gets its own module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…modules

BotSettingsForm owns the draft, save bar, and sheets. BotIdentityFields and
BotEngineFields render the Identity and Model & usage sections from the draft.
Source-contract tests read all four modules, and the shallow render tests expand
the section leaves through a shared test-support helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move snapshot history and lookup coverage into independent suites with shared fixtures. Keep command, telemetry, transaction, and restart engine coverage separate.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
…utton variants

Adds avatar-edit, avatar-tile, default-muted-disabled, ghost-destructive, and
outline-pill-muted variants plus an avatar size to ui/button, carrying the classes the
call sites passed. The bot settings avatar action and new-bot shape tiles become
Buttons; aria-pressed drives the tile's chosen state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nto ui/sheet

SheetHeader, SheetTitle, and SheetPanel gain a compact variant carrying the classes
BotSideSheet passed, and EmptyTitle gains a body variant for its sans medium title.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The BotSettingsPage split moved BotModelPicker and TraitsPicker into BotEngineFields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lity out of BotChatMessageRows

BotChatMessageRows keeps the memoized assistant and user rows and re-exports the moved
symbols. BotMessageAttachments uses the exact scale values for its arbitrary sizes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep bot settings and compatibility coverage at the existing test entry point and extract ownership cases with reusable fixtures.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
…est fixtures

Compose reactor services from owned state and focused delivery, ingestion, checkpoint, and recovery helpers. Decode typed fixture events at publication, subscribe before triggers, and await observations or receipts instead of polling.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
Run owned-path lint autofixes and formatting. The diff is empty with git diff --ignore-all-space --ignore-blank-lines; all changes are whitespace-only.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
… modules

DesktopOnboarding.tsx keeps gating, draft recovery, and the durable handoff
resume; the subscription and identity steps and the overlay surface move to
their own files. desktopOnboarding.logic.ts and goalPlan.logic.ts split into
draft, engine, handoff, data, and classification modules with re-exports at
the old paths, and the translator moves to a leaf to break the import cycle.

Also uses success tokens for the connected check, a Button onboarding size
for the tall rounded actions, classes instead of inline pointer-events, and
exact scale values for the overlay width and z-index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VoiceCallProvider keeps connection, microphone, and teardown ownership at
VoiceCall.tsx, which re-exports the moved helpers, hooks, and views so its
importers and module mocks are unchanged. The hang-up button selects a new
icon-sm-round Button size instead of restyling the primitive.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The search field, filter bar, page header, and dialog/page directory layout
move to PluginDirectoryLayout.tsx, the catalog constants to
pluginDirectoryCatalog.ts, and the MCP server draft helpers to
mcpServerDraft.logic.ts. PluginsDialog.tsx keeps the environment-bound state
owner, the server editor, and both surfaces, and re-exports moved names.

Dialog gains directory header/panel variants that carry the catalog padding,
including the pt-5! override, and a divided header variant for the border-b
rule, so plugin call sites stop restyling the primitives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PluginsCatalog.tsx keeps the directory composition and re-exports the cards
(PluginCatalogCards.tsx), Composio results, custom and removed MCP server
lists, and the label translator, each now in its own module.

Plugin action buttons select new Button pill sizes, the broker badge a quiet
Badge variant, and the category picker a dense Select size, carrying the
exact classes the call sites used to pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nu modules

sidebarContext.tsx owns the provider, contexts, cookie persistence, and
keyboard-facing toggle; sidebarRail.tsx owns resize capture and width
clamping; sidebarMenu.tsx owns the group, menu, and submenu parts.
sidebar.tsx keeps Sidebar, the trigger, inset, and layout slots, and its
export list is unchanged, so no importer changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed modules

toastState.ts owns the shared manager instances and the visible-time
registry so every provider reads the same ones. ToastBody.tsx holds the body
rendering, ThreadToastVisibleAutoDismiss.tsx the route-scoped visibility and
timeout accounting, and AnchoredToasts.tsx the anchored provider. toast.tsx
keeps ToastProvider and Toasts and its existing exports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added type:provider Agent provider contribution. area:directory Plugin directory and its user interface. area:connectors Plugin and MCP connector runtime. labels Oct 2, 2026
leoisadev1 and others added 3 commits October 2, 2026 10:15
CI runs scripts/check-public-dependencies.ts before installing dependencies, so
importing effect/Schema failed with ERR_MODULE_NOT_FOUND. Parse manifests with
Node built-ins only and add a test that guards the import list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test-file override for no-module-mocking matched only .ts and .tsx, so CI
lint rejected the vi.mock seams in apps/desktop/scripts/dev-electron.test.mjs.
Also format ResponseLoadingState.test.tsx, which failed fmt:check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…old labels

Restoring main's English work-fold labels removed the translated messages from
thread-turn-fold-row.tsx, but the coverage snapshot still counted them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Refactors module structure and adds lint tooling configuration.

The PR appears safe to merge based on this review.

Summary

The PR splits oversized modules, strengthens lint enforcement, replaces raw palette colors with theme tokens, and includes targeted behavior fixes. Since the previous review, the desktop annotation stylesheet generator was updated to scan the preview modules containing overlay classes.

Reviews (7) · Last reviewed commit: "fix(desktop): build annotation styles fr..."

Comment thread apps/server/src/wsOrchestrationCommands.ts
Comment thread apps/server/src/wsOrchestrationCommands.ts Outdated
Comment thread apps/server/src/orchestration/Layers/snapshot-query/ThreadRows.ts
Comment thread apps/server/src/image-generation/ImageFile.ts
Comment thread apps/web/src/components/usage/UsagePageSections.tsx Outdated
leoisadev1 and others added 2 commits October 2, 2026 10:40
The engine commits a queued command even after its caller stops waiting,
so an interrupted bootstrap could delete a thread whose first turn was
accepted, or miss deleting a thread whose create had committed. Create
and turn start now await their results uninterruptibly and record them
before cleanup reads them.

The latest user message lookup now runs as one ordered SQL query instead
of loading every message, image reads gain multi-chunk coverage, and the
usage loading comment matches the static skeleton.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude turns select the 1M context variant and grok-build resolves to
grok-4.6 before reaching Mastra, so comparing switches against the raw
model slug failed for both providers on main as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leoisadev1

Copy link
Copy Markdown
Member Author

@greptile apex

Comment thread apps/server/src/wsOrchestrationCommands.ts
leoisadev1 and others added 5 commits October 2, 2026 11:08
Bootstrap awaits its create and turn start uninterruptibly, so a command
stuck in the engine queue could hold a cancelled request and server
shutdown forever. Closing the engine now interrupts the in-flight and
queued results, releases their turn admissions, and fails later
dispatches instead of leaving them waiting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cleanup after a failed dispatch also ran when the client cancelled, but
the engine commits a queued turn start after its caller leaves, so the
message kept pointing at deleted files. Turn starts with pending uploads
now await the engine outcome and delete claimed files only when the
command receipt shows the turn was not accepted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…connection modules

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The worker could be interrupted after taking a command but before it
installed settlement and admission release, leaving the caller waiting.
Take uninterruptibly and install both before processing becomes
interruptible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread apps/server/src/orchestration/Normalizer.ts
leoisadev1 and others added 3 commits October 2, 2026 12:12
…lled engine

The dispatch ran uninterruptibly so its receipt could decide upload
cleanup, which made a cancelled caller wait behind any stalled command.
Run the dispatch detached with its cleanup attached and join it
interruptibly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…slop-cleanup

# Conflicts:
#	apps/web/src/components/sidebar/ExperimentalSidebar.tsx
The PickPreload split moved overlay class names into sibling modules, so the
generator dropped them on rebuild. Scan all preview sources instead.

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

area:connectors Plugin and MCP connector runtime. area:directory Plugin directory and its user interface. size:XXL type:provider Agent provider contribution. vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant