ccburn 0.3.0__py3-none-any.whl → 0.3.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ccburn/app.py CHANGED
@@ -3,7 +3,6 @@
3
3
  import os
4
4
  import signal
5
5
  import threading
6
- import time
7
6
  from datetime import datetime, timedelta, timezone
8
7
  from typing import Any
9
8
 
@@ -71,7 +70,8 @@ class CCBurnApp:
71
70
  self.layout = BurnupLayout(self.console)
72
71
 
73
72
  # State
74
- self.running = threading.Event()
73
+ self.running = True
74
+ self._stop_event = threading.Event() # For interruptible sleep
75
75
  self.last_snapshot: UsageSnapshot | None = None
76
76
  self.last_fetch_time: datetime | None = None
77
77
  self.last_error: str | None = None
@@ -197,18 +197,6 @@ class CCBurnApp:
197
197
  self.last_error = f"Unexpected error: {e}"
198
198
  return False
199
199
 
200
- def _should_refresh(self) -> bool:
201
- """Check if we should fetch new data.
202
-
203
- Returns:
204
- True if it's time to refresh
205
- """
206
- if self.last_fetch_time is None:
207
- return True
208
-
209
- elapsed = (datetime.now(timezone.utc) - self.last_fetch_time).total_seconds()
210
- return elapsed >= self.interval
211
-
212
200
  def run(self) -> int:
213
201
  """Run the application.
214
202
 
@@ -311,7 +299,7 @@ class CCBurnApp:
311
299
  Exit code
312
300
  """
313
301
  self._setup_signal_handlers()
314
- self.running.set()
302
+ self.running = True
315
303
 
316
304
  try:
317
305
  # Create initial display
@@ -333,7 +321,7 @@ class CCBurnApp:
333
321
  with Live(
334
322
  initial_layout,
335
323
  console=self.console,
336
- refresh_per_second=1,
324
+ auto_refresh=False, # Manual refresh only - saves CPU
337
325
  transient=False,
338
326
  screen=True,
339
327
  vertical_overflow="visible",
@@ -358,18 +346,14 @@ class CCBurnApp:
358
346
  Args:
359
347
  live: Rich Live instance
360
348
  """
361
- last_update = 0.0
362
-
363
- while self.running.is_set():
349
+ while self.running:
364
350
  try:
365
- current_time = time.time()
366
-
367
- # Check if we should refresh data
368
- if self._should_refresh():
369
- self._fetch_and_update()
351
+ # Fetch new data
352
+ data_changed = self._fetch_and_update()
370
353
 
371
- # Update display
372
- if current_time - last_update >= 1.0: # Update display every second
354
+ # Only re-render layout when data actually changes
355
+ # This avoids expensive chart re-rendering
356
+ if data_changed:
373
357
  limit_data = None
374
358
  if self.last_snapshot:
375
359
  limit_data = self.last_snapshot.get_limit(self.limit_type)
@@ -387,15 +371,16 @@ class CCBurnApp:
387
371
  since_duration=self.since_duration,
388
372
  )
389
373
  live.update(updated_layout)
374
+ live.refresh() # Manual refresh since auto_refresh=False
390
375
  self._update_window_title()
391
- last_update = current_time
392
376
 
393
- # Small sleep to prevent busy waiting
394
- time.sleep(0.05)
377
+ # Sleep until next refresh interval
378
+ # Use Event.wait() for interruptible sleep on shutdown
379
+ self._stop_event.wait(timeout=self.interval)
395
380
 
396
381
  except Exception:
397
382
  # Log but continue
398
- time.sleep(0.5)
383
+ self._stop_event.wait(timeout=self.interval)
399
384
 
400
385
  def _create_json_output(self) -> dict:
401
386
  """Create JSON output structure.
@@ -482,7 +467,8 @@ class CCBurnApp:
482
467
 
483
468
  def stop(self) -> None:
484
469
  """Stop the application."""
485
- self.running.clear()
470
+ self.running = False
471
+ self._stop_event.set() # Wake up from sleep immediately
486
472
 
487
473
  def _update_window_title(self) -> None:
488
474
  """Update terminal window title with current status."""
ccburn/display/layout.py CHANGED
@@ -24,7 +24,7 @@ class BurnupLayout:
24
24
 
25
25
  MIN_WIDTH = 40
26
26
  MIN_HEIGHT = 10
27
- COMPACT_WIDTH = 60
27
+ COMPACT_WIDTH = 40
28
28
  COMPACT_HEIGHT = 15
29
29
 
30
30
  def __init__(self, console: Console | None = None):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ccburn
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Terminal-based Claude Code usage limit visualizer with real-time burn-up charts
5
5
  Author: JuanjoFuchs
6
6
  License-Expression: MIT
@@ -1,5 +1,5 @@
1
1
  ccburn/__init__.py,sha256=u8tlHJ2bTam19CROn2nufmcfCONN9BwlRLY-8AOu8Os,191
2
- ccburn/app.py,sha256=wJNWyBBOzgT3c-DZhPkcp1dfF75Ynf6Ke0Uzd5PDqpE,17909
2
+ ccburn/app.py,sha256=IvIFOX10AFD103P5XiIenkEB2clAq2o3XJR6lceMVhE,17775
3
3
  ccburn/cli.py,sha256=dvh6V8I1TQlqbCv4-5j3ANRdKpoQKPHgA2QrBZUSkJY,7120
4
4
  ccburn/main.py,sha256=TqWLl9xxOtbpTQr-ObomzSLG3jNec2GZ6RKEQYYdGLg,2474
5
5
  ccburn/data/__init__.py,sha256=ZczEZwodQ-MMO5F7fVNsyIpUCRY8Ya9W4pwdOOJWxm4,803
@@ -10,13 +10,13 @@ ccburn/data/usage_client.py,sha256=_dGwmI5vYPk4S-HUe2_fnTwSuAfTPaOFff7mKPFnhps,4
10
10
  ccburn/display/__init__.py,sha256=aL7TV53kU5oxlIwJ8M17stG2aC6UeGB-pj2u5BOpegs,495
11
11
  ccburn/display/chart.py,sha256=7Rg9KeeeDjr8jwvEhHbmBYmZ0Wj3N1ijfzsQy6u6kqA,15917
12
12
  ccburn/display/gauges.py,sha256=qPjFmTJd3RcwMfpmONFHByno5ByDPaVpvDttHnfct1E,10628
13
- ccburn/display/layout.py,sha256=DlgmH3G2RbpyYfWYD6YP1IlohYmhWBSiqjM7Y7fto-U,8244
13
+ ccburn/display/layout.py,sha256=JMqTsUzVLZPwK5WsnZzZugi4KLjkb8pTKB3e6Uhirkc,8244
14
14
  ccburn/utils/__init__.py,sha256=N6EzUX9hUJkuga_l9Ci3of1CWNtQgpNmMmNyY2DgYrg,1119
15
15
  ccburn/utils/calculator.py,sha256=m-XATeOqgD5Z4ZranuI7QSlSb4pnW43_rtaJSF2Te6Q,7706
16
16
  ccburn/utils/formatting.py,sha256=MEVIohBmvSur0hcc67oyYRDooiUMf0rPa4LO1fc2Ud4,4174
17
- ccburn-0.3.0.dist-info/licenses/LICENSE,sha256=Qf2mqNi2qJ35JytfoTdR1SgYhZ2Mt4Ohcf-tu_MuYC0,1068
18
- ccburn-0.3.0.dist-info/METADATA,sha256=zsp0rkT2qCWRwJC1w_VXmtNqwQhFTVswHimCEGayE54,7343
19
- ccburn-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
- ccburn-0.3.0.dist-info/entry_points.txt,sha256=GfFQ5VusMR8RJ9meygqWjaErdmYsf_arbILzf64WjLU,43
21
- ccburn-0.3.0.dist-info/top_level.txt,sha256=SM8TwGQZqQKKIQObVWQkfpA0OI4gRut7bPl-iM3g5RI,7
22
- ccburn-0.3.0.dist-info/RECORD,,
17
+ ccburn-0.3.2.dist-info/licenses/LICENSE,sha256=Qf2mqNi2qJ35JytfoTdR1SgYhZ2Mt4Ohcf-tu_MuYC0,1068
18
+ ccburn-0.3.2.dist-info/METADATA,sha256=baZRwLIuHI1Uax7JZAeyxGBALk9bwLsH7iF1b-VJf7k,7343
19
+ ccburn-0.3.2.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
20
+ ccburn-0.3.2.dist-info/entry_points.txt,sha256=GfFQ5VusMR8RJ9meygqWjaErdmYsf_arbILzf64WjLU,43
21
+ ccburn-0.3.2.dist-info/top_level.txt,sha256=SM8TwGQZqQKKIQObVWQkfpA0OI4gRut7bPl-iM3g5RI,7
22
+ ccburn-0.3.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5