Skip to content

Add Semantic Block Protocol (DEC Mode 2034) with SBQUERY#1900

Merged
christianparpart merged 1 commit intomasterfrom
feature/vt-screen-reader
Feb 26, 2026
Merged

Add Semantic Block Protocol (DEC Mode 2034) with SBQUERY#1900
christianparpart merged 1 commit intomasterfrom
feature/vt-screen-reader

Conversation

@christianparpart
Copy link
Member

@christianparpart christianparpart commented Feb 23, 2026

  • Introduce DEC Private Mode 2034 to enable semantic block tracking via OSC 133 shell integration sequences, storing command metadata (command line, exit code, prompt/output text) alongside line flags (OutputStart, CommandEnd) in the grid ring buffer.
  • Add the SBQUERY sequence (CSI > Ps ; Pn b) that returns structured JSON via DCS responses, supporting three query types: last completed command (Ps=1), last N completed commands (Ps=2), and current in-progress command (Ps=3). Query type values use named SBQueryType constants to avoid magic numbers.
  • Include SemanticBlockTracker class, full test coverage (8 test cases / 27 assertions), and a protocol specification document at docs/vt-extensions/semantic-block-query.md.

@Yaraslaut Background story: I need that for endo to be able to let the shell agent read the output of the last executed command.

@christianparpart christianparpart added the no changelog Tells the CI to not require a changelog entry label Feb 23, 2026
@github-actions github-actions bot added documentation Improvements or additions to documentation VT: Backend Virtual Terminal Backend (libterminal API) test Unit tests labels Feb 23, 2026
@github-actions github-actions bot added the CI GitHub Actions & CI label Feb 23, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces the Semantic Block Protocol (DEC Mode 2034) that enables programmatic querying of shell command history through structured JSON responses. The implementation tracks OSC 133 shell integration sequences and provides a query mechanism via the new SBQUERY sequence (CSI > Ps ; Pn b) to retrieve command metadata including command line, exit code, prompt text, and output text.

Changes:

  • Added DEC Private Mode 2034 to enable/disable semantic block tracking with line flags (OutputStart, CommandEnd) stored in the grid buffer alongside command metadata
  • Implemented SBQUERY sequence supporting three query types: last completed command, last N completed commands, and current in-progress command, with DCS-formatted JSON responses
  • Included comprehensive test suite (8 test cases, 27 assertions) covering mode toggling, metadata tracking, DECRQM reporting, and all query types

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/vtbackend/primitives.h Added DECMode::SemanticBlockProtocol (2034) enum value and bidirectional conversion functions
src/vtbackend/Terminal.h Added SemanticBlockTracker member and accessor methods to Terminal class
src/vtbackend/Terminal.cpp Integrated mode 2034 handling in setMode() and added string conversion for the new mode
src/vtbackend/SemanticBlockTracker.h New header defining CommandBlockInfo, SBQueryType constants, and SemanticBlockTracker class
src/vtbackend/SemanticBlockTracker.cpp Implementation of semantic block tracking with state management for completed and in-progress commands
src/vtbackend/Screen.h Added handleSemanticBlockQuery() method declaration
src/vtbackend/Screen.cpp Implemented handleSemanticBlockQuery() with backward grid scanning, JSON generation, and integrated tracker calls into processShellIntegration()
src/vtbackend/Line.h Added OutputStart and CommandEnd line flags for semantic block boundaries
src/vtbackend/Functions.h Added SBQUERY function definition with proper CSI parameters
src/vtbackend/ShellIntegration_test.cpp Added 8 test cases covering line flags, metadata tracking, DECRQM, and all query scenarios
src/vtbackend/CMakeLists.txt Added SemanticBlockTracker source and header files to build
docs/vt-extensions/semantic-block-query.md Complete protocol specification with syntax, response format, JSON schema, and examples
mkdocs.yml Added documentation page to navigation
.github/actions/spelling/expect.txt Added expected spelling exceptions for new terminology

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@Yaraslaut Yaraslaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some points

@christianparpart christianparpart force-pushed the feature/vt-screen-reader branch 2 times, most recently from dc324b6 to 7e30bb5 Compare February 23, 2026 09:25
Add token-based authentication to SBQUERY: DECSET 2034 now generates a
64-bit session token (4 x uint16) and replies via DCS. Every SBQUERY must
include the token as CSI parameters 2..5. Missing token returns status 2,
wrong token returns status 3. Token is invalidated on DECRST and
regenerated on re-enable.

Signed-off-by: Christian Parpart <christian@parpart.family>
Copy link
Member

@Yaraslaut Yaraslaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great additions, thanks

@christianparpart christianparpart merged commit 138e0ac into master Feb 26, 2026
61 of 62 checks passed
@christianparpart christianparpart deleted the feature/vt-screen-reader branch February 26, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI GitHub Actions & CI documentation Improvements or additions to documentation no changelog Tells the CI to not require a changelog entry test Unit tests VT: Backend Virtual Terminal Backend (libterminal API)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants