Skip to content

Conversation

@moncho
Copy link
Owner

@moncho moncho commented Jul 5, 2025

No description provided.

moncho and others added 7 commits July 5, 2025 00:15
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>
@moncho moncho requested a review from Copilot July 5, 2025 14:57
Copy link

Copilot AI left a 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 OptimizedScreen with separate render/config locks and atomic fields
  • Define ScreenRenderer interface and factory NewScreenWithOptimization
  • Update main.go and app/dry.go to 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 stateLock field that doesn't exist in OptimizedScreen. Update this section to reflect the actual fields (renderLock, configLock, atomic closing and dimensions).
stateLock      sync.RWMutex // For closing and dimensions (unused now)

Comment on lines +224 to +225
screen.screen.SetCell(x, y, style, r)
screen.renderLock.Unlock()
Copy link

Copilot AI Jul 5, 2025

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.

Suggested change
screen.screen.SetCell(x, y, style, r)
screen.renderLock.Unlock()
defer screen.renderLock.Unlock()
screen.screen.SetCell(x, y, style, r)

Copilot uses AI. Check for mistakes.
fg, bg := screen.theme.Fg, screen.theme.Bg
screen.configLock.RUnlock()

st := mkStyle(termbox.Attribute(fg), termbox.Attribute(bg))
Copy link

Copilot AI Jul 5, 2025

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.

Copilot uses AI. Check for mistakes.
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>
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.

1 participant