Skip to content

Add wsh debugterm#2947

Merged
sawka merged 9 commits intomainfrom
copilot/add-wsh-debugterm-command
Feb 27, 2026
Merged

Add wsh debugterm#2947
sawka merged 9 commits intomainfrom
copilot/add-wsh-debugterm-command

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

wsh debugterm currently decodes terminal bytes sourced from backend block files. This extends it with a stdin-driven path so FE-emitted payloads like ["...", "..."] can be decoded directly without requiring block lookup/RPC in that mode.

  • CLI surface

    • Added new mode: --mode stdin
    • Updated mode help text to: hex, decode, stdin
    • Centralized mode validation via getDebugTermMode()
  • Execution path split

    • Added mode-aware pre-run (debugTermPreRun):
      • stdin mode: skips RPC setup
      • hex/decode: keeps existing RPC setup behavior
    • stdin mode now:
      • reads all stdin
      • parses JSON as []string
      • concatenates entries and runs existing decode formatter
  • Parsing support

    • Added parseDebugTermStdinData([]byte) ([]byte, error)
    • Error messaging explicitly requires a JSON array of strings
  • Tests

    • Added focused coverage for:
      • valid stdin JSON array parsing + decoded output
      • invalid stdin JSON input
stdinData, _ := io.ReadAll(WrappedStdin)
termData, err := parseDebugTermStdinData(stdinData) // expects []string JSON
if err != nil { return err }
WriteStdout("%s", formatDebugTermDecode(termData))

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 27, 2026

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4db8c15
Status: ✅  Deploy successful!
Preview URL: https://8c2c280a.waveterm.pages.dev
Branch Preview URL: https://copilot-add-wsh-debugterm-co.waveterm.pages.dev

View logs

Copilot AI and others added 2 commits February 27, 2026 01:36
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Copilot AI changed the title [WIP] Add hidden wsh debugterm command for terminal output Add hidden wsh debugterm command for terminal tail byte inspection (hex/decode) Feb 27, 2026
Copilot AI and others added 3 commits February 27, 2026 02:48
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Copilot AI changed the title Add hidden wsh debugterm command for terminal tail byte inspection (hex/decode) Add wsh debugterm --mode stdin to decode FE-emitted JSON string arrays Feb 27, 2026
@sawka sawka changed the title Add wsh debugterm --mode stdin to decode FE-emitted JSON string arrays Add wsh debugterm Feb 27, 2026
@sawka sawka marked this pull request as ready for review February 27, 2026 18:20
if readSize > dataLength {
readSize = dataLength
}
readOffset := waveFile.Size - readSize
Copy link
Contributor

Choose a reason for hiding this comment

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

CRITICAL: Incorrect offset calculation for circular files

This line uses waveFile.Size - readSize which is incorrect for circular files. When a terminal file is circular and Size > MaxSize, this calculation will produce an offset beyond the actual available data.

The correct calculation should account for the data start index:

readOffset := waveFile.DataStartIdx() + dataLength - readSize

This ensures:

  • For regular files: DataStartIdx() returns 0, so it becomes dataLength - readSize (equivalent to Size - readSize)
  • For circular files: It correctly accounts for the starting index of available data, preventing out-of-bounds reads

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 27, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 1
WARNING 0
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue
pkg/wshrpc/wshserver/wshserver.go 829 Incorrect offset calculation for circular files - uses waveFile.Size - readSize instead of waveFile.DataStartIdx() + dataLength - readSize
Files Reviewed (6 files)
  • cmd/wsh/cmd/wshcmd-debugterm.go - New file, no issues
  • cmd/wsh/cmd/wshcmd-debugterm_test.go - New file, no issues
  • frontend/app/store/wshclientapi.ts - Generated file, no issues
  • frontend/types/gotypes.d.ts - Generated file, no issues
  • pkg/wshrpc/wshclient/wshclient.go - Generated file, no issues
  • pkg/wshrpc/wshserver/wshserver.go - 1 critical issue

Fix these issues in Kilo Cloud

@sawka sawka merged commit b2f3129 into main Feb 27, 2026
6 checks passed
@sawka sawka deleted the copilot/add-wsh-debugterm-command branch February 27, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants