fix(kugetsu): session detection ordering bug and debugging #108

Merged
shoko merged 1 commits from fix/session-detection-v2 into main 2026-04-02 12:26:58 +02:00
Owner

Summary

  • Move session detection BEFORE checking if fork process is still running
  • Add database query debugging when detection fails

Problem

The previous code broke out of the polling loop if the forked process exited, before running session detection. Since opencode run --fork completes quickly (it spawns a child session and exits), the detection was being skipped entirely.

This is why the 10-second retry wasn't helping - we were exiting early on every iteration.

Also Note

For the permission issue (external_directory auto-rejecting), run:

kugetsu doctor --fix-permissions

This updates base and PM agent sessions to allow external_directory access to kugetsu directories.

Testing

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

## Summary - Move session detection BEFORE checking if fork process is still running - Add database query debugging when detection fails ## Problem The previous code broke out of the polling loop if the forked process exited, **before** running session detection. Since `opencode run --fork` completes quickly (it spawns a child session and exits), the detection was being skipped entirely. This is why the 10-second retry wasn't helping - we were exiting early on every iteration. ## Also Note For the permission issue (external_directory auto-rejecting), run: ```bash kugetsu doctor --fix-permissions ``` This updates base and PM agent sessions to allow `external_directory` access to kugetsu directories. ## Testing Test with: `kugetsu start git.fbrns.co/shoko/jigaido#2 "your message"`
shoko added 1 commit 2026-04-02 11:57:48 +02:00
1. Move session detection BEFORE checking if fork process is still running.
   Previous code broke out of loop if forked process exited, skipping detection.

2. Add database query debugging when detection fails to help diagnose
   why opencode session list might miss newly created sessions.
han approved these changes 2026-04-02 12:26:11 +02:00
han left a comment
First-time contributor

lgtm

lgtm
shoko merged commit 97d7511e56 into main 2026-04-02 12:26:58 +02:00
Sign in to join this conversation.