-
-
Couldn't load subscription status.
- Fork 100
chore: optimize rendering code #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Fix typo in struct name and all related function signatures to use the correct name. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Remove duplicate optimization code from ui/screen.go, ui/tcell.go, and app/dry.go. This restores the original implementation to prepare for proper migration strategy. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add ScreenRenderer interface to enable both Screen and OptimizedScreen implementations. Update method signatures to return interface type for compatibility during migration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add NewScreenWithOptimization function that can switch between Screen and OptimizedScreen implementations based on UseOptimizedScreen flag. This enables gradual rollout testing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add --optimized-screen flag to enable testing of optimized screen implementation. Currently limited to Screen implementation due to interface compatibility requirements. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add compatibility methods to screen wrapper to satisfy appui.ScreenBuffererRender interface requirements after ScreenRenderer interface introduction. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add missing newlines and fix formatting per make fmt requirements. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces an optional OptimizedScreen implementation with finer-grained locking and lock-free fast paths, refactors the original Screen to a ScreenRenderer interface, and adds a CLI flag to toggle optimization.
- Add
OptimizedScreenwith separate render/config locks and atomic fields - Define
ScreenRendererinterface and factoryNewScreenWithOptimization - Update
main.goandapp/dry.goto wire up the new implementation and CLI flag
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/screen_optimized.go | New OptimizedScreen implementation using separate locks & atomic |
| ui/screen.go | ScreenRenderer interface definition, update Screen methods |
| main.go | Add --optimized-screen flag, use factory and type assertion |
| app/dry.go | Adapt wrapper methods to new interface |
| SCREEN_OPTIMIZATION.md | Documentation on lock contention fix and migration guide |
| CLAUDE.md | AI guidance file (unrelated to core rendering functionality) |
Comments suppressed due to low confidence (1)
SCREEN_OPTIMIZATION.md:22
- The doc mentions a
stateLockfield that doesn't exist inOptimizedScreen. Update this section to reflect the actual fields (renderLock,configLock, atomicclosinganddimensions).
stateLock sync.RWMutex // For closing and dimensions (unused now)
| screen.screen.SetCell(x, y, style, r) | ||
| screen.renderLock.Unlock() |
Copilot
AI
Jul 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider using defer screen.renderLock.Unlock() immediately after Lock() for consistency and to prevent lock leaks if future code panics or returns early.
| screen.screen.SetCell(x, y, style, r) | |
| screen.renderLock.Unlock() | |
| defer screen.renderLock.Unlock() | |
| screen.screen.SetCell(x, y, style, r) |
| fg, bg := screen.theme.Fg, screen.theme.Bg | ||
| screen.configLock.RUnlock() | ||
|
|
||
| st := mkStyle(termbox.Attribute(fg), termbox.Attribute(bg)) |
Copilot
AI
Jul 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Mixing termbox.Attribute with tcell.Style may be confusing. Consider centralizing attribute-to-style conversion in one helper or using consistent tcell color types.
Add delegation wrapper that allows OptimizedScreen to work seamlessly with existing codebase that expects *ui.Screen. Key optimized methods are delegated to OptimizedScreen implementation when --optimized-screen flag is used. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
No description provided.