Skip to content

Commit dd8c613

Browse files
committed
fix(tui): show the date, not just the time, beyond day-scoped session lists
1 parent 99a2ea2 commit dd8c613

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

src/opentab/tui/renderer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,14 +719,16 @@ def project_sort_heading(self, key: str, label: str) -> str:
719719
return f"{label} {'v' if desc else '^'}"
720720

721721
def session_started(self, workflow: Workflow) -> str:
722+
# Date whenever the scope spans more than a day (projects mode, a month, a year,
723+
# or "All years"); a bare clock time only when every row shares the scoped day.
722724
return (
723725
workflow.created_at[:10]
724-
if self.browse_mode == "projects" or self.focus == "months"
726+
if self.browse_mode == "projects" or self.focus != "days"
725727
else workflow.created_at[11:16]
726728
)
727729

728730
def session_date_label(self) -> str:
729-
return "Started" if self.browse_mode == "projects" or self.focus == "months" else "Time"
731+
return "Started" if self.browse_mode == "projects" or self.focus != "days" else "Time"
730732

731733
def top_sessions(self, rows: list[Workflow]) -> list[Workflow]:
732734
return sorted(rows, key=lambda item: (item.total_cost, item.total_tokens), reverse=True)

test_opentab.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,39 @@ def test_sessions_picker_shows_a_project_column_in_time_mode():
26062606
assert any("beta" in ln and "second" in ln for ln in lines)
26072607

26082608

2609+
def test_sessions_picker_shows_the_date_beyond_day_scope():
2610+
# A year (or "All years") scope spans months, so a bare clock time is useless --
2611+
# the picker must show the date there, like the month scope already does. Only a
2612+
# zoomed day (every row shares that day) keeps the time-only column.
2613+
app = app_with(
2614+
[
2615+
workflow("s1", "2026-06-01 12:15:00", title="june"),
2616+
workflow("s2", "2025-11-02 08:34:00", title="november"),
2617+
]
2618+
)
2619+
app.view = "zoom"
2620+
app.focus = "years" # defaults to the "All years" row -> both years listed
2621+
app.tab = app.year_tabs.index("Sessions")
2622+
lines = _paint_sessions_picker(app)
2623+
header = next(ln for ln in lines if "Title" in ln)
2624+
assert "Started" in header and "Time" not in header
2625+
assert any("2026-06-01" in ln and "june" in ln for ln in lines)
2626+
assert any("2025-11-02" in ln and "november" in ln for ln in lines)
2627+
app.focus = "months" # scoped to one month, but it still spans days -> date column
2628+
app.tab = app.month_tabs.index("Sessions")
2629+
lines = _paint_sessions_picker(app)
2630+
header = next(ln for ln in lines if "Title" in ln)
2631+
assert "Started" in header and "Time" not in header
2632+
assert any("2026-06-01" in ln and "june" in ln for ln in lines)
2633+
app.focus = "days"
2634+
app.tab = app.day_tabs.index("Sessions")
2635+
lines = _paint_sessions_picker(app)
2636+
header = next(ln for ln in lines if "Title" in ln)
2637+
assert "Time" in header and "Started" not in header
2638+
assert any("12:15" in ln and "june" in ln for ln in lines) # clock, not the date
2639+
assert not any("2026-06-01" in ln for ln in lines)
2640+
2641+
26092642
def test_sessions_picker_hides_the_project_column_when_project_scoped():
26102643
app = app_with(
26112644
[

0 commit comments

Comments
 (0)