fix(kugetsu): improve session detection in cmd_start with retry logic and logging #107

Merged
shoko merged 2 commits from fix/start-session-detection into main 2026-04-02 11:41:53 +02:00
Owner

Summary

  • Capture fork output to .fork.log for debugging
  • Track fork PID to detect if process exits early
  • Retry session detection up to 10 seconds instead of 1 second
  • Show fork log output when session creation fails
  • Improve error message to indicate timeout

Problem

When running kugetsu start, the session detection only waited 1 second before giving up. If opencode run --fork took longer to register the session, the command would fail with "Could not find newly created session".

This is why kugetsu delegate worked (uses existing session with --continue) but kugetsu start failed (creates new session with --fork).

Testing

Test with: kugetsu start git.fbrns.co/shoko/jigaido#2 "your message"

If it fails, the fork log will now show the actual output from opencode run.

## Summary - Capture fork output to `.fork.log` for debugging - Track fork PID to detect if process exits early - Retry session detection up to 10 seconds instead of 1 second - Show fork log output when session creation fails - Improve error message to indicate timeout ## Problem When running `kugetsu start`, the session detection only waited 1 second before giving up. If `opencode run --fork` took longer to register the session, the command would fail with "Could not find newly created session". This is why `kugetsu delegate` worked (uses existing session with `--continue`) but `kugetsu start` failed (creates new session with `--fork`). ## Testing Test with: `kugetsu start git.fbrns.co/shoko/jigaido#2 "your message"` If it fails, the fork log will now show the actual output from `opencode run`.
shoko added 1 commit 2026-04-02 11:31:30 +02:00
- Capture fork output to log file for debugging
- Track fork PID to detect if process exits early
- Retry session detection up to 10 seconds instead of 1 second
- Show fork log output when session creation fails
- Improve error message to indicate timeout
han approved these changes 2026-04-02 11:36:56 +02:00
Dismissed
han left a comment
First-time contributor

lgtm

lgtm
shoko added 1 commit 2026-04-02 11:39:52 +02:00
Resolve conflict: use cd approach for worktree, keep retry logic
han approved these changes 2026-04-02 11:41:13 +02:00
han left a comment
First-time contributor

lgtm

lgtm
shoko merged commit ffdf5e34c8 into main 2026-04-02 11:41:53 +02:00
Sign in to join this conversation.