# refactor\(web\): ChatView's thread derivations are tested functions in ChatView.logic · PR \#23071 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/23071)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: merged

Source repository: pingdotgg/t3code

Source branch: refactor/split2-chatview-logic

Target branch: main

Head commit: 9d1b04843931bceefe82d0296b3dd27f072b636d

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/23071)

[Commits](https://git.cafe/pingdotgg/t3code/pull/23071/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/23071/diffs?format=markdown)

## Description

---

Four render-time IIFEs were pure derivations of the thread projection. They become named functions in `ChatView.logic.ts`: the shell built from a directly loaded detail, pending background work, the runs a conversation can revert to, and the workspace mutation key. `deriveAvailableRevertTurnCounts` and `deriveWorkspaceMutationId` get focused tests.

| | Before | After |
|---|---|---|
| `ChatView.tsx` lines | 4,190 | 4,072 |

Tests: `tsc-rs --noEmit` for apps/web, oxlint on the changed files, `vp test run src/components/ChatView.logic.test.ts`, and the React Compiler coverage test for every changed file (0 bailouts). ChatView stays in the coverage test's slow set.

Part of the ChatView split (7,258 → 3,975 lines across the stack).

Opus 5.5, Claude Code.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

