Skip to content

Fix life.occ display buffering and ALT busy-wait#92

Merged
associate-1 merged 1 commit intomainfrom
fix/life-display-and-alt-busywait-72
Feb 24, 2026
Merged

Fix life.occ display buffering and ALT busy-wait#92
associate-1 merged 1 commit intomainfrom
fix/life-display-and-alt-busywait-72

Conversation

@associate-1
Copy link
Member

Summary

Fixes the two bugs preventing the Game of Life editor mode from working (#72):

  • Auto-flush screen output on channel drain: The buffered writer now flushes when len(ch) == 0, so small writes (cursor movements, single characters) appear immediately instead of waiting for the 4096-byte buffer to fill
  • Dual-select pattern for guarded SKIP in ALT: When a SKIP guard is false, the generated select omits default: so it blocks on channel cases instead of busy-waiting at 100% CPU

Test plan

  • All existing tests pass (go test ./...)
  • New TestE2E_AltGuardedSkipFalseBlocking verifies ALT blocks when SKIP guard is false (uses relay channel to force sender delay)
  • life.occ transpiles and passes go vet
  • Manual test: go run /tmp/life.go — e→arrows→*→q→r works

🤖 Generated with Claude Code

Two bugs prevented the Game of Life editor mode from working:

1. Screen output goroutine never flushed for small writes. Add
   auto-flush when the channel drains (len(ch) == 0), so bursts
   of output flush immediately while still batching rapid writes.

2. Guarded SKIP in ALT generated unconditional `default:` in select,
   causing 100% CPU spin when the guard was false. Use a dual-select
   pattern: when guard is true, include default (non-blocking); when
   false, omit default (blocks on channels).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@associate-1 associate-1 merged commit 0c15516 into main Feb 24, 2026
1 check passed
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