Skip to content

Fix snapshot tests for executing message headers - #20

Merged
serialx merged 1 commit into
mainfrom
codex/test-development-environment-readiness
Sep 23, 2025
Merged

serialx merged 1 commit into
mainfrom
codex/test-development-environment-readiness

Conversation

@serialx

@serialx serialx commented Sep 23, 2025

Copy link
Copy Markdown
Owner

Summary

  • keep message header prefixes visible when snapshot tests are running by pausing the blink timer
  • ensure executing message headers render their status prefix immediately so snapshots are stable

Testing

  • uv run pytest

https://chatgpt.com/codex/tasks/task_e_68d230613cd8832aabb3435a8dcea311

@claude

claude Bot commented Sep 23, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @serialx's task —— View job


Code Review

I've reviewed the PR and the changes look good overall. The fix correctly addresses snapshot test instability for executing message headers.

✅ Strengths

  1. Well-targeted fix: The solution correctly identifies and addresses the root cause - the blinking animation causing non-deterministic snapshots
  2. Clean implementation: Uses environment variable detection to automatically disable blinking during snapshot tests
  3. Preserves functionality: The blinking behavior remains intact for normal operation, only disabled during testing
  4. Good initialization: Setting _prefix_visible = True for executing status ensures the indicator is visible immediately

📝 Code Quality & Best Practices

The code follows good practices:

  • Uses appropriate Textual patterns for timer management
  • Clear, descriptive comments explain the purpose of changes
  • Minimal code changes with maximum effectiveness
  • Proper use of reactive properties

🐛 Potential Issues

None identified. The fix properly addresses the snapshot stability issue without introducing new problems.

⚡ Performance Considerations

  • Minimal overhead: The environment variable check (os.environ.get()) only happens once during widget mount
  • Timer optimization: Properly pauses the timer when not needed, reducing unnecessary work
  • The disable_blink flag is calculated once and reused, which is efficient

🔒 Security Concerns

No security concerns. The changes only affect UI rendering behavior and test execution.

🧪 Test Coverage

The changes directly improve test reliability rather than requiring new tests. The existing snapshot tests (tests/ui/test_message_snapshots.py) will now run more consistently, especially:

  • test_message_status_transitions which tests executing states
  • test_tool_messages which includes executing tool messages

💭 Minor Suggestions

  1. Consider adding a comment to document the TEXTUAL_SNAPSHOT_TEMPDIR environment variable's purpose, as it's a pytest-textual-snapshot implementation detail that might not be immediately obvious to future maintainers.

  2. The commented line on line 85 (# self.query_one(".prefix").visible = self._prefix_visible) could be removed if it's no longer needed.

✅ Conclusion

This is a solid fix that elegantly solves the snapshot test flakiness issue. The changes are minimal, targeted, and maintain backward compatibility while improving test reliability. Approved! 👍


@serialx
serialx merged commit 1c71c91 into main Sep 23, 2025
3 checks passed
@serialx
serialx deleted the codex/test-development-environment-readiness branch September 23, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant