Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fa1c2cf
feat(cli): add one-shot user commands
me2seeks Aug 18, 2026
e41468b
fix(cli): own user command teardown
me2seeks Aug 19, 2026
c711a3c
fix(cli): hint bare user commands
me2seeks Aug 19, 2026
f3376bc
fix(cli): clarify user command hint
me2seeks Aug 19, 2026
48ab966
fix(cli): streamline user command hint
me2seeks Aug 19, 2026
5843a94
fix(cli): keep user command output expanded
me2seeks Aug 19, 2026
9ba0b59
fix(cli): stop user commands before leaving their Session
me2seeks Aug 20, 2026
c7c6fdd
fix(cli): isolate user-command stop failures and gate the widened sta…
me2seeks Aug 20, 2026
e2052a7
fix(cli): reconcile user command cards with main's transcript authority
me2seeks Aug 24, 2026
b5d18be
fix(cli,runtime-host): make /new abortable and one-shot starts self-c…
me2seeks Aug 24, 2026
4118817
style: format pi-transcript
me2seeks Aug 25, 2026
a176d13
style: fix formatting
me2seeks Aug 25, 2026
2e5d944
fix(cli): drop retired lastUsedAt from driver tests
me2seeks Aug 25, 2026
f6139ef
chore: retrigger CI
me2seeks Aug 25, 2026
79687b0
Merge origin/main into PR 3210 review
me2seeks Aug 25, 2026
003e132
test(runtime-host): pin one-shot command epoch beyond main
me2seeks Aug 25, 2026
c523c40
Merge remote-tracking branch 'origin/main' into HEAD
me2seeks Aug 25, 2026
ef3e75d
Merge remote-tracking branch 'origin/main' into HEAD
me2seeks Aug 25, 2026
f5b5384
Merge origin/main into feat/cli-user-shell-mode
me2seeks Aug 26, 2026
55ae299
Merge remote-tracking branch 'origin/main' into HEAD
me2seeks Aug 26, 2026
74230ed
Merge remote-tracking branch 'origin/main' into HEAD
me2seeks Aug 26, 2026
61a0a5c
chore(cli): format session driver imports
me2seeks Aug 26, 2026
1d9c615
chore: retrigger pull request checks
me2seeks Aug 26, 2026
e030f03
Merge remote-tracking branch 'origin/main' into HEAD
me2seeks Aug 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 151 additions & 1 deletion packages/cli/src/__tests__/pi-transcript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import { describe, test } from 'node:test';
import { visibleWidth } from '@earendil-works/pi-tui';
import type { PipeShellOutput, PtyShellOutput } from '@maka/core/shell-run';
import type { ShellRunToolResult } from '@maka/core/shell-run-result';
import type { SessionEvent, ToolResultContent } from '@maka/core/events';
import type { SessionEvent, ShellRunSnapshotResult, ToolResultContent } from '@maka/core/events';
import type { StoredMessage } from '@maka/core/session';
import {
appendUserCommandToTranscript,
appendUserPrompt,
applyShellRunViewUpdateToTranscript,
applyMakaSessionEventToTranscript,
Expand Down Expand Up @@ -2940,6 +2941,155 @@ describe('Maka Pi TUI transcript', () => {
);
});

test('updates a local user command card from its Runtime Resource', () => {
const state = createMakaPiTranscriptState();
const ref = 'maka://runtime/background-tasks/user-command-1';
appendUserCommandToTranscript(state, {
commandId: 'user-command-1',
command: 'pwd',
result: shellRun({ ref, status: 'running', stdout: '' }) as ShellRunSnapshotResult,
});

const applied = applyShellRunViewUpdateToTranscript(state, {
sessionId: 'session-1',
ownership: { kind: 'local' },
sourceTurnId: 'user-command-1',
sourceToolCallId: 'user-command-1',
result: shellRun({
ref,
status: 'completed',
stdout: '/repo\n',
completedAt: 2_000,
exitCode: 0,
}),
});

assert.equal(applied, true);
const tool = state.entries.find((entry) => entry.kind === 'tool');
assert.equal(tool?.toolName, 'User command');
assert.equal(tool?.callStatus, 'completed');
assert.equal(tool?.expanded, true);
const shellResult = tool?.result;
assert.equal(
shellResult?.kind === 'shell_run' && shellResult.mode === 'pipes'
? shellResult.output?.stdout
: '',
'/repo\n',
);
assert.equal(
state.entries.some((entry) => entry.kind === 'notice'),
false,
);
});

test('keeps user commands expanded and outside Ctrl+O model-tool toggles', () => {
const state = createMakaPiTranscriptState();
appendUserCommandToTranscript(state, {
commandId: 'user-command-1',
command: 'printf done',
result: shellRun({
ref: 'maka://runtime/background-tasks/user-command-1',
status: 'completed',
stdout: 'done\n',
completedAt: 2_000,
exitCode: 0,
}) as ShellRunSnapshotResult,
});
applyMakaSessionEventToTranscript(
state,
event({
type: 'tool_start',
toolUseId: 'model-tool-1',
toolName: 'Bash',
args: { command: 'printf model' },
}),
);
const tools = state.entries.filter((entry) => entry.kind === 'tool');
const userCommand = tools.find((entry) => entry.userOwned === true);
const modelTool = tools.find((entry) => entry.userOwned !== true);
assert.ok(userCommand && modelTool);
assert.equal(userCommand.expanded, true);
assert.equal(modelTool.expanded, false);

assert.equal(toggleAllToolExpansion(state), true);
assert.equal(userCommand.expanded, true);
assert.equal(modelTool.expanded, true);
assert.equal(toggleAllToolExpansion(state), true);
assert.equal(userCommand.expanded, true);
assert.equal(modelTool.expanded, false);
});

test('preserves local user-command cards only for same-session reconnect replacement', () => {
const state = createMakaPiTranscriptState();
appendUserCommandToTranscript(state, {
commandId: 'user-command-1',
command: 'sleep 60',
result: shellRun({
ref: 'maka://runtime/background-tasks/user-command-1',
status: 'running',
stdout: '',
}) as ShellRunSnapshotResult,
});

replaceTranscriptWithStoredMessages(state, [], { preserveClientLocalEntries: true });
assert.equal(
state.entries.some((entry) => entry.kind === 'tool' && entry.userOwned === true),
true,
);

replaceTranscriptWithStoredMessages(state, []);
assert.equal(
state.entries.some((entry) => entry.kind === 'tool' && entry.userOwned === true),
false,
);
});

test('reconnect re-inserts preserved user-command cards at their chronological position (#3210)', () => {
const state = createMakaPiTranscriptState();
// The command ran before the model turns that followed it.
appendUserCommandToTranscript(state, {
commandId: 'user-command-1',
command: 'pwd',
result: shellRun({
ref: 'maka://runtime/background-tasks/user-command-1',
status: 'completed',
stdout: '/repo\n',
startedAt: 1_000,
}) as ShellRunSnapshotResult,
});

replaceTranscriptWithStoredMessages(
state,
[
{ type: 'user', id: 'message-1', turnId: 'turn-1', ts: 2_000, text: 'later prompt' },
{
type: 'assistant',
id: 'message-2',
turnId: 'turn-1',
ts: 3_000,
text: 'later answer',
modelId: 'model-1',
},
],
{ preserveClientLocalEntries: true },
);

const cardIndex = state.entries.findIndex(
(entry) => entry.kind === 'tool' && entry.userOwned === true,
);
const promptIndex = state.entries.findIndex((entry) =>
JSON.stringify(entry).includes('later prompt'),
);
const answerIndex = state.entries.findIndex((entry) =>
JSON.stringify(entry).includes('later answer'),
);
assert.notEqual(cardIndex, -1);
assert.notEqual(promptIndex, -1);
assert.notEqual(answerIndex, -1);
assert.ok(cardIndex < promptIndex, 'card must stay ahead of the later turn');
assert.ok(promptIndex < answerIndex);
});

test('notifies a settle exactly once across a folded poll and the live update', () => {
const state = createMakaPiTranscriptState();
const ref = 'maka://runtime/background-tasks/bg-1';
Expand Down
Loading