From 2653b5a0ee96c27581e476c36a187084a791cc64 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Tue, 3 Feb 2026 14:02:28 +0100 Subject: [PATCH] Make vertical timeline more compact with smaller nodes Reduces font sizes, padding, spacing, and note truncation length specifically for vertical (TB) mode to improve usability. Co-Authored-By: Claude Opus 4.5 --- history_tree.py | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/history_tree.py b/history_tree.py index bc43b13..51adfb5 100644 --- a/history_tree.py +++ b/history_tree.py @@ -76,12 +76,23 @@ class HistoryTree: direction: "LR" (Horizontal) or "TB" (Vertical) """ node_count = len(self.nodes) - if node_count <= 5: - nodesep, ranksep = 0.5, 0.6 - elif node_count <= 15: - nodesep, ranksep = 0.3, 0.4 + is_vertical = direction == "TB" + + # Vertical mode uses much tighter spacing + if is_vertical: + if node_count <= 5: + nodesep, ranksep = 0.3, 0.2 + elif node_count <= 15: + nodesep, ranksep = 0.2, 0.15 + else: + nodesep, ranksep = 0.1, 0.1 else: - nodesep, ranksep = 0.15, 0.25 + if node_count <= 5: + nodesep, ranksep = 0.5, 0.6 + elif node_count <= 15: + nodesep, ranksep = 0.3, 0.4 + else: + nodesep, ranksep = 0.15, 0.25 # Build reverse lookup: branch tip -> branch name(s) tip_to_branches: dict[str, list[str]] = {} @@ -102,11 +113,23 @@ class HistoryTree: sorted_nodes = sorted(self.nodes.values(), key=lambda x: x["timestamp"]) + # Font sizes and padding - smaller for vertical + if is_vertical: + note_font_size = 8 + meta_font_size = 7 + cell_padding = 2 + max_note_len = 18 + else: + note_font_size = 10 + meta_font_size = 8 + cell_padding = 4 + max_note_len = 25 + for n in sorted_nodes: nid = n["id"] full_note = n.get('note', 'Step') - display_note = (full_note[:25] + '..') if len(full_note) > 25 else full_note + display_note = (full_note[:max_note_len] + '..') if len(full_note) > max_note_len else full_note ts = time.strftime('%b %d %H:%M', time.localtime(n['timestamp'])) @@ -130,14 +153,14 @@ class HistoryTree: # HTML LABEL rows = [ - f'{display_note}', - f'{ts} • {nid[:4]}', + f'{display_note}', + f'{ts} • {nid[:4]}', ] if branch_label: - rows.append(f'{branch_label}') + rows.append(f'{branch_label}') label = ( - f'<' + f'<
' + "".join(rows) + '
>' )