The server should remember recently submitted user inputs so interactive clients
can recall recent inputs into their editor. The immediate TUI behavior is:
when the normal input box is focused, the first Up restores the latest
submitted input for the current project, repeated Up presses walk to older
inputs, and Down walks back toward newer inputs before restoring the original
draft. This must keep working even when the transcript above the prompt can
scroll, and while a model turn is still streaming output and new input would be
queued.
Input history is server/session state, not TUI state.
Up into a recallPreviousInput client intent and renders the
returned text in the input box.Up/Down to transcript scrollback.
Transcript keyboard scrollback uses PageUp/PageDown so the prompt editor
and scrollback viewport do not compete for the same direction keys.The renderer must not read SQLite, derive project ids, or keep a durable history list in React/Ink component state.
First version behavior:
projectID.skip, where 0 means the latest entry, 1
means the next older entry, and so on.Stored inputs may include normal prompts, active-turn steering inputs, and
accepted slash commands. Slash commands are not a model message contract, so the
command center records the raw command text through a best-effort input-history
port after a command is successfully handled. This includes local commands such
as /help when an input-history source is available, so Up can recall the
command the user actually typed instead of an expanded prompt. Commands that may
contain secrets, such as /login ... <api-key>, must not be recorded.
type InputHistoryKind = "prompt" | "steered_input" | "slash_command";
interface InputHistoryEntry {
id: string;
projectID: ProjectId;
sessionID?: SessionId;
text: string;
kind: InputHistoryKind;
time: {
created: number;
};
}
interface InputHistoryStorePort {
recordInputHistory(input: {
projectID: ProjectId;
sessionID?: SessionId;
text: string;
kind: InputHistoryKind;
time?: { created?: number };
}): Promise<InputHistoryEntry | null>;
recallPreviousInput(input: {
projectID: ProjectId;
skip?: number;
}): Promise<InputHistoryEntry | null>;
}
recordInputHistory returns null for blank input or consecutive duplicate
input in the same project. recallPreviousInput returns null when skip
points past the oldest entry for the project.
Input history uses the existing session SQLite database, controlled by
storage.sessionDbPath. No new ZCODE_ environment variable is introduced.
create table input_history (
id text primary key,
project_id text not null,
session_id text,
text text not null,
kind text not null,
time_created integer not null
);
create index input_history_project_time_idx
on input_history(project_id, time_created desc, id desc);
create index input_history_time_idx
on input_history(time_created desc, id desc);
The adapter trims after each insert:
delete from input_history
where id not in (
select id from input_history
order by time_created desc, id desc
limit 100
);
The retention limit is global, not per project.
skip > 0./help as
slash_command when a history source is available.recallPreviousInput on Up in the normal input state, including
while a model turn is busy, and places the returned text into the input box.Up and restores newer history or the
original draft on Down.Up after long output creates transcript
overflow.Up while model output is streaming.Up/Down; PageUp
and PageDown remain the keyboard scrollback controls.Up/Down behavior.