Skip to content

Simplify InterruptReader facade and specify it as Input interface for ansipixels, with better name than ReadDirect. Fix windows every other frame read delay in FPSTicks#203

Merged
ldemailly merged 8 commits intomainfrom
ssh_hooks
Nov 20, 2025

Conversation

… ansipixels, with better name than ReadDirect
@ldemailly ldemailly requested a review from Copilot November 15, 2025 19:35
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 15, 2025

Codecov Report

❌ Patch coverage is 0% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.31%. Comparing base (e9231a3) to head (0642ce2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
timeoutreader.go 0.00% 22 Missing ⚠️
timeoutreader_unix.go 0.00% 16 Missing ⚠️
ansipixels/ansipixels.go 0.00% 13 Missing ⚠️
interrupt.go 0.00% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #203      +/-   ##
==========================================
- Coverage   18.06%   17.31%   -0.76%     
==========================================
  Files          23       23              
  Lines        4129     4308     +179     
==========================================
  Hits          746      746              
- Misses       3352     3531     +179     
  Partials       31       31              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

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 simplifies the InterruptReader facade by renaming DirectRead to ReadWithTimeout and removing the now-duplicate ReadWithTimeout method that had wait logic. It also introduces an Input interface in ansipixels to abstract input reading capabilities, making the code more modular and allowing alternative implementations (e.g., for SSH-based input).

  • Renamed DirectRead to ReadWithTimeout with clearer documentation about its behavior
  • Removed duplicate ReadWithTimeout method that included buffering logic
  • Introduced the Input interface in ansipixels to abstract input reading requirements
  • Updated AnsiPixels.SharedInput field type from *terminal.InterruptReader to Input

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
interrupt.go Renamed DirectRead to ReadWithTimeout, removed duplicate ReadWithTimeout method with wait logic, updated internal calls
ansipixels/ansipixels.go Added Input interface, changed SharedInput field type to use interface, updated method calls and documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

timeoutreader.go:24

  • Fixed typo: "inpout" corrected to "input"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ldemailly ldemailly changed the title Simplify InterruptReader facade and specify it as Input interface for ansipixels, with better name than ReadDirect Simplify InterruptReader facade and specify it as Input interface for ansipixels, with better name than ReadDirect. Fix windows every other frame read delay in FPSTicks Nov 20, 2025
@ldemailly ldemailly requested a review from Copilot November 20, 2025 01:46
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (4)

timeoutreader.go:23

  • Spelling error: 'loosing' should be 'losing' (meaning 'to lose', not 'to make loose').
    timeoutreader.go:24
  • Fixed typo: 'inpout' corrected to 'input'.
    timeoutreader.go:56
  • The inputChan buffer size was changed from 1 to 0 (unbuffered). This makes the channel synchronous, which means PrimeReadImmediate will now block until the reader goroutine receives from the channel. This change should be called out in the PR description or documentation, as it affects the behavior and could introduce blocking where it didn't exist before, particularly if PrimeReadImmediate is called while the reader goroutine is blocked on a read.
    timeoutreader.go:226
  • The comment says "If called currently it will block until the current read completes" but the implementation only briefly locks the mutex to update the timeout value. It does not wait for any read operation to complete. The comment should be corrected to accurately reflect that the method only updates the timeout for subsequent reads and may block briefly to acquire the mutex, but does not wait for in-progress reads.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +91 to 97
func (tr *TimeoutReaderUnixFD) ReadImmediate() (int, error) {
if tr.blocking {
return tr.ostream.Read(buf)
return tr.ostream.Read(tr.buf)
}
var zeroTv unix.Timeval
return ReadWithTimeout(tr.fd, &zeroTv, buf)
return ReadWithTimeout(tr.fd, &zeroTv, tr.buf)
}
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadImmediate doesn't check if PrimeReadImmediate was called first. If tr.buf is nil (because PrimeReadImmediate was never called), calling ReadWithTimeout with a nil buffer could cause undefined behavior or a crash. Consider adding a check similar to the Windows implementation:

if tr.buf == nil {
    panic("ReadImmediate called without prior PrimeReadImmediate")
}

Copilot uses AI. Check for mistakes.
@ldemailly ldemailly merged commit 16faa22 into main Nov 20, 2025
16 of 18 checks passed
@ldemailly ldemailly deleted the ssh_hooks branch January 19, 2026 23:14
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.

investigate the windows reader (or unix test_alt_timeoutreader) key off in FPSTicks mode

3 participants