Skip to content

feat: report blocked prompts via Program Status Protocol - #129

Merged
rawnly merged 1 commit into
mainfrom
feat/prompt-status
Oct 21, 2026
Merged

rawnly merged 1 commit into
mainfrom
feat/prompt-status

Conversation

@rawnly

@rawnly rawnly commented Oct 21, 2026 •

Copy link
Copy Markdown
Owner

Why the change

Terminals and agent dashboards can't tell when splash-cli is waiting for the user, so this PR reports blocked prompts through the Program Status Protocol so they can show "needs input".

Special things to note

  • Reports are best-effort: they are only sent when stdout is a real terminal (not piped, not TERM=dumb), and terminals that don't know OSC 7501 ignore them.
  • Messages are cut at 2048 bytes, which is the protocol limit. This can split a multi-byte character.
  • Two small fixes are included: a "no photos found" error instead of a nil photo crash, and removal of duplicate viper.WriteConfig() calls in login.go and root.go.

Change outline

A new helper sends the status; each prompt wraps its wait with it.

lib/terminal/
+├── status.go        # Blocked(kind, msg) -> resume(); writes OSC 7501
+└── status_test.go   # truncation and message encoding
\x1b]7501;state=blocked:app=splash-cli:kind=<kind>:msg=<base64>\x1b\\   when a prompt opens
\x1b]7501;state=working:app=splash-cli\x1b\\                              when it closes

Prompts that now report:

 rootCmd.Run
   permission prompt (survey)
+    Blocked("permission", ...)
   download failed: GetSingleKey
+    Blocked("permission", ...)
   like photo? (survey)
+    Blocked("question", ...)
 loginCmd.Run
   wait for browser code
+    Blocked("auth", ...)

Smaller fixes in the same files:

 rootCmd.Run
+  if photo == nil
+    error "no photos found"
 loginCmd.Run / rootCmd.Run
-  viper.WriteConfig()   # duplicate write

Also guard against empty photo results and drop a duplicate config write.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 15:04
@rawnly
rawnly merged commit ddeb687 into main Oct 21, 2026
6 checks passed
@rawnly
rawnly deleted the feat/prompt-status branch October 21, 2026 15:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Terminal detection admits non-terminal devices, and download-fallback status reporting is unreachable.

2 open issues
What changed in this PR

Adds Program Status Protocol reporting so terminals and dashboards can identify when splash-cli needs user input.

Changes:

  • Adds blocked/working status reporting and message tests.
  • Instruments permission, confirmation, and login waits.
  • Handles missing photos and removes duplicate configuration writes.
File Description
lib/​terminal/​status.go Adds terminal status reporting and message truncation.
lib/​terminal/​status_test.go Tests truncation and Base64 encoding.
cmd/​root.go Instruments prompts, handles missing photos, and removes a duplicate write.
cmd/​auth/​login.go Reports the authentication wait and removes a duplicate write.

Review effort: Balanced

Comment thread cmd/root.go
fmt.Println("")

var key keyboard.Key
resume := terminal.Blocked("permission", "Download failed. Set wallpaper from the URL?")
Comment thread lib/terminal/status.go
Comment on lines +38 to +39
info, err := os.Stdout.Stat()
return err == nil && info.Mode()&os.ModeCharDevice != 0 && os.Getenv("TERM") != "dumb"
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