You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/08/23 08:14:15 UTC
(maka) branch refactor/3521-simplify-tool-reconcile created (now 36cbeb9c3)
This is an automated email from the ASF dual-hosted git repository.
Astro-Han pushed a change to branch refactor/3521-simplify-tool-reconcile
in repository https://gitbox.apache.org/repos/asf/maka.git
at 36cbeb9c3 refactor(cli): remove derived transcript mirrors
This branch includes the following new commits:
new f762d80f9 refactor(cli): unify transcript reconciliation
new 36cbeb9c3 refactor(cli): remove derived transcript mirrors
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
(maka) 02/02: refactor(cli): remove derived transcript mirrors
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
Astro-Han pushed a commit to branch refactor/3521-simplify-tool-reconcile
in repository https://gitbox.apache.org/repos/asf/maka.git
commit 36cbeb9c3dbb9d8a5364834681de9a6edfc11a86
Author: AstroHan <le...@outlook.com>
AuthorDate: Sun Aug 23 16:13:00 2026 +0800
refactor(cli): remove derived transcript mirrors
---
packages/cli/src/__tests__/pi-transcript.test.ts | 28 ++++++++++++++++++++++++
packages/cli/src/pi-transcript-tools.ts | 12 ++++++----
packages/cli/src/pi-transcript.ts | 20 +++--------------
packages/cli/src/pi-tui-runner.ts | 13 ++++++-----
4 files changed, 47 insertions(+), 26 deletions(-)
diff --git a/packages/cli/src/__tests__/pi-transcript.test.ts b/packages/cli/src/__tests__/pi-transcript.test.ts
index e1cab2d10..eea6842d9 100644
--- a/packages/cli/src/__tests__/pi-transcript.test.ts
+++ b/packages/cli/src/__tests__/pi-transcript.test.ts
@@ -556,6 +556,34 @@ describe('Maka Pi TUI transcript', () => {
);
});
+ test('explains a stored tool call whose turn ended without a result', () => {
+ const state = createMakaPiTranscriptState();
+ replaceTranscriptWithStoredMessages(state, [
+ {
+ type: 'tool_call',
+ id: 'tool-1',
+ turnId: 'turn-1',
+ ts: 1,
+ toolName: 'Read',
+ args: { path: '/tmp/example.txt' },
+ },
+ {
+ type: 'turn_state',
+ id: 'turn-state-1',
+ turnId: 'turn-1',
+ ts: 2,
+ status: 'completed',
+ partialOutputRetained: false,
+ },
+ ] satisfies StoredMessage[]);
+
+ assert.equal(toggleAllToolExpansion(state), true);
+ assert.match(
+ renderMakaPiTranscript(state, meta(), 80).map(stripAnsi).join('\n'),
+ /Interrupted before the tool returned a result\./,
+ );
+ });
+
test('keeps a stored errored Read poll as a card without folding it into the parent Bash card', () => {
const state = createMakaPiTranscriptState();
const ref = 'maka://runtime/background-tasks/bg-1';
diff --git a/packages/cli/src/pi-transcript-tools.ts b/packages/cli/src/pi-transcript-tools.ts
index 40ac11ed1..719586271 100644
--- a/packages/cli/src/pi-transcript-tools.ts
+++ b/packages/cli/src/pi-transcript-tools.ts
@@ -33,6 +33,7 @@ import { colorDiff } from './tui-diff.js';
import {
collapseToSingleLine,
fitLine,
+ formatToolResultContent,
formatUnknownInline,
limitText,
renderIndented,
@@ -193,7 +194,7 @@ function renderExpandedToolBlock(entry: MakaPiToolEntry, width: number): string[
}
lines.push(...renderToolStreams(entry.outputDeltas.values(), width));
}
- if (entry.result || entry.output) {
+ if (entry.result || entry.status === 'aborted') {
lines.push(...renderToolResult(entry, width));
}
if (
@@ -549,8 +550,8 @@ function renderToolResult(entry: MakaPiToolEntry, width: number): string[] {
}
// A generic `text` dump — a Bash body or raw tool text — is what the head/tail
// cap targets: the model already holds the full body, so the transcript only
- // needs enough to orient. An undefined result with a formatted `output` string
- // is treated the same way. `json` is deliberately excluded: a Read json is
+ // needs enough to orient. An interrupted call with no result uses the same
+ // capped path for its explanation. `json` is deliberately excluded: a Read json is
// summarized above, a Grep/Glob json is a structured list the user expands to
// scan in full, and any other json collapses to a single inline line where the
// cap would be a no-op anyway.
@@ -566,6 +567,9 @@ function renderToolResult(entry: MakaPiToolEntry, width: number): string[] {
/** Best-effort extraction of the human-readable body from a tool result. */
function plainResultText(entry: MakaPiToolEntry): string {
const result = entry.result;
+ if (!result) {
+ return entry.status === 'aborted' ? 'Interrupted before the tool returned a result.' : '';
+ }
if (result?.kind === 'text') return typeof result.text === 'string' ? result.text : '';
if (result?.kind === 'json') {
const value = result.value;
@@ -585,7 +589,7 @@ function plainResultText(entry: MakaPiToolEntry): string {
const preview = formatQuietJsonValue(value, 'en');
return preview.headline ? `${preview.headline}\n${preview.body}` : preview.body;
}
- return entry.output ?? '';
+ return formatToolResultContent(result);
}
function renderTerminalResult(
diff --git a/packages/cli/src/pi-transcript.ts b/packages/cli/src/pi-transcript.ts
index b5f3e1745..ebe05a65d 100644
--- a/packages/cli/src/pi-transcript.ts
+++ b/packages/cli/src/pi-transcript.ts
@@ -50,7 +50,6 @@ import { ansi } from './tui-ansi.js';
import {
fitLine,
formatTokenCount,
- formatToolResultContent,
formatUnknown,
limitText,
markdownTheme,
@@ -176,10 +175,8 @@ export type MakaPiTranscriptEntry =
toolName: string;
title?: string;
input: unknown;
- /** Structured result; preferred over `output` when present. */
+ /** Structured result returned by the tool. */
result?: ToolResultContent;
- /** Flattened result text, kept as a fallback for text/json/unknown kinds. */
- output?: string;
/** In-memory revision for render-cache invalidation when a result is replaced. */
resultVersion: number;
progress: BoundedChunkBuffer<string>;
@@ -405,7 +402,6 @@ export function reconcileToolsWithStoredMessages(
entry.title = durable.title;
entry.input = structuredClone(durable.input);
entry.result = durable.result ? structuredClone(durable.result) : undefined;
- entry.output = durable.output;
entry.durationMs = durable.durationMs;
entry.status = durable.status;
entry.hidden = durable.hidden;
@@ -632,7 +628,6 @@ export function applyMakaSessionEventToTranscript(
progress: createProgressBuffer(),
outputDeltas: createOutputBuffer(),
result: event.content,
- output: formatToolResultContent(event.content),
resultVersion: 1,
durationMs: event.durationMs,
status: event.isError ? 'error' : 'done',
@@ -680,7 +675,6 @@ export function applyMakaSessionEventToTranscript(
} else {
tool.status = toolResultTranscriptStatus(event.content, event.isError);
tool.result = event.content;
- tool.output = formatToolResultContent(event.content);
tool.durationMs = event.durationMs;
tool.resultVersion += 1;
}
@@ -694,7 +688,6 @@ export function applyMakaSessionEventToTranscript(
progress: createProgressBuffer(),
outputDeltas: createOutputBuffer(),
result: event.content,
- output: formatToolResultContent(event.content),
resultVersion: 1,
durationMs: event.durationMs,
status: toolResultTranscriptStatus(event.content, event.isError),
@@ -874,11 +867,6 @@ function chatItemToTranscriptEntries(item: ChatItem): MakaPiTranscriptEntry[] {
}
function toolActivityToTranscriptEntry(item: ToolActivityItem): MakaPiToolEntry {
- const output = item.result
- ? formatToolResultContent(item.result)
- : item.status === 'interrupted'
- ? 'Interrupted before the tool returned a result.'
- : undefined;
const entry: MakaPiToolEntry = {
kind: 'tool',
toolUseId: item.toolUseId,
@@ -888,7 +876,6 @@ function toolActivityToTranscriptEntry(item: ToolActivityItem): MakaPiToolEntry
progress: createProgressBuffer(),
outputDeltas: createOutputBuffer(),
...(item.result ? { result: item.result } : {}),
- ...(output ? { output } : {}),
resultVersion: item.result ? 1 : 0,
...(item.durationMs !== undefined ? { durationMs: item.durationMs } : {}),
status: transcriptToolStatus(item.status),
@@ -939,8 +926,9 @@ function transcriptToolStatus(status: ToolActivityItem['status']): MakaPiToolEnt
case 'completed':
return 'done';
case 'errored':
- case 'interrupted':
return 'error';
+ case 'interrupted':
+ return 'aborted';
case 'pending':
case 'running':
return 'running';
@@ -1001,7 +989,6 @@ function applyShellRunResult(
if (!merged.changed) return false;
entry.status = shellRunTranscriptStatus(merged.result.status);
entry.result = merged.result;
- entry.output = formatToolResultContent(merged.result);
entry.durationMs = Math.max(
0,
(merged.result.completedAt ?? merged.result.updatedAt) - merged.result.startedAt,
@@ -1022,7 +1009,6 @@ function applyOwnShellRunResult(
: 'done'
: shellRunTranscriptStatus(result.status);
entry.result = result;
- entry.output = formatToolResultContent(result);
if (entry.toolName === 'WriteStdin') {
entry.durationMs = operationDurationMs;
} else {
diff --git a/packages/cli/src/pi-tui-runner.ts b/packages/cli/src/pi-tui-runner.ts
index d80e6b23c..ad50c9430 100644
--- a/packages/cli/src/pi-tui-runner.ts
+++ b/packages/cli/src/pi-tui-runner.ts
@@ -279,9 +279,12 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
};
const tui = new TUI(terminal);
const state = createMakaPiTranscriptState();
- let transcriptMessages: readonly StoredMessage[] = [];
+ let transcriptLastUsedModel: string | undefined;
+ const rememberTranscriptModel = (messages: readonly StoredMessage[]): void => {
+ transcriptLastUsedModel = deriveModelSwitchTranscript(messages).lastUsedModel;
+ };
const replaceTranscript = (messages: readonly StoredMessage[]): void => {
- transcriptMessages = messages;
+ rememberTranscriptModel(messages);
replaceTranscriptWithStoredMessages(state, messages);
};
let cwd = input.cwd;
@@ -536,7 +539,7 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
requestRender();
return;
}
- transcriptMessages = messages;
+ rememberTranscriptModel(messages);
if (reconcileToolsWithStoredMessages(state, turnId, messages)) {
shellRunElapsedTicker.sync();
requestRender();
@@ -1461,7 +1464,7 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
const setModel = async (nextModel: string) => {
if (nextModel === model) return;
- const previousModel = deriveModelSwitchTranscript(transcriptMessages).lastUsedModel ?? model;
+ const previousModel = transcriptLastUsedModel ?? model;
await input.driver.setModel(nextModel);
model = nextModel;
// Same-connection switch: scope the choice lookup to the live connection
@@ -1487,7 +1490,7 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
// Updates the provider (and thus the thinking variants) and the status line.
const setModelChoice = async (choice: ModelChoice) => {
if (choice.model === model && choice.connectionSlug === connectionSlug) return;
- const previousModel = deriveModelSwitchTranscript(transcriptMessages).lastUsedModel ?? model;
+ const previousModel = transcriptLastUsedModel ?? model;
const previousConnectionSlug = connectionSlug;
const previousChoice = modelChoices?.find(
(candidate) =>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org
(maka) 01/02: refactor(cli): unify transcript reconciliation
Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
Astro-Han pushed a commit to branch refactor/3521-simplify-tool-reconcile
in repository https://gitbox.apache.org/repos/asf/maka.git
commit f762d80f9c056c9855b488000d70532909a74278
Author: AstroHan <le...@outlook.com>
AuthorDate: Sun Aug 23 16:12:55 2026 +0800
refactor(cli): unify transcript reconciliation
---
.../src/__tests__/runtime-host-run-command.test.ts | 6 +--
.../__tests__/runtime-host-session-driver.test.ts | 48 +++++++++++++++++++---
packages/cli/src/runtime-host-run-command.ts | 8 +++-
packages/cli/src/runtime-host-session-driver.ts | 41 ++++++------------
packages/cli/src/session-driver.ts | 4 +-
5 files changed, 66 insertions(+), 41 deletions(-)
diff --git a/packages/cli/src/__tests__/runtime-host-run-command.test.ts b/packages/cli/src/__tests__/runtime-host-run-command.test.ts
index 708d6e6de..2589f6c01 100644
--- a/packages/cli/src/__tests__/runtime-host-run-command.test.ts
+++ b/packages/cli/src/__tests__/runtime-host-run-command.test.ts
@@ -895,7 +895,7 @@ function runFixture(input: {
if (input.graphMultiWakeRace) {
queueMicrotask(() => {
for (const listener of transcriptListeners) {
- listener('session-created', 'turn-2', structuredClone(graphMessages()), 'terminal');
+ listener('session-created', 'turn-2', structuredClone(graphMessages()), 'reconcile');
}
});
}
@@ -905,7 +905,7 @@ function runFixture(input: {
queueMicrotask(() => {
const terminal = multiWakeGraphMessages(true);
for (const listener of transcriptListeners) {
- listener('session-created', 'turn-3', structuredClone(terminal), 'terminal');
+ listener('session-created', 'turn-3', structuredClone(terminal), 'reconcile');
}
});
return multiWakeGraphMessages(false);
@@ -918,7 +918,7 @@ function runFixture(input: {
if (input.graphProjectionRace) {
queueMicrotask(() => {
for (const listener of transcriptListeners) {
- listener('session-created', 'turn-2', structuredClone(messages), 'terminal');
+ listener('session-created', 'turn-2', structuredClone(messages), 'reconcile');
}
});
return graphMessages(false);
diff --git a/packages/cli/src/__tests__/runtime-host-session-driver.test.ts b/packages/cli/src/__tests__/runtime-host-session-driver.test.ts
index 606768098..112b7ae7c 100644
--- a/packages/cli/src/__tests__/runtime-host-session-driver.test.ts
+++ b/packages/cli/src/__tests__/runtime-host-session-driver.test.ts
@@ -1304,7 +1304,7 @@ describe('Runtime Host Maka Session driver', () => {
model: 'gpt-5',
});
await driver.switchSession('session-1');
- const replacement = deferred<StoredMessage[]>();
+ const replacement = deferred<readonly StoredMessage[]>();
driver.subscribeTranscriptReplacements!((_sessionId, _turnId, messages) =>
replacement.resolve(messages),
);
@@ -1344,9 +1344,9 @@ describe('Runtime Host Maka Session driver', () => {
model: 'gpt-5',
});
await driver.switchSession('session-1');
- const replacements: StoredMessage[][] = [];
+ const replacements: Array<readonly StoredMessage[]> = [];
driver.subscribeTranscriptReplacements!((_sessionId, _turnId, messages, reason) => {
- assert.equal(reason, 'tool_result');
+ assert.equal(reason, 'reconcile');
replacements.push(messages);
});
@@ -1357,6 +1357,44 @@ describe('Runtime Host Maka Session driver', () => {
assert.deepEqual(replacements, [secondMessages]);
});
+ test('does not publish an older tool-result transcript after the terminal transcript', async () => {
+ const attached = new FakeSubscription(continuitySnapshot(), Promise.resolve([]));
+ const liveTranscript = deferred<StoredMessage[]>();
+ const liveRefresh = new FakeSubscription(
+ continuitySnapshot(),
+ liveTranscript.promise,
+ 'subscription-2',
+ );
+ const terminalMessages = [userMessage('turn-1', 'Run it'), assistantMessage('turn-1', 'Done')];
+ const terminalRefresh = new FakeSubscription(
+ continuitySnapshot({ rootTurn: completedTurn('turn-1', 'run-1') }),
+ Promise.resolve(terminalMessages),
+ 'subscription-3',
+ );
+ const connection = new FakeConnection([attached, liveRefresh, terminalRefresh]);
+ const driver = createRuntimeHostMakaSessionDriver({
+ connection: connection.value,
+ cwd: '/tmp',
+ llmConnectionSlug: 'openai-main',
+ model: 'gpt-5',
+ });
+ await driver.switchSession('session-1');
+ const replacements: Array<{ messages: readonly StoredMessage[]; reason: string }> = [];
+ driver.subscribeTranscriptReplacements!((_sessionId, _turnId, messages, reason) => {
+ replacements.push({ messages, reason });
+ });
+
+ attached.push(toolResultFrame(1));
+ await waitFor(() => connection.openedSubscriptions === 2);
+ attached.push(projectionFrame(2, completedTurn('turn-1', 'run-1'), 2));
+ await waitFor(() => replacements.length === 1);
+ assert.deepEqual(replacements, [{ messages: terminalMessages, reason: 'reconcile' }]);
+
+ liveTranscript.resolve([userMessage('turn-1', 'Run it')]);
+ await delay(0);
+ assert.deepEqual(replacements, [{ messages: terminalMessages, reason: 'reconcile' }]);
+ });
+
test('resnapshots an active Session after reconnect and continues its live stream', async () => {
const initial = new FakeSubscription(
continuitySnapshot(),
@@ -1377,7 +1415,7 @@ describe('Runtime Host Maka Session driver', () => {
});
const switched = await driver.switchSession('session-1');
assert.ok(switched.activeTurn);
- const transcript = deferred<StoredMessage[]>();
+ const transcript = deferred<readonly StoredMessage[]>();
driver.subscribeTranscriptReplacements!((_sessionId, _turnId, messages, reason) => {
assert.equal(reason, 'reconnect');
transcript.resolve(messages);
@@ -2257,7 +2295,7 @@ describe('turn consumer lag recovery (#3180)', () => {
});
const switched = await driver.switchSession('session-1');
assert.ok(switched.activeTurn);
- const transcript = deferred<StoredMessage[]>();
+ const transcript = deferred<readonly StoredMessage[]>();
driver.subscribeTranscriptReplacements!((_sessionId, _turnId, messages, reason) => {
assert.equal(reason, 'reconnect');
transcript.resolve(messages);
diff --git a/packages/cli/src/runtime-host-run-command.ts b/packages/cli/src/runtime-host-run-command.ts
index a50ceca5e..18d8f0865 100644
--- a/packages/cli/src/runtime-host-run-command.ts
+++ b/packages/cli/src/runtime-host-run-command.ts
@@ -471,7 +471,7 @@ class RuntimeHostRunRuntime implements MakaRunRuntime {
}
}
- #acceptGraphTranscript(messages: StoredMessage[]): void {
+ #acceptGraphTranscript(messages: readonly StoredMessage[]): void {
const replacement = messages.map((message) => structuredClone(message));
this.#latestTranscriptReplacement = replacement;
for (const [turnId, waiters] of this.#graphTerminalWaiters) {
@@ -484,7 +484,11 @@ class RuntimeHostRunRuntime implements MakaRunRuntime {
}
}
- #acceptRootTranscript(sessionId: string, turnId: string, messages: StoredMessage[]): void {
+ #acceptRootTranscript(
+ sessionId: string,
+ turnId: string,
+ messages: readonly StoredMessage[],
+ ): void {
const active = this.#activeTurn;
if (!active || active.sessionId !== sessionId || active.turnId !== turnId) return;
active.outcome = classifierFromStoredTurn(messages, turnId, active.runId);
diff --git a/packages/cli/src/runtime-host-session-driver.ts b/packages/cli/src/runtime-host-session-driver.ts
index f855c71df..0607c84d9 100644
--- a/packages/cli/src/runtime-host-session-driver.ts
+++ b/packages/cli/src/runtime-host-session-driver.ts
@@ -41,10 +41,7 @@ import type { ThinkingLevel } from '@maka/core/model-thinking';
import type { SkillInvocationResult } from '@maka/core/skill-invocation';
import type { UserQuestionResponse } from '@maka/core/user-question';
import type { ContextDiagnostics } from '@maka/runtime/context-diagnostics';
-import {
- isRuntimeHostTerminalTurn as isTerminalTurn,
- type RuntimeHostTerminalTurn as TerminalTurnSnapshot,
-} from '@maka/runtime-host/adapter';
+import { isRuntimeHostTerminalTurn as isTerminalTurn } from '@maka/runtime-host/adapter';
import type { DirectRequestOperationKey, RuntimeHostConnection } from '@maka/runtime-host/client';
import {
readRuntimeHostResources,
@@ -133,7 +130,7 @@ export interface RuntimeHostMakaSessionDriver extends MakaSessionDriver {
listener: (
sessionId: string,
turnId: string,
- messages: StoredMessage[],
+ messages: readonly StoredMessage[],
reason: MakaTranscriptReplacementReason,
) => void,
): () => void;
@@ -176,7 +173,7 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
readonly #startedTurnReattachTails = new Map<number, Promise<void>>();
#sessionGeneration = 0;
#channelGeneration = 0;
- #liveTranscriptRefreshSequence = 0;
+ #transcriptRefreshSequence = 0;
readonly #startedTurnListeners = new Set<(turn: MakaAttachedSessionTurn) => void>();
readonly #goalListeners = new Set<(goal: GoalProjection | null) => void>();
readonly #pendingInteractionListeners = new Set<(pending: InteractionPendingSnapshot) => void>();
@@ -189,7 +186,7 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
(
sessionId: string,
turnId: string,
- messages: StoredMessage[],
+ messages: readonly StoredMessage[],
reason: MakaTranscriptReplacementReason,
) => void
>();
@@ -634,7 +631,7 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
listener: (
sessionId: string,
turnId: string,
- messages: StoredMessage[],
+ messages: readonly StoredMessage[],
reason: MakaTranscriptReplacementReason,
) => void,
): () => void {
@@ -1028,8 +1025,8 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
for (const listener of this.#pendingInteractionListeners) listener(pending);
},
onInteractionResolved: (pending) => this.#resolveExternalInteraction(pending),
- onTurnTerminal: (turn) => this.#refreshTerminalTranscript(turn),
- onToolResult: (turnId) => this.#refreshLiveTranscript(sessionId, sessionGeneration, turnId),
+ onTurnTerminal: (turn) => this.#refreshTranscript(sessionId, sessionGeneration, turn.turnId),
+ onToolResult: (turnId) => this.#refreshTranscript(sessionId, sessionGeneration, turnId),
onTranscriptReplaced: (turnId, messages) =>
this.#publishTranscriptReplacement(sessionId, turnId, messages, 'reconnect'),
onGoalChanged: (goal) => {
@@ -1072,27 +1069,18 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
.catch(() => undefined);
}
- #refreshTerminalTranscript(turn: TerminalTurnSnapshot): void {
- void loadCurrentMessages(this.#connection, turn.sessionId)
- .then((messages) => {
- if (this.#sessionId !== turn.sessionId) return;
- this.#publishTranscriptReplacement(turn.sessionId, turn.turnId, messages, 'terminal');
- })
- .catch(() => undefined);
- }
-
- #refreshLiveTranscript(sessionId: string, sessionGeneration: number, turnId: string): void {
- const refreshSequence = ++this.#liveTranscriptRefreshSequence;
+ #refreshTranscript(sessionId: string, sessionGeneration: number, turnId: string): void {
+ const refreshSequence = ++this.#transcriptRefreshSequence;
void loadCurrentMessages(this.#connection, sessionId)
.then((messages) => {
if (
this.#sessionId !== sessionId ||
this.#sessionGeneration !== sessionGeneration ||
- refreshSequence !== this.#liveTranscriptRefreshSequence
+ refreshSequence !== this.#transcriptRefreshSequence
) {
return;
}
- this.#publishTranscriptReplacement(sessionId, turnId, messages, 'tool_result');
+ this.#publishTranscriptReplacement(sessionId, turnId, messages, 'reconcile');
})
.catch(() => undefined);
}
@@ -1105,12 +1093,7 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
): void {
if (this.#sessionId !== sessionId) return;
for (const listener of this.#transcriptListeners) {
- listener(
- sessionId,
- turnId,
- messages.map((message) => structuredClone(message)),
- reason,
- );
+ listener(sessionId, turnId, messages, reason);
}
}
diff --git a/packages/cli/src/session-driver.ts b/packages/cli/src/session-driver.ts
index 701fca53d..42e179efa 100644
--- a/packages/cli/src/session-driver.ts
+++ b/packages/cli/src/session-driver.ts
@@ -123,7 +123,7 @@ export interface MakaSessionDriver {
listener: (
sessionId: string,
turnId: string,
- messages: StoredMessage[],
+ messages: readonly StoredMessage[],
reason: MakaTranscriptReplacementReason,
) => void,
): () => void;
@@ -176,7 +176,7 @@ export type CreateSessionRequest = Omit<CreateSessionInput, 'permissionMode'> &
permissionMode?: PermissionMode;
};
-export type MakaTranscriptReplacementReason = 'terminal' | 'reconnect' | 'tool_result';
+export type MakaTranscriptReplacementReason = 'reconcile' | 'reconnect';
export type SessionResumeAvailability = { available: true } | { available: false; reason: string };
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org