Skip to content

chore: Move unicode demo into demos#993

Merged
gdamore merged 1 commit intomainfrom
unicode-demo
Jan 12, 2026
Merged

chore: Move unicode demo into demos#993
gdamore merged 1 commit intomainfrom
unicode-demo

Conversation

@gdamore
Copy link
Copy Markdown
Owner

@gdamore gdamore commented Jan 12, 2026

Summary by CodeRabbit

  • New Features

    • Ctrl-Q keyboard shortcut now available to exit the unicode demo.
    • Updated in-app exit instruction to reference Ctrl-Q.
  • Tests

    • Added automated test coverage for the unicode demo rendering flow.
  • Chores

    • Enabled the unicode demo for compilation.
    • Updated copyright year to 2026.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 12, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Enabled compilation of the unicode demo by removing build-ignore markers, updated copyright year to 2026, changed quit key/prompt to Ctrl‑Q, and added a test (TestUnicode) exercising rendering and key-driven quit behavior.

Changes

Cohort / File(s) Summary
Demo update
demos/unicode/unicode.go
Removed build-ignore markers; updated copyright year (2025→2026); changed prompt text from "Press ESC to Exit" to "Press Control-Q to Exit"; added handling for tcell.KeyCtrlQ to trigger quit alongside Escape/Enter.
Test added
demos/unicode/unicode_test.go
Added TestUnicode(t *testing.T) which creates a mock VT terminal and tcell screen, runs main() in a goroutine, simulates Ctrl‑L and Ctrl‑Q keypresses, drains the mock terminal, and iterates the 24×80 cell grid to exercise rendering/attribute-change paths.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I hop through code at break of day,
Ctrl‑Q chases ESC away,
A demo wakes, the tests all run,
Unicode shines beneath the sun,
Year updated — hop, celebrate! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'chore: Move unicode demo into demos' is misleading. The changes show copyright updates, prompt text modifications, key handling additions, and new test code—not a file move operation. Revise the title to accurately reflect the actual changes, such as 'chore: Update unicode demo with Ctrl-Q support and tests' or similar.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f6af32 and 09397b7.

📒 Files selected for processing (2)
  • demos/unicode/unicode.go
  • demos/unicode/unicode_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.97%. Comparing base (c7a03e2) to head (0f6af32).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #993      +/-   ##
==========================================
+ Coverage   81.52%   81.97%   +0.44%     
==========================================
  Files          38       39       +1     
  Lines        3989     4055      +66     
==========================================
+ Hits         3252     3324      +72     
+ Misses        587      584       -3     
+ Partials      150      147       -3     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
demos/unicode/unicode.go (1)

15-16: Stale package comment.

The package comment on line 16 still says "Press ESC to exit the program" but the actual prompt (line 66) and key handling (line 104) now use Control-Q.

📝 Proposed fix
 // unicode just displays a Unicode test on your screen.
-// Press ESC to exit the program.
+// Press Control-Q to exit the program.
 package main
🤖 Fix all issues with AI agents
In @demos/unicode/unicode_test.go:
- Around line 12-15: The test name and comment are referencing the wrong demo:
rename the test function TestStyles to TestUnicode and update the preceding
comment text to mention the unicode demo program instead of the styles demo;
ensure any references inside the test (function TestStyles) and its comment are
changed consistently so the test name and comment match the demos/unicode
context.
🧹 Nitpick comments (2)
demos/unicode/unicode_test.go (2)

41-50: Computed value never asserted.

The attrs variable is computed by iterating through cells and counting attribute changes, but the value is never checked. The test will pass regardless of what attrs contains. Consider adding a basic sanity check to ensure the rendering path actually produced styled output.

💡 Suggestion
 		}
 	}
+	if attrs == 0 {
+		t.Error("expected at least one attribute change in rendered output")
+	}
 	time.Sleep(time.Millisecond * 10)

33-33: Consider noting the flakiness tradeoff.

Using time.Sleep for synchronization can cause intermittent failures under load. The comment on lines 31-32 explains this is needed because main runs asynchronously, which is fair for a demo test. Just be aware this might occasionally flake in CI.

Also applies to: 51-51

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7a03e2 and 0f6af32.

📒 Files selected for processing (2)
  • demos/unicode/unicode.go
  • demos/unicode/unicode_test.go
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-18T02:50:48.847Z
Learnt from: gdamore
Repo: gdamore/tcell PR: 908
File: stdin_unix.go:128-155
Timestamp: 2025-12-18T02:50:48.847Z
Learning: In the tcell Tty interface implementations (stdin_unix.go, tty_unix.go, tty_win.go, tty_plan9.go), the caller is responsible for providing synchronization/mutual exclusion guarantees for method calls like NotifyResize. The Tty implementations themselves do not need internal locking for these methods, as documented in tty.go. The tscreen.go layer handles the synchronization.

Applied to files:

  • demos/unicode/unicode.go
📚 Learning: 2026-01-06T15:44:36.396Z
Learnt from: gdamore
Repo: gdamore/tcell PR: 977
File: vt/emulate.go:150-150
Timestamp: 2026-01-06T15:44:36.396Z
Learning: In vt/emulate.go for DEC Private Mode 2 (PmVT52), the VT200/VT52 semantics are inverted: when the mode is OFF, VT52 mode is enabled; when the mode is ON, VT52 is disabled and VT100/ANSI mode is active. Ensure reviews verify that ModeOnLocked correctly enforces VT100/ANSI (VT52 disabled) when set, and that enabling OFF path activates VT52 mode. Document this inversion in code comments and tests, and avoid assuming a direct one-way mapping between PmVT52 and VT52 state. If any code branches rely on the opposite behavior, adjust tests accordingly.

Applied to files:

  • demos/unicode/unicode.go
  • demos/unicode/unicode_test.go
🧬 Code graph analysis (1)
demos/unicode/unicode_test.go (5)
vt/mock.go (1)
  • NewMockTerm (181-194)
screen.go (1)
  • ShimScreen (277-282)
vt/event.go (1)
  • KeyEvent (18-25)
vt/attr.go (1)
  • Attr (18-18)
vt/coord.go (3)
  • Row (22-22)
  • Col (25-25)
  • Coord (28-31)
🔇 Additional comments (3)
demos/unicode/unicode.go (2)

1-1: LGTM!

Copyright year update to 2026 is correct.


66-66: LGTM!

The prompt text and key handling are now consistent. Adding KeyCtrlQ to the existing case alongside KeyEscape and KeyEnter is a clean approach that maintains backward compatibility while adding the new quit mechanism.

Also applies to: 104-104

demos/unicode/unicode_test.go (1)

26-29: LGTM!

The goroutine pattern with sync.WaitGroup correctly synchronizes main() execution. The Ctrl-Q key events properly align with the updated quit handling in unicode.go.

Also applies to: 52-55

Comment thread demos/unicode/unicode_test.go Outdated
@gdamore gdamore merged commit 09397b7 into main Jan 12, 2026
11 of 12 checks passed
@gdamore gdamore deleted the unicode-demo branch January 12, 2026 04:10
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