wavetermdev/waveterm · error
Cannot get last command data without shell integration
Error message
Cannot get last command data without shell integration
What it means
When a termgetscrollbacklines request asks for lastcommand metadata, the terminal must have shell integration active (prompt markers/command tracking). If the shell integration status atom is null, no such data can be derived, so the handler throws instead of returning wrong boundaries.
Source
Thrown at frontend/app/view/term/term-wsh.tsx:127
rh: RpcResponseHelper,
data: CommandTermGetScrollbackLinesData
): Promise<CommandTermGetScrollbackLinesRtnData> {
const termWrap = this.model.termRef.current;
if (!termWrap || !termWrap.terminal) {
return {
totallines: 0,
linestart: data.linestart,
lines: [],
lastupdated: 0,
};
}
const buffer = termWrap.terminal.buffer.active;
const totalLines = buffer.length;
if (data.lastcommand) {
if (globalStore.get(termWrap.shellIntegrationStatusAtom) == null) {
throw new Error("Cannot get last command data without shell integration");
}
let startBufferIndex = 0;
let endBufferIndex = totalLines;
if (termWrap.promptMarkers.length > 0) {
// The last marker is the current prompt, so we want the second-to-last for the previous command
// If there's only one marker, use it (edge case for first command)
const markerIndex =
termWrap.promptMarkers.length > 1
? termWrap.promptMarkers.length - 2
: termWrap.promptMarkers.length - 1;
const commandStartMarker = termWrap.promptMarkers[markerIndex];
startBufferIndex = commandStartMarker.line;
// End at the last marker (current prompt) if there are multiple markers
if (termWrap.promptMarkers.length > 1) {
const currentPromptMarker = termWrap.promptMarkers[termWrap.promptMarkers.length - 1];
endBufferIndex = currentPromptMarker.line;View on GitHub (pinned to a4447c1563)
Solutions
- Enable/install shell integration for the running shell (source the provided integration script in the shell rc).
- Retry only after shellIntegrationStatusAtom is non-null; poll or subscribe instead of assuming.
- Set lastcommand:false (or omit it) if you only need raw scrollback lines.
- Verify the shell/term environment actually reports integration status (check termWrap.shellIntegrationStatusAtom).
Example fix
// before
const lines = await RpcApi.TermGetScrollbackLines(controller, { lastcommand: true });
// after
const hasIntegration = globalStore.get(termWrap.shellIntegrationStatusAtom) != null;
const lines = await RpcApi.TermGetScrollbackLines(controller, { lastcommand: hasIntegration }); Defensive patterns
Strategy: fallback
Validate before calling
const status = globalStore.get(termWrap.shellIntegrationStatusAtom);
if (data.lastcommand && status == null) {
// degrade: request without lastcommand metadata
data = { ...data, lastcommand: false };
} Type guard
function hasShellIntegration(termWrap: TermWrap): boolean {
return globalStore.get(termWrap.shellIntegrationStatusAtom) != null;
} Try / catch
try {
return await getScrollbackLines(data);
} catch (e) {
if (String(e.message).includes("without shell integration")) {
// fall back to plain scrollback without last-command boundaries
return await getScrollbackLines({ ...data, lastcommand: false });
}
throw e;
} Prevention
- Install Wave's shell-integration hooks in all shells you use (including remote/ssh).
- Check shellIntegrationStatusAtom before requesting command metadata.
- Design callers to degrade gracefully to raw scrollback when integration is absent.
When it happens
Trigger: Requesting scrollback with lastcommand:true while the shell lacks integration (plain bash/sh without osc prompt hooks), the integration script failed to load, or the terminal just started and status was never set.
Common situations: Using minimal/ exotic shells without Wave's shell-integration hooks, connecting over ssh without the integration being injected, or users disabling shell integration in settings.
Related errors
- creating new terminal block: %w
- block %s is not a terminal block (view type: %s)
- error getting terminal scrollback: %w
- count must be positive
- failed to get terminal scrollback: %w
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/d882d1c1a8ac302a.
Report an issue: GitHub.