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:
@@ -8,6 +8,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, type Mock, vi } from "bun:test";
|
||||
import * as path from "node:path";
|
||||
import { Agent } from "@oh-my-pi/pi-agent-core";
|
||||
import type { ImageContent } from "@oh-my-pi/pi-ai";
|
||||
import { getBundledModel } from "@oh-my-pi/pi-catalog/models";
|
||||
import { ModelRegistry } from "@oh-my-pi/pi-coding-agent/config/model-registry";
|
||||
import { Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
|
||||
@@ -28,6 +29,8 @@ type StubEditor = {
|
||||
getText: () => string;
|
||||
addToHistory: Mock<(...args: unknown[]) => unknown>;
|
||||
onSubmit?: (text: string) => Promise<void>;
|
||||
pendingImages: ImageContent[];
|
||||
pendingImageLinks: (string | undefined)[];
|
||||
};
|
||||
|
||||
type PromptCustomMessage = Mock<
|
||||
@@ -53,6 +56,8 @@ function createStubInputControllerContext(opts: { skillCommands: Map<string, str
|
||||
return editorText;
|
||||
},
|
||||
addToHistory: vi.fn(),
|
||||
pendingImages: [] as ImageContent[],
|
||||
pendingImageLinks: [] as (string | undefined)[],
|
||||
};
|
||||
const promptCustomMessage: PromptCustomMessage = vi.fn(async () => {});
|
||||
const prompt = vi.fn(async (_text: string, _options?: unknown) => {});
|
||||
@@ -83,8 +88,6 @@ function createStubInputControllerContext(opts: { skillCommands: Map<string, str
|
||||
updatePendingMessagesDisplay,
|
||||
isBashMode: false,
|
||||
isPythonMode: false,
|
||||
pendingImages: [],
|
||||
pendingImageLinks: [],
|
||||
loopModeEnabled: false,
|
||||
compactionQueuedMessages: [],
|
||||
locallySubmittedUserSignatures: new Set<string>(),
|
||||
@@ -448,6 +451,8 @@ function createStubInteractiveModeContextForUiHelpers(session: AgentSession) {
|
||||
return editorText;
|
||||
},
|
||||
addToHistory: vi.fn(),
|
||||
pendingImages: [] as ImageContent[],
|
||||
pendingImageLinks: [] as (string | undefined)[],
|
||||
};
|
||||
const pendingMessagesContainer = new Container();
|
||||
const requestRender = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user