Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/ceeker/tui/view.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

(def ^:const compact-threshold
"Terminal width (columns) below which compact card view is used.
Derived from table row width: prefix(4) + columns + gaps = ~98."
100)
Derived from table row width: prefix(4) + columns + gaps = 109."
110)

(def ^:const max-card-message-lines
"Maximum number of message lines shown in a card."
Expand Down Expand Up @@ -138,12 +138,12 @@
(conj current-line c) lines))))))))

(def ^:private time-formatter
"HH:mm:ss formatter for local time display.
"yyyy-MM-dd HH:mm:ss formatter for local datetime display.
Immutable and safe to initialize at build time."
(DateTimeFormatter/ofPattern "HH:mm:ss"))
(DateTimeFormatter/ofPattern "yyyy-MM-dd HH:mm:ss"))

(defn- format-time
"Formats an ISO-8601 UTC timestamp to HH:mm:ss in local timezone.
"Formats an ISO-8601 UTC timestamp to yyyy-MM-dd HH:mm:ss in local timezone.
Resolves the system timezone at runtime to avoid baking the build
machine's timezone into GraalVM native images."
[updated]
Expand Down
21 changes: 18 additions & 3 deletions test/ceeker/tui/view_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@
expected (-> (Instant/parse utc-ts)
(.atZone (ZoneId/systemDefault))
(.format (DateTimeFormatter/ofPattern
"HH:mm:ss")))]
"yyyy-MM-dd HH:mm:ss")))]
(is (= expected result))
(is (re-matches #"\d{2}:\d{2}:\d{2}" result)))))
(is (re-matches #"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}" result)))))

(deftest test-format-time-nil-and-short
(testing "nil returns empty string"
Expand All @@ -488,9 +488,19 @@
expected (-> (Instant/parse utc-ts)
(.atZone (ZoneId/systemDefault))
(.format (DateTimeFormatter/ofPattern
"HH:mm:ss")))]
"yyyy-MM-dd HH:mm:ss")))]
(is (= expected (#'view/format-time utc-ts))))))

(deftest test-format-session-line-includes-full-datetime
(testing "table rows show full local datetime, not time only"
(let [session (make-session "msg")
plain (strip-ansi (#'view/format-session-line session false))
expected (-> (Instant/parse (:last-updated session))
(.atZone (ZoneId/systemDefault))
(.format (DateTimeFormatter/ofPattern
"yyyy-MM-dd HH:mm:ss")))]
(is (str/includes? plain expected)))))

;; -- worktree truncation tests --

(deftest test-long-worktree-truncated-in-table
Expand Down Expand Up @@ -576,3 +586,8 @@
height))
(is (str/includes? plain "project-3"))
(is (not (str/includes? plain "project-0"))))))

(deftest test-use-compact-threshold-covers-datetime-column-width
(testing "auto mode switches to card view below full table width"
(is (false? (#'view/use-compact? :auto 110)))
(is (true? (#'view/use-compact? :auto 109)))))
Loading