refactor(coding-agent): consolidated editor state and unify transcript rendering

- Centralized draft state and image management by migrating fields from context to the CustomEditor component.
- Standardized transcript row construction by introducing shared helpers for background jobs, IRC traffic, and file mentions.
- Refactored redundant UI logic and helper functions into reusable utility modules to streamline message submission and component rendering.
- Standardized event handler types by consolidating lifecycle definitions into a shared module while maintaining public API stability.
This commit is contained in:
can1357
2026-06-22 06:11:57 +02:00
parent c204d1b30c
commit 93db34b0d5
25 changed files with 419 additions and 390 deletions
@@ -1,4 +1,5 @@
import { describe, expect, it, vi } from "bun:test";
import type { ImageContent } from "@oh-my-pi/pi-ai";
import { InputController } from "@oh-my-pi/pi-coding-agent/modes/controllers/input-controller";
import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types";
@@ -11,6 +12,8 @@ type FakeEditor = {
setActionKeys(action: string, keys: string[]): void;
setCustomKeyHandler(key: string, handler: () => void): void;
clearCustomKeyHandlers(): void;
pendingImages: ImageContent[];
pendingImageLinks: (string | undefined)[];
};
function createContext() {
@@ -33,6 +36,8 @@ function createContext() {
setActionKeys: vi.fn(),
setCustomKeyHandler: vi.fn(),
clearCustomKeyHandlers: vi.fn(),
pendingImages: [] as ImageContent[],
pendingImageLinks: [] as (string | undefined)[],
};
const ctx = {
@@ -49,8 +54,6 @@ function createContext() {
getQueuedMessages: () => ({ steering: [], followUp: [] }),
} as unknown as InteractiveModeContext["session"],
sessionManager: { getSessionName: () => "named-session" } as unknown as InteractiveModeContext["sessionManager"],
pendingImages: [] as InteractiveModeContext["pendingImages"],
pendingImageLinks: [] as InteractiveModeContext["pendingImageLinks"],
compactionQueuedMessages: [] as InteractiveModeContext["compactionQueuedMessages"],
locallySubmittedUserSignatures: new Set<string>(),
onInputCallback,