refactor: group native chat turn presentation (#34629)

This commit is contained in:
Neil
2026-10-27 17:33:03 -07:00
committed by GitHub
parent 59dbb54dad
commit ea532813b1
33 changed files with 57 additions and 51 deletions
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import type { AgentJournalRenderItem } from '../../shared/agent-session-journal-types'
import { agentJournalItemKey } from '../../shared/agent-session-journal-item-key'
import { nativeChatTurnFold } from '../../shared/native-chat-turn-fold'
import { nativeChatTurnFold } from '../../shared/native-chat/transcript/native-chat-turn-fold'
import { nativeChatTurnMembership } from '../../shared/native-chat-turn-membership'
import type { NativeChatMessage } from '../../shared/native-chat-types'
import { projectStructuredItemToNativeChat } from '../../shared/structured-agent-session-projection'
@@ -4,7 +4,7 @@ import { join } from 'node:path'
import { afterEach, describe, expect, it } from 'vitest'
import type { AgentJournalRenderItem } from '../../shared/agent-session-journal-types'
import type { AgentSessionTurnActivity } from '../../shared/agent-session-wire'
import { selectStructuredAgentTurnActivity } from '../../shared/native-chat-turn-activity'
import { selectStructuredAgentTurnActivity } from '../../shared/native-chat/transcript/native-chat-turn-activity'
import { latestStructuredAgentSessionAssistantMessage } from '../../shared/structured-agent-session-latest-request'
import {
isStructuredAgentSessionThinking,
@@ -16,8 +16,11 @@ import { withNativeChatCutTurnNotices } from '../../../shared/native-chat-cut-tu
import {
nativeChatRowTurnKeys,
nativeChatTurnBarRows
} from '../../../shared/native-chat-turn-grouping'
import { nativeChatTurnFold, nativeChatTurnFoldRow } from '../../../shared/native-chat-turn-fold'
} from '../../../shared/native-chat/transcript/native-chat-turn-grouping'
import {
nativeChatTurnFold,
nativeChatTurnFoldRow
} from '../../../shared/native-chat/transcript/native-chat-turn-fold'
import { nativeChatTurnMembership } from '../../../shared/native-chat-turn-membership'
import { projectStructuredItemsToNativeChat } from '../../../shared/structured-agent-session-projection'
import { GROK_ACP_DIALECT } from '../../acp/acp-dialects/grok-dialect'
@@ -9,7 +9,7 @@ import { computeAgentSessionPayloadFingerprint } from '../../../shared/agent-ses
import { agentSessionSendSubmission } from '../../../shared/agent-session-wire'
import { projectStructuredAgentSessionMessages } from '../../../shared/structured-agent-session-message-projection'
import { projectNativeChatTranscriptMessages } from '../../../shared/native-chat-transcript-projection'
import { nativeChatRowsInDrawOrder } from '../../../shared/native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from '../../../shared/native-chat/transcript/native-chat-turn-grouping'
import { nativeChatTurnMembership } from '../../../shared/native-chat-turn-membership'
import { ClaudeStructuredSessionAdapter } from '../../claude/claude-structured-session-adapter'
import {
@@ -5,7 +5,7 @@ import { agentJournalItemKey } from '../../../shared/agent-session-journal-item-
import type { AgentJournalRenderItem } from '../../../shared/agent-session-journal-types'
import { withNativeChatCutTurnNotices } from '../../../shared/native-chat-cut-turn-notice'
import { latestNativeChatOrcaStopCut } from '../../../shared/native-chat/native-chat-orca-stop-cut'
import { nativeChatTurnFold } from '../../../shared/native-chat-turn-fold'
import { nativeChatTurnFold } from '../../../shared/native-chat/transcript/native-chat-turn-fold'
import { orcaStopRowBody } from './structured-agent-session-orca-stop-row'
const LEGACY_TEXT =
@@ -8,7 +8,7 @@ import { agentJournalSubmissionKey } from '../../shared/agent-session-journal-it
import { CODEX_TURN_OPEN_WAIT_MS } from '../codex/codex-structured-turn-open-wait'
import { projectStructuredAgentSessionMessages } from '../../shared/structured-agent-session-message-projection'
import { projectNativeChatTranscriptMessages } from '../../shared/native-chat-transcript-projection'
import { nativeChatRowsInDrawOrder } from '../../shared/native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from '../../shared/native-chat/transcript/native-chat-turn-grouping'
import { nativeChatTurnMembership } from '../../shared/native-chat-turn-membership'
import { CodexAppServerRequestError } from '../codex/app-server/codex-app-server-request-error'
import type {
@@ -20,7 +20,7 @@ import { readAgentJournalTurn } from '../../shared/agent-session-turn-record'
import { AGENT_SESSION_GOAL_CONTROL_COPY } from '../../shared/agent-session-goal-control-copy'
import { NATIVE_CHAT_STOPPED_BEFORE_START_TEXT } from '../../shared/native-chat/native-chat-stopped-before-start'
import { projectNativeChatTranscript } from '../../shared/native-chat-transcript-projection'
import { nativeChatRowsInDrawOrder } from '../../shared/native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from '../../shared/native-chat/transcript/native-chat-turn-grouping'
import {
nativeChatTurnMembership,
structuredAgentTurnAnchors
@@ -17,7 +17,7 @@ import { NativeChatDockedTaskList } from './NativeChatDockedTaskList'
import { useNativeChatTurnStatus } from './use-native-chat-turn-status'
import { NativeChatAwaitingInputRow } from './NativeChatAwaitingInputRow'
import type { RuntimeFileOperationArgs } from '@/runtime/runtime-file-client-types'
import type { NativeChatTurnActivity } from '../../../../shared/native-chat-turn-activity'
import type { NativeChatTurnActivity } from '../../../../shared/native-chat/transcript/native-chat-turn-activity'
import { NativeChatTurnActivityLine } from './NativeChatTurnActivityLine'
import {
NativeChatDisclosureContext,
@@ -13,7 +13,7 @@ import type {
import { agentJournalSubmissionKey } from '../../../../shared/agent-session-journal-item-key'
import { DISPATCH_REJECTED_CANCELLED } from '../../../../shared/structured-agent-session-dispatch-rejection'
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
import { nativeChatRowsInDrawOrder } from '../../../../shared/native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from '../../../../shared/native-chat/transcript/native-chat-turn-grouping'
import { nativeChatTurnMembership } from '../../../../shared/native-chat-turn-membership'
import {
buildNativeChatRailItems,
@@ -8,7 +8,7 @@ import type {
NativeChatSubagentState
} from '../../../../shared/native-chat-types'
import { projectNativeChatTranscript } from '../../../../shared/native-chat-transcript-projection'
import { nativeChatRowsInDrawOrder } from '../../../../shared/native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from '../../../../shared/native-chat/transcript/native-chat-turn-grouping'
import {
nativeChatTurnMembership,
type NativeChatTurnJournal
@@ -8,8 +8,11 @@ import type { NativeChatMessage } from '../../../../shared/native-chat-types'
import type { NativeChatTurnStatus } from '../../../../shared/native-chat-turn-status'
import { isNativeChatRowInLiveWorkingTurn } from '../../../../shared/native-chat-turn-membership'
import { nativeChatMessagesWaitingBehindLiveTurn } from '../../../../shared/native-chat-messages-waiting-behind-live-turn'
import { nativeChatTurnBarRows } from '../../../../shared/native-chat-turn-grouping'
import { nativeChatTurnFold, nativeChatTurnFoldRow } from '../../../../shared/native-chat-turn-fold'
import { nativeChatTurnBarRows } from '../../../../shared/native-chat/transcript/native-chat-turn-grouping'
import {
nativeChatTurnFold,
nativeChatTurnFoldRow
} from '../../../../shared/native-chat/transcript/native-chat-turn-fold'
import { nativeChatRowRendersContent } from '../../../../shared/native-chat-row-content'
import {
type NativeChatRowTypography,
@@ -3,7 +3,7 @@ import type { AgentJournalRenderItem } from '../../../../shared/agent-session-jo
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
import { projectNativeChatTranscript } from '../../../../shared/native-chat-transcript-projection'
import { nativeChatTurnMembership } from '../../../../shared/native-chat-turn-membership'
import { nativeChatRowsInDrawOrder } from '../../../../shared/native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from '../../../../shared/native-chat/transcript/native-chat-turn-grouping'
import { nativeChatSubagentSections } from './native-chat-subagent-sections'
import {
buildNativeChatTranscriptSlots,
@@ -6,7 +6,7 @@ import type {
import type { NativeChatMessage } from '../../../../shared/native-chat-types'
import type { AgentSessionLatestTurn } from '../../../../shared/agent-session-wire'
import { nativeChatTurnMembership } from '../../../../shared/native-chat-turn-membership'
import { nativeChatRowsInDrawOrder } from '../../../../shared/native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from '../../../../shared/native-chat/transcript/native-chat-turn-grouping'
export type NativeChatTurnRows = {
messages: readonly NativeChatMessage[]
@@ -7,7 +7,7 @@ import {
import { isStructuredAgentSessionMainAgentWorking } from '../../../../shared/structured-agent-session-main-agent-working'
import type { StructuredAgentSessionState } from '../../../../shared/structured-agent-session-reducer'
import type { StructuredAgentSubagentRoster } from '../../../../shared/structured-agent-session-subagent-roster'
import { selectStructuredAgentTurnActivity } from '../../../../shared/native-chat-turn-activity'
import { selectStructuredAgentTurnActivity } from '../../../../shared/native-chat/transcript/native-chat-turn-activity'
import { structuredSessionBackgroundTasksView } from '../../../../shared/structured-session-background-tasks-view'
import { structuredSessionForegroundCommands } from '../../../../shared/structured-session-foreground-commands'
import { useStructuredAgentTurnTiming } from './use-structured-agent-turn-timing'
@@ -7,7 +7,7 @@ import type {
AgentJournalTurnScope
} from './agent-session-journal-types'
import { projectNativeChatTranscript } from './native-chat-transcript-projection'
import { nativeChatRowsInDrawOrder } from './native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from './native-chat/transcript/native-chat-turn-grouping'
import { nativeChatTurnMembership, structuredAgentTurnAnchors } from './native-chat-turn-membership'
import { DISPATCH_REJECTED_CANCELLED } from './structured-agent-session-dispatch-rejection'
import { projectStructuredAgentSessionMessages } from './structured-agent-session-message-projection'
@@ -3,7 +3,7 @@ import './native-chat-reasoning-order.spec'
import './native-chat/tools/native-chat-tool-activity.spec'
import './native-chat/tools/native-chat-tool-pair-limit.spec'
import './native-chat/tools/native-chat-tool-fold-attribution.spec'
import './native-chat-turn-grouping.spec'
import './native-chat/transcript/native-chat-turn-grouping.spec'
import './native-chat/input/native-chat-ask-row.spec'
import './native-chat/tools/native-chat-tool-pairing.spec'
import './native-chat-live-line.spec'
@@ -6,7 +6,7 @@ import type {
AgentJournalSubmission,
AgentJournalTurnScope
} from './agent-session-journal-types'
import { nativeChatRowsInDrawOrder } from './native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from './native-chat/transcript/native-chat-turn-grouping'
import {
nativeChatTurnMembership,
structuredAgentTurnAnchors,
+1 -1
View File
@@ -21,7 +21,7 @@ import {
nativeChatTurnDrawOrder,
nativeChatUserRowOpensTurn,
type NativeChatOpensTurn
} from './native-chat-turn-grouping'
} from './native-chat/transcript/native-chat-turn-grouping'
import type { NativeChatMessage, NativeChatRole } from './native-chat-types'
import { dispatchWasWithdrawn } from './structured-agent-session-dispatch-rejection'
import { inSendOrder } from './native-chat/native-chat-send-order'
@@ -5,7 +5,7 @@ import type {
} from '../../agent-session-journal-types'
import type { AgentJournalTurnScope } from '../../agent-session-journal-turn-scope'
import { foldToolMessages } from './native-chat-tool-fold'
import { nativeChatRowsInDrawOrder } from '../../native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from '../transcript/native-chat-turn-grouping'
import { nativeChatTurnMembership } from '../../native-chat-turn-membership'
import type { NativeChatMessage, NativeChatRole } from '../../native-chat-types'
import { projectStructuredItemsToNativeChat } from '../../structured-agent-session-projection'
@@ -1,5 +1,8 @@
import { describe, expect, it } from 'vitest'
import type { AgentJournalItemBody, AgentJournalRenderItem } from './agent-session-journal-types'
import type {
AgentJournalItemBody,
AgentJournalRenderItem
} from '../../agent-session-journal-types'
import { selectStructuredAgentTurnActivity } from './native-chat-turn-activity'
function item(sequence: number, body: AgentJournalItemBody): AgentJournalRenderItem {
@@ -1,12 +1,9 @@
import { readAgentJournalTurn } from './agent-session-turn-record'
import type { AgentJournalRenderItem } from './agent-session-journal-types'
import type { AgentSessionTurnActivity } from './agent-session-wire'
import { isRootAgentJournalItem } from './agent-session-journal-producer'
import { normalizePromptField } from './agent-status-field-normalization'
import {
describeActiveToolCall,
formatActiveToolLabel
} from './native-chat/tools/native-chat-tool-activity'
import { readAgentJournalTurn } from '../../agent-session-turn-record'
import type { AgentJournalRenderItem } from '../../agent-session-journal-types'
import type { AgentSessionTurnActivity } from '../../agent-session-wire'
import { isRootAgentJournalItem } from '../../agent-session-journal-producer'
import { normalizePromptField } from '../../agent-status-field-normalization'
import { describeActiveToolCall, formatActiveToolLabel } from '../tools/native-chat-tool-activity'
export type NativeChatTurnActivity = { kind: 'description'; text: string }
@@ -1,18 +1,18 @@
// Derive settled-turn answers from the last assistant prose or system failure; the journal has no answer marker.
// Earlier work/recovered errors fold behind that answer, while failed turns end visibly on their error.
import { AGENT_SESSION_COMPACTION_SKIPPED_PRESENTATION } from './agent-session-compaction'
import { AGENT_SESSION_ORCA_STOP_PRESENTATION } from './agent-session-orca-stop'
import { AGENT_SESSION_TURN_NOTICE_PRESENTATION } from './agent-session-turn-notice'
import { nativeChatRowRendersContent } from './native-chat-row-content'
import { isStoppedBeforeStartBlock } from './native-chat/native-chat-stopped-before-start'
import { nativeChatRowRendersProse } from './native-chat/native-chat-trailing-run'
import { AGENT_SESSION_COMPACTION_SKIPPED_PRESENTATION } from '../../agent-session-compaction'
import { AGENT_SESSION_ORCA_STOP_PRESENTATION } from '../../agent-session-orca-stop'
import { AGENT_SESSION_TURN_NOTICE_PRESENTATION } from '../../agent-session-turn-notice'
import { nativeChatRowRendersContent } from '../../native-chat-row-content'
import { isStoppedBeforeStartBlock } from '../native-chat-stopped-before-start'
import { nativeChatRowRendersProse } from '../native-chat-trailing-run'
import {
isBackgroundTaskBlock,
isSubagentGroupBlock,
type NativeChatMessage,
type NativeChatRole
} from './native-chat-types'
} from '../../native-chat-types'
/** Each surface supplies its own row-content results so folding sees exactly the prose it renders. */
export type NativeChatTurnFoldRow = {
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import type { NativeChatMessage } from './native-chat-types'
import type { NativeChatMessage } from '../../native-chat-types'
import {
nativeChatRowTurnKeys,
nativeChatTurnBarRows,
@@ -1,8 +1,8 @@
// Share desktop/mobile turn ownership, bar placement and row order.
import type { AgentJournalRenderItem } from './agent-session-journal-types'
import { readAgentJournalTurn } from './agent-session-turn-record'
import type { NativeChatRole } from './native-chat-types'
import type { AgentJournalRenderItem } from '../../agent-session-journal-types'
import { readAgentJournalTurn } from '../../agent-session-turn-record'
import type { NativeChatRole } from '../../native-chat-types'
type NativeChatTurnRow = { id: string; role: NativeChatRole }
@@ -22,7 +22,7 @@ import {
projectNativeChatTranscript,
projectNativeChatTranscriptMessages
} from './native-chat-transcript-projection'
import { nativeChatRowsInDrawOrder } from './native-chat-turn-grouping'
import { nativeChatRowsInDrawOrder } from './native-chat/transcript/native-chat-turn-grouping'
import { nativeChatTurnMembership } from './native-chat-turn-membership'
let sequence = 0