fix: suppress opencode fork stdout and strip ANSI codes from logs #197

Merged
shoko merged 1 commits from fix/issue-session-id-and-log-cleanup into main 2026-04-07 04:58:15 +02:00
Owner

Bugs Fixed

1. Session ID corruption in create_session

Problem: opencode run --fork outputs the session title to stdout, which was being captured and stored as the session ID.

Example of corrupted session file:

{"opencode_session_id": "Ready. What do you need help with?\nses_29a621116ffeZSNMtSGFajGPaT", ...}

Fix: Suppress stdout from opencode run --fork --session ... "new session" >/dev/null 2>&1

2. ANSI codes in logs

Problem: Logs contained ANSI escape codes (^[[0m), command prompts, and noise.

Fix: Added strip_ansi_codes() function and updated cmd_logs to clean output.

3. mask_sensitive_vars empty input bug

Fix: Changed $1 to ${1:-} to handle empty input gracefully.

Changes

  • kugetsu-session.sh: Suppress stdout from opencode run --fork
  • kugetsu-config.sh: Add strip_ansi_codes() function
  • kugetsu-log.sh: Strip ANSI codes in cmd_logs output
## Bugs Fixed ### 1. Session ID corruption in create_session **Problem:** `opencode run --fork` outputs the session title to stdout, which was being captured and stored as the session ID. **Example of corrupted session file:** ```json {"opencode_session_id": "Ready. What do you need help with?\nses_29a621116ffeZSNMtSGFajGPaT", ...} ``` **Fix:** Suppress stdout from `opencode run --fork --session ... "new session" >/dev/null 2>&1` ### 2. ANSI codes in logs **Problem:** Logs contained ANSI escape codes (`^[[0m`), command prompts, and noise. **Fix:** Added `strip_ansi_codes()` function and updated `cmd_logs` to clean output. ### 3. mask_sensitive_vars empty input bug **Fix:** Changed `$1` to `${1:-}` to handle empty input gracefully. ## Changes - `kugetsu-session.sh`: Suppress stdout from `opencode run --fork` - `kugetsu-config.sh`: Add `strip_ansi_codes()` function - `kugetsu-log.sh`: Strip ANSI codes in `cmd_logs` output
shoko added 1 commit 2026-04-07 04:44:19 +02:00
1. Fix create_session: suppress stdout from 'opencode run --fork'
   - Previously stdout was showing session title which corrupted session ID storage

2. Add strip_ansi_codes() function to clean ANSI escape sequences

3. Update cmd_logs to strip ANSI codes before displaying

4. Fix mask_sensitive_vars to handle empty input gracefully
First-time contributor

lgtm

lgtm
shoko merged commit aafdebb6c6 into main 2026-04-07 04:58:15 +02:00
Sign in to join this conversation.