refactor: codebase audit cleanup — dead code, dedup, module splits

Multi-agent audit + aggressive cleanup across server/web/coder/booterm,
delivered behind a DEFER discipline so none of the in-flight files were
touched. Removes dead code/deps/columns, dedups server + coder helpers,
and splits the oversized modules (tools.ts, opencode-server.ts,
sentinel-summaries, turn.ts, TerminalPane.tsx) behind stable contracts.
Adds 78 parity/unit tests (server 587, coder 323); fixes two latent bugs
(ChatPane queue keys, FileViewerOverlay blank-line parity).

Intended tag: v2.7.12-audit-cleanup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 21:10:06 +00:00
parent e5ce01ae72
commit 8c200216eb
143 changed files with 6729 additions and 6087 deletions

View File

@@ -25,7 +25,8 @@ interface Props {
export function ChatPane({ sessionId, chatId, projectId, agentId, onAgentChange, sessionChats, webSearchEnabled }: Props) {
const stream = useSessionStream(sessionId);
const lastErrorRef = useRef<string | null>(null);
const [queue, setQueue] = useState<string[]>([]);
const [queue, setQueue] = useState<{ id: string; text: string }[]>([]);
const queueIdRef = useRef(0);
const processingRef = useRef(false);
useEffect(() => {
@@ -84,7 +85,7 @@ export function ChatPane({ sessionId, chatId, projectId, agentId, onAgentChange,
processingRef.current = true;
const next = queue[0]!;
setQueue((prev) => prev.slice(1));
api.messages.send(chatId, next)
api.messages.send(chatId, next.text)
.catch((err) => toast.error(err instanceof Error ? err.message : 'queue send failed'))
.finally(() => { processingRef.current = false; });
}, [streaming, queue, chatId]);
@@ -101,7 +102,7 @@ export function ChatPane({ sessionId, chatId, projectId, agentId, onAgentChange,
return;
}
if (streaming) {
setQueue((prev) => [...prev, trimmed]);
setQueue((prev) => [...prev, { id: String(++queueIdRef.current), text: trimmed }]);
return;
}
await api.messages.send(chatId, trimmed);
@@ -185,18 +186,18 @@ export function ChatPane({ sessionId, chatId, projectId, agentId, onAgentChange,
// into ChatInput via sendToChat. ChatInput appends (or sets, if empty) and
// focuses; user re-sends, which re-queues if streaming is still active.
function editQueued(idx: number) {
const msg = queue[idx];
if (!msg) return;
const item = queue[idx];
if (!item) return;
setQueue((prev) => prev.filter((_, i) => i !== idx));
sendToChat.emit({ chat_id: chatId, text: msg });
sendToChat.emit({ chat_id: chatId, text: item.text });
}
async function forceSendQueued(idx: number) {
const msg = queue[idx];
if (!msg) return;
const item = queue[idx];
if (!item) return;
setQueue((prev) => prev.filter((_, i) => i !== idx));
try {
await api.chats.forceSend(chatId, msg);
await api.chats.forceSend(chatId, item.text);
} catch (err) {
toast.error(err instanceof Error ? err.message : 'force send failed');
}
@@ -211,10 +212,10 @@ export function ChatPane({ sessionId, chatId, projectId, agentId, onAgentChange,
{queue.length > 0 && (
<div className="border-t">
<div className="max-w-[1000px] mx-auto w-full px-4 py-1 space-y-1">
{queue.map((msg, i) => (
<div key={i} className="flex items-center gap-2 text-xs text-muted-foreground bg-muted/30 rounded px-2 py-1">
{queue.map((item, i) => (
<div key={item.id} className="flex items-center gap-2 text-xs text-muted-foreground bg-muted/30 rounded px-2 py-1">
<span className="font-medium shrink-0">Queued:</span>
<span className="truncate flex-1">{msg}</span>
<span className="truncate flex-1">{item.text}</span>
<button
type="button"
onClick={() => editQueued(i)}