a9bb34cb77
When a new proposal lands in the dashboard's list, the operator shouldn't have to compare the list to a mental snapshot to spot what's new. Render newly-arrived proposals in green for the first five seconds after they show up. - _try_init_green: initialise a green color pair; returns 0 if the terminal lacks color so the highlight degrades to no-op. - _main_loop tracks first_seen[proposal_id] across refresh ticks, pruning entries when a proposal leaves the queue. - _render ORs green into the existing attr (composes with selection reverse-video — terminal handles the mix). Applies to all tool types (cred-proxy-block, pipelock-block, capability-block). If a tool-specific highlight is wanted later, filter on qp.proposal.tool in _is_recent. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""Unit: dashboard's new-proposal highlight window.
|
|
|
|
The curses rendering itself is exercised manually; this isolates
|
|
the pure decision `is the proposal still in its post-arrival
|
|
highlight window?`"""
|
|
|
|
import unittest
|
|
|
|
from claude_bottle.cli import dashboard
|
|
|
|
|
|
class TestIsRecent(unittest.TestCase):
|
|
def test_just_seen_is_recent(self):
|
|
self.assertTrue(dashboard._is_recent("p1", {"p1": 100.0}, now=100.5))
|
|
|
|
def test_seen_within_window(self):
|
|
# Default window is 5s.
|
|
self.assertTrue(
|
|
dashboard._is_recent("p1", {"p1": 100.0}, now=104.9),
|
|
)
|
|
|
|
def test_seen_past_window_is_not_recent(self):
|
|
self.assertFalse(
|
|
dashboard._is_recent("p1", {"p1": 100.0}, now=106.0),
|
|
)
|
|
|
|
def test_unknown_proposal_is_not_recent(self):
|
|
self.assertFalse(
|
|
dashboard._is_recent("p2", {"p1": 100.0}, now=100.5),
|
|
)
|
|
|
|
def test_none_args_safe_default(self):
|
|
self.assertFalse(dashboard._is_recent("p1", None, None))
|
|
self.assertFalse(dashboard._is_recent("p1", {"p1": 100.0}, None))
|
|
self.assertFalse(dashboard._is_recent("p1", None, 100.5))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|