git-visual-timeline 0.1.0__tar.gz → 0.2.1__tar.gz

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.
Files changed (37) hide show
  1. {git_visual_timeline-0.1.0/src/git_visual_timeline.egg-info → git_visual_timeline-0.2.1}/PKG-INFO +51 -13
  2. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/README.md +50 -12
  3. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/pyproject.toml +4 -1
  4. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1/src/git_visual_timeline.egg-info}/PKG-INFO +51 -13
  5. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/SOURCES.txt +6 -0
  6. git_visual_timeline-0.2.1/src/gvt/__init__.py +1 -0
  7. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/app.py +165 -16
  8. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/cli.py +2 -0
  9. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/git/cache.py +25 -11
  10. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/git/repo.py +136 -53
  11. git_visual_timeline-0.2.1/src/gvt/styles/app.tcss +178 -0
  12. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/changed_files.py +37 -3
  13. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/commit_bar.py +1 -1
  14. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/diff_view.py +263 -7
  15. git_visual_timeline-0.2.1/src/gvt/widgets/file_tree.py +286 -0
  16. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/modals.py +14 -100
  17. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/status_bar.py +9 -4
  18. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/timeline.py +77 -29
  19. git_visual_timeline-0.2.1/tests/test_app_integration.py +200 -0
  20. git_visual_timeline-0.2.1/tests/test_changed_files.py +109 -0
  21. git_visual_timeline-0.2.1/tests/test_diff_view_logic.py +267 -0
  22. git_visual_timeline-0.2.1/tests/test_git_repo_extended.py +240 -0
  23. git_visual_timeline-0.2.1/tests/test_timeline_logic.py +327 -0
  24. git_visual_timeline-0.1.0/src/gvt/__init__.py +0 -1
  25. git_visual_timeline-0.1.0/src/gvt/widgets/file_tree.py +0 -192
  26. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/LICENSE +0 -0
  27. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/setup.cfg +0 -0
  28. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/dependency_links.txt +0 -0
  29. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/entry_points.txt +0 -0
  30. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/requires.txt +0 -0
  31. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/top_level.txt +0 -0
  32. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/git/__init__.py +0 -0
  33. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/__init__.py +0 -0
  34. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/commit_toast.py +0 -0
  35. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/tests/test_cache.py +0 -0
  36. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/tests/test_git_repo.py +0 -0
  37. {git_visual_timeline-0.1.0 → git_visual_timeline-0.2.1}/tests/test_widgets.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-visual-timeline
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: Git Visual Timeline — a keyboard-driven TUI for exploring file commit history
5
5
  Author-email: Adam Reese <areese801@gmail.com>
6
6
  License: MIT
@@ -59,39 +59,77 @@ gvt path/to/file.py
59
59
 
60
60
  - **Visual timeline** with heatmap-colored ticks (green=adds, red=deletes, amber=mixed)
61
61
  - **Step-through mode** — scrub one commit at a time to see what changed
62
- - **Pin mode** — press `x` to mark start/end and diff any two commits
63
- - **Syntax-highlighted diffs** with inline and whole-file views
62
+ - **Pin mode** — press `x` to mark start/end and diff any two commits, `X` to snap nearest pin
63
+ - **Syntax-highlighted diffs** with inline, whole-file, and side-by-side views
64
+ - **Diff search** (`/`) — regex search within the diff with `n`/`p` to navigate matches
64
65
  - **Commit search** (`c`) — fuzzy search all repo commits by message, branch name, or author, then drill into changed files
65
66
  - **File search** (`f`) — fzf-style file picker
66
- - **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, custom date)
67
+ - **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, 6m, 1y, custom date)
67
68
  - **Inline blame** (`b`) — right-aligned blame annotations
68
69
  - **Contributor breakdown** (`B`) — visual bar chart of who changed the file
69
- - **WIP indicator** — hollow tick showing uncommitted changes
70
+ - **WIP indicator** — hollow tick showing uncommitted changes on the timeline
71
+ - **Changed files pane** — see all files touched by the current commit, select to navigate
72
+ - **Side-by-side diff** (`d`) — toggle between inline and side-by-side diff views
73
+ - **Copy to clipboard** (`y`/`Y`) — copy short or full commit hash
74
+ - **Open in editor** (`e`) — open current file in `$VISUAL`/`$EDITOR`/vim
75
+ - **Remember last file** — reopens to the last file you were viewing per repo
70
76
  - **5-pane layout** with numbered switching (1-5) and Ctrl+hjkl navigation
71
77
  - **tmux integration** — seamless pane switching at edges (add `gvt` to your `is_vim` regex)
78
+ - **Lazy file tree** — loads directories on demand for large repos
79
+ - **Preloaded diffs** — adjacent commits pre-cached for instant navigation
72
80
  - **Context-sensitive status bar** showing relevant shortcuts per pane
81
+ - **Untracked files** — shown in a separate section, viewable as read-only preview
73
82
 
74
83
  ## Keybindings
75
84
 
85
+ ### Global
86
+
76
87
  | Key | Action |
77
88
  |-----|--------|
78
89
  | `1`-`5` | Jump to pane |
79
90
  | `Ctrl+h/j/k/l` | Navigate panes directionally |
80
- | `h`/`l` | Move timeline cursor |
81
- | `x` | Pin start/end commits |
82
- | `X` | Snap nearest pin to cursor |
83
- | `n`/`p` | Next/prev diff hunk |
91
+ | `c` | Search commits (all repo) |
92
+ | `f` / `Ctrl+P` | Search files |
93
+ | `t` | Time filter |
84
94
  | `w` | Toggle whole-file view |
95
+ | `d` | Toggle side-by-side diff |
85
96
  | `b` | Toggle inline blame |
86
97
  | `B` | Contributor breakdown |
87
- | `c` | Search commits (all repo) |
88
- | `f` | Search files |
89
- | `t` | Time filter |
90
- | `+`/`-` | More/less diff context |
98
+ | `/` | Search in diff |
99
+ | `n`/`p` | Next/prev diff hunk |
100
+ | `y` / `Y` | Copy short/full commit hash |
101
+ | `e` | Open file in editor |
91
102
  | `?` | Help |
92
103
  | `q` | Quit (with confirmation) |
93
104
  | `qq` | Quit immediately |
94
105
 
106
+ ### Timeline (Pane 2)
107
+
108
+ | Key | Action |
109
+ |-----|--------|
110
+ | `h`/`l` | Move cursor |
111
+ | `0`/`$` | Jump to first/last commit |
112
+ | `x` | Pin commit (1st=start, 2nd=end, 3rd=clear) |
113
+ | `X` | Snap nearest pin to cursor |
114
+
115
+ ### Diff (Pane 4)
116
+
117
+ | Key | Action |
118
+ |-----|--------|
119
+ | `j`/`k` | Scroll |
120
+ | `g`/`G` | Top/bottom |
121
+ | `+`/`-` or `m`/`l` | More/less context lines |
122
+ | `Shift+Left/Right` | Horizontal scroll |
123
+
124
+ ### Search Modals
125
+
126
+ | Key | Action |
127
+ |-----|--------|
128
+ | `Tab` / `Shift+Tab` | Navigate results |
129
+ | `Ctrl+n` / `Ctrl+p` | Navigate results (alternative) |
130
+ | `Enter` | Select |
131
+ | `Esc` | Close |
132
+
95
133
  ## Requirements
96
134
 
97
135
  - Python 3.10+
@@ -22,39 +22,77 @@ gvt path/to/file.py
22
22
 
23
23
  - **Visual timeline** with heatmap-colored ticks (green=adds, red=deletes, amber=mixed)
24
24
  - **Step-through mode** — scrub one commit at a time to see what changed
25
- - **Pin mode** — press `x` to mark start/end and diff any two commits
26
- - **Syntax-highlighted diffs** with inline and whole-file views
25
+ - **Pin mode** — press `x` to mark start/end and diff any two commits, `X` to snap nearest pin
26
+ - **Syntax-highlighted diffs** with inline, whole-file, and side-by-side views
27
+ - **Diff search** (`/`) — regex search within the diff with `n`/`p` to navigate matches
27
28
  - **Commit search** (`c`) — fuzzy search all repo commits by message, branch name, or author, then drill into changed files
28
29
  - **File search** (`f`) — fzf-style file picker
29
- - **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, custom date)
30
+ - **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, 6m, 1y, custom date)
30
31
  - **Inline blame** (`b`) — right-aligned blame annotations
31
32
  - **Contributor breakdown** (`B`) — visual bar chart of who changed the file
32
- - **WIP indicator** — hollow tick showing uncommitted changes
33
+ - **WIP indicator** — hollow tick showing uncommitted changes on the timeline
34
+ - **Changed files pane** — see all files touched by the current commit, select to navigate
35
+ - **Side-by-side diff** (`d`) — toggle between inline and side-by-side diff views
36
+ - **Copy to clipboard** (`y`/`Y`) — copy short or full commit hash
37
+ - **Open in editor** (`e`) — open current file in `$VISUAL`/`$EDITOR`/vim
38
+ - **Remember last file** — reopens to the last file you were viewing per repo
33
39
  - **5-pane layout** with numbered switching (1-5) and Ctrl+hjkl navigation
34
40
  - **tmux integration** — seamless pane switching at edges (add `gvt` to your `is_vim` regex)
41
+ - **Lazy file tree** — loads directories on demand for large repos
42
+ - **Preloaded diffs** — adjacent commits pre-cached for instant navigation
35
43
  - **Context-sensitive status bar** showing relevant shortcuts per pane
44
+ - **Untracked files** — shown in a separate section, viewable as read-only preview
36
45
 
37
46
  ## Keybindings
38
47
 
48
+ ### Global
49
+
39
50
  | Key | Action |
40
51
  |-----|--------|
41
52
  | `1`-`5` | Jump to pane |
42
53
  | `Ctrl+h/j/k/l` | Navigate panes directionally |
43
- | `h`/`l` | Move timeline cursor |
44
- | `x` | Pin start/end commits |
45
- | `X` | Snap nearest pin to cursor |
46
- | `n`/`p` | Next/prev diff hunk |
54
+ | `c` | Search commits (all repo) |
55
+ | `f` / `Ctrl+P` | Search files |
56
+ | `t` | Time filter |
47
57
  | `w` | Toggle whole-file view |
58
+ | `d` | Toggle side-by-side diff |
48
59
  | `b` | Toggle inline blame |
49
60
  | `B` | Contributor breakdown |
50
- | `c` | Search commits (all repo) |
51
- | `f` | Search files |
52
- | `t` | Time filter |
53
- | `+`/`-` | More/less diff context |
61
+ | `/` | Search in diff |
62
+ | `n`/`p` | Next/prev diff hunk |
63
+ | `y` / `Y` | Copy short/full commit hash |
64
+ | `e` | Open file in editor |
54
65
  | `?` | Help |
55
66
  | `q` | Quit (with confirmation) |
56
67
  | `qq` | Quit immediately |
57
68
 
69
+ ### Timeline (Pane 2)
70
+
71
+ | Key | Action |
72
+ |-----|--------|
73
+ | `h`/`l` | Move cursor |
74
+ | `0`/`$` | Jump to first/last commit |
75
+ | `x` | Pin commit (1st=start, 2nd=end, 3rd=clear) |
76
+ | `X` | Snap nearest pin to cursor |
77
+
78
+ ### Diff (Pane 4)
79
+
80
+ | Key | Action |
81
+ |-----|--------|
82
+ | `j`/`k` | Scroll |
83
+ | `g`/`G` | Top/bottom |
84
+ | `+`/`-` or `m`/`l` | More/less context lines |
85
+ | `Shift+Left/Right` | Horizontal scroll |
86
+
87
+ ### Search Modals
88
+
89
+ | Key | Action |
90
+ |-----|--------|
91
+ | `Tab` / `Shift+Tab` | Navigate results |
92
+ | `Ctrl+n` / `Ctrl+p` | Navigate results (alternative) |
93
+ | `Enter` | Select |
94
+ | `Esc` | Close |
95
+
58
96
  ## Requirements
59
97
 
60
98
  - Python 3.10+
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "git-visual-timeline"
7
- version = "0.1.0"
7
+ version = "0.2.1"
8
8
  description = "Git Visual Timeline — a keyboard-driven TUI for exploring file commit history"
9
9
  readme = "README.md"
10
10
  license = {text = "MIT"}
@@ -54,6 +54,9 @@ gvt = "gvt.cli:main"
54
54
  [tool.setuptools.packages.find]
55
55
  where = ["src"]
56
56
 
57
+ [tool.setuptools.package-data]
58
+ gvt = ["styles/*.tcss"]
59
+
57
60
  [tool.ruff]
58
61
  line-length = 88
59
62
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-visual-timeline
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: Git Visual Timeline — a keyboard-driven TUI for exploring file commit history
5
5
  Author-email: Adam Reese <areese801@gmail.com>
6
6
  License: MIT
@@ -59,39 +59,77 @@ gvt path/to/file.py
59
59
 
60
60
  - **Visual timeline** with heatmap-colored ticks (green=adds, red=deletes, amber=mixed)
61
61
  - **Step-through mode** — scrub one commit at a time to see what changed
62
- - **Pin mode** — press `x` to mark start/end and diff any two commits
63
- - **Syntax-highlighted diffs** with inline and whole-file views
62
+ - **Pin mode** — press `x` to mark start/end and diff any two commits, `X` to snap nearest pin
63
+ - **Syntax-highlighted diffs** with inline, whole-file, and side-by-side views
64
+ - **Diff search** (`/`) — regex search within the diff with `n`/`p` to navigate matches
64
65
  - **Commit search** (`c`) — fuzzy search all repo commits by message, branch name, or author, then drill into changed files
65
66
  - **File search** (`f`) — fzf-style file picker
66
- - **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, custom date)
67
+ - **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, 6m, 1y, custom date)
67
68
  - **Inline blame** (`b`) — right-aligned blame annotations
68
69
  - **Contributor breakdown** (`B`) — visual bar chart of who changed the file
69
- - **WIP indicator** — hollow tick showing uncommitted changes
70
+ - **WIP indicator** — hollow tick showing uncommitted changes on the timeline
71
+ - **Changed files pane** — see all files touched by the current commit, select to navigate
72
+ - **Side-by-side diff** (`d`) — toggle between inline and side-by-side diff views
73
+ - **Copy to clipboard** (`y`/`Y`) — copy short or full commit hash
74
+ - **Open in editor** (`e`) — open current file in `$VISUAL`/`$EDITOR`/vim
75
+ - **Remember last file** — reopens to the last file you were viewing per repo
70
76
  - **5-pane layout** with numbered switching (1-5) and Ctrl+hjkl navigation
71
77
  - **tmux integration** — seamless pane switching at edges (add `gvt` to your `is_vim` regex)
78
+ - **Lazy file tree** — loads directories on demand for large repos
79
+ - **Preloaded diffs** — adjacent commits pre-cached for instant navigation
72
80
  - **Context-sensitive status bar** showing relevant shortcuts per pane
81
+ - **Untracked files** — shown in a separate section, viewable as read-only preview
73
82
 
74
83
  ## Keybindings
75
84
 
85
+ ### Global
86
+
76
87
  | Key | Action |
77
88
  |-----|--------|
78
89
  | `1`-`5` | Jump to pane |
79
90
  | `Ctrl+h/j/k/l` | Navigate panes directionally |
80
- | `h`/`l` | Move timeline cursor |
81
- | `x` | Pin start/end commits |
82
- | `X` | Snap nearest pin to cursor |
83
- | `n`/`p` | Next/prev diff hunk |
91
+ | `c` | Search commits (all repo) |
92
+ | `f` / `Ctrl+P` | Search files |
93
+ | `t` | Time filter |
84
94
  | `w` | Toggle whole-file view |
95
+ | `d` | Toggle side-by-side diff |
85
96
  | `b` | Toggle inline blame |
86
97
  | `B` | Contributor breakdown |
87
- | `c` | Search commits (all repo) |
88
- | `f` | Search files |
89
- | `t` | Time filter |
90
- | `+`/`-` | More/less diff context |
98
+ | `/` | Search in diff |
99
+ | `n`/`p` | Next/prev diff hunk |
100
+ | `y` / `Y` | Copy short/full commit hash |
101
+ | `e` | Open file in editor |
91
102
  | `?` | Help |
92
103
  | `q` | Quit (with confirmation) |
93
104
  | `qq` | Quit immediately |
94
105
 
106
+ ### Timeline (Pane 2)
107
+
108
+ | Key | Action |
109
+ |-----|--------|
110
+ | `h`/`l` | Move cursor |
111
+ | `0`/`$` | Jump to first/last commit |
112
+ | `x` | Pin commit (1st=start, 2nd=end, 3rd=clear) |
113
+ | `X` | Snap nearest pin to cursor |
114
+
115
+ ### Diff (Pane 4)
116
+
117
+ | Key | Action |
118
+ |-----|--------|
119
+ | `j`/`k` | Scroll |
120
+ | `g`/`G` | Top/bottom |
121
+ | `+`/`-` or `m`/`l` | More/less context lines |
122
+ | `Shift+Left/Right` | Horizontal scroll |
123
+
124
+ ### Search Modals
125
+
126
+ | Key | Action |
127
+ |-----|--------|
128
+ | `Tab` / `Shift+Tab` | Navigate results |
129
+ | `Ctrl+n` / `Ctrl+p` | Navigate results (alternative) |
130
+ | `Enter` | Select |
131
+ | `Esc` | Close |
132
+
95
133
  ## Requirements
96
134
 
97
135
  - Python 3.10+
@@ -13,6 +13,7 @@ src/gvt/cli.py
13
13
  src/gvt/git/__init__.py
14
14
  src/gvt/git/cache.py
15
15
  src/gvt/git/repo.py
16
+ src/gvt/styles/app.tcss
16
17
  src/gvt/widgets/__init__.py
17
18
  src/gvt/widgets/changed_files.py
18
19
  src/gvt/widgets/commit_bar.py
@@ -22,6 +23,11 @@ src/gvt/widgets/file_tree.py
22
23
  src/gvt/widgets/modals.py
23
24
  src/gvt/widgets/status_bar.py
24
25
  src/gvt/widgets/timeline.py
26
+ tests/test_app_integration.py
25
27
  tests/test_cache.py
28
+ tests/test_changed_files.py
29
+ tests/test_diff_view_logic.py
26
30
  tests/test_git_repo.py
31
+ tests/test_git_repo_extended.py
32
+ tests/test_timeline_logic.py
27
33
  tests/test_widgets.py
@@ -0,0 +1 @@
1
+ __version__ = "0.2.1"
@@ -2,9 +2,14 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import hashlib
5
6
  import os
7
+ import shutil
8
+ import subprocess
9
+ from datetime import datetime, timezone
6
10
  from pathlib import Path
7
11
 
12
+ from rich.text import Text
8
13
  from textual import on, work
9
14
  from textual.app import App, ComposeResult
10
15
  from textual.binding import Binding
@@ -13,7 +18,7 @@ from textual.widget import Widget
13
18
 
14
19
  from gvt.git.cache import DiffCache
15
20
  from gvt.git.repo import CommitInfo, GitRepo
16
- from gvt.widgets.changed_files import ChangedFilesWidget, ChangedFileSelected
21
+ from gvt.widgets.changed_files import ChangedFilesWidget, ChangedFileSelected, ChangedFileHighlighted
17
22
  from gvt.widgets.commit_bar import CommitMessageBar, ShowCommitDetail
18
23
  from gvt.widgets.diff_view import DiffContextChanged, DiffViewWidget
19
24
  from gvt.widgets.file_tree import FileSelected, FileTreeWidget
@@ -22,7 +27,6 @@ from gvt.widgets.modals import (
22
27
  CommitFilesModal,
23
28
  CommitSearchModal,
24
29
  FileSearchModal,
25
- FlashAuthorModal,
26
30
  HelpModal,
27
31
  QuitConfirmModal,
28
32
  TimeFilterModal,
@@ -53,11 +57,16 @@ class GVTApp(App):
53
57
  Binding("t", "time_filter", "Time filter", show=False),
54
58
  Binding("w", "toggle_whole_file", "Whole file", show=False),
55
59
  Binding("b", "toggle_blame", "Blame", show=False),
60
+ Binding("d", "toggle_side_by_side", "Side-by-side diff", show=False),
56
61
  Binding("B", "flash_last_author", "Last author", show=False),
57
62
  Binding("n", "global_next_hunk", "Next hunk", show=False),
58
63
  Binding("p", "global_prev_hunk", "Prev hunk", show=False),
59
64
  Binding("N", "global_prev_hunk", "Prev hunk", show=False),
60
65
  Binding("P", "global_next_hunk", "Next hunk", show=False),
66
+ Binding("slash", "global_search_diff", "Search diff", show=False),
67
+ Binding("y", "copy_short_hash", "Copy hash", show=False),
68
+ Binding("Y", "copy_full_hash", "Copy full hash", show=False),
69
+ Binding("e", "open_in_editor", "Open in editor", show=False),
61
70
  Binding("ctrl+h", "focus_left", "Focus left", show=False),
62
71
  Binding("ctrl+l", "focus_right", "Focus right", show=False),
63
72
  Binding("ctrl+k", "focus_up", "Focus up", show=False),
@@ -74,8 +83,8 @@ class GVTApp(App):
74
83
  self.current_commits: list[CommitInfo] = []
75
84
  self._q_count: int = 0
76
85
  self._q_timer = None
77
- self._saved_tree_state: set[str] = set()
78
86
  self._all_commits_cache: list[CommitInfo] | None = None
87
+ self._preload_worker = None
79
88
  self._pane_order = [
80
89
  "file-tree-widget",
81
90
  "timeline-widget",
@@ -125,9 +134,14 @@ class GVTApp(App):
125
134
  rel_path = self.initial_file
126
135
  if os.path.isabs(rel_path):
127
136
  rel_path = os.path.relpath(rel_path, self.repo_path)
137
+ self._save_last_file(rel_path)
128
138
  self._load_file(rel_path)
129
139
  else:
130
- self.query_one("#file-tree-widget", FileTreeWidget).focus()
140
+ last = self._read_last_file()
141
+ if last and os.path.isfile(os.path.join(self.repo_path, last)):
142
+ self._load_file(last)
143
+ else:
144
+ self.query_one("#file-tree-widget", FileTreeWidget).focus()
131
145
 
132
146
  def on_descendant_focus(self, event) -> None:
133
147
  """Track which pane is focused and update status bar legend."""
@@ -138,17 +152,42 @@ class GVTApp(App):
138
152
  self.query_one(GVTStatusBar).set_focused_pane(widget_id)
139
153
 
140
154
 
155
+ def _last_file_path(self) -> Path:
156
+ """Return the path to the last-file marker for this repo."""
157
+ repo_hash = hashlib.md5(self.repo_path.encode()).hexdigest()
158
+ return Path.home() / ".config" / "gvt" / f"{repo_hash}.last"
159
+
160
+ def _save_last_file(self, rel_path: str) -> None:
161
+ """Persist the last-selected file for this repo."""
162
+ p = self._last_file_path()
163
+ p.parent.mkdir(parents=True, exist_ok=True)
164
+ p.write_text(rel_path)
165
+
166
+ def _read_last_file(self) -> str | None:
167
+ """Read the last-selected file for this repo, or None."""
168
+ p = self._last_file_path()
169
+ if p.is_file():
170
+ text = p.read_text().strip()
171
+ return text if text else None
172
+ return None
173
+
141
174
  @on(FileSelected)
142
175
  def on_file_selected(self, event: FileSelected) -> None:
143
176
  if event.tracked:
177
+ self._save_last_file(event.path)
144
178
  self._load_file(event.path)
145
179
  else:
146
180
  self._load_untracked_file(event.path)
147
181
 
148
182
  @on(ChangedFileSelected)
149
183
  def on_changed_file_selected(self, event: ChangedFileSelected) -> None:
184
+ self._save_last_file(event.path)
150
185
  self._load_file(event.path)
151
186
 
187
+ @on(ChangedFileHighlighted)
188
+ def on_changed_file_highlighted(self, event: ChangedFileHighlighted) -> None:
189
+ self.query_one("#changed-files-pane", Container).border_title = f"[5] {event.path}"
190
+
152
191
  def _load_untracked_file(self, file_path: str) -> None:
153
192
  """Show an untracked file as a read-only preview."""
154
193
  self.current_file = file_path
@@ -170,7 +209,6 @@ class GVTApp(App):
170
209
  diff_view.set_diff("")
171
210
  diff_view.set_message("")
172
211
  # Build a simple preview with line numbers
173
- from rich.text import Text
174
212
  lines = []
175
213
  for i, line_text in enumerate(content.split("\n"), 1):
176
214
  t = Text()
@@ -204,8 +242,6 @@ class GVTApp(App):
204
242
  @work(thread=True)
205
243
  def _do_load_file(self, file_path: str) -> None:
206
244
  """Load file commits in background thread."""
207
- from datetime import datetime, timezone
208
-
209
245
  commits = self.git_repo.get_file_commits(file_path)
210
246
 
211
247
  # Append WIP tick if file has uncommitted changes
@@ -337,11 +373,18 @@ class GVTApp(App):
337
373
  @work(thread=True)
338
374
  def _load_diff(self, file_path: str, left_idx: int, right_idx: int) -> None:
339
375
  """Load diff between two commits, using cache."""
340
- if not self.current_commits:
376
+ commits = list(self.current_commits)
377
+ if not commits:
341
378
  return
342
379
 
343
- left = self.current_commits[left_idx]
344
- right = self.current_commits[right_idx]
380
+ if left_idx >= len(commits) or right_idx >= len(commits):
381
+ return
382
+
383
+ if self.current_file != file_path:
384
+ return
385
+
386
+ left = commits[left_idx]
387
+ right = commits[right_idx]
345
388
  diff_view = self.query_one("#diff-view", DiffViewWidget)
346
389
 
347
390
  if left.hexsha == right.hexsha:
@@ -382,6 +425,51 @@ class GVTApp(App):
382
425
  full_content = self.git_repo.get_file_at_commit(file_path, right.hexsha)
383
426
  self.call_from_thread(diff_view.set_full_file, full_content, diff)
384
427
 
428
+ # Fire preload for adjacent diffs after main diff is done
429
+ timeline = self.query_one("#timeline-widget", TimelineWidget)
430
+ cursor_idx = timeline.cursor
431
+ self.call_from_thread(self._preload_adjacent_diffs, file_path, cursor_idx, context)
432
+
433
+ @work(thread=True, exclusive=True, group="preload")
434
+ def _preload_adjacent_diffs(self, file_path: str, cursor_idx: int, context: int) -> None:
435
+ """Preload diffs for adjacent timeline positions into the cache."""
436
+ commits = list(self.current_commits)
437
+ if not commits or len(commits) < 2:
438
+ return
439
+
440
+ cache_key_suffix = f"_ctx{context}"
441
+
442
+ # Adjacent pairs to preload: (N-1 → N) and (N → N+1)
443
+ pairs = []
444
+ if cursor_idx > 0:
445
+ pairs.append((cursor_idx - 1, cursor_idx))
446
+ if cursor_idx < len(commits) - 1:
447
+ pairs.append((cursor_idx, cursor_idx + 1))
448
+
449
+ for left_idx, right_idx in pairs:
450
+ # Check if we've been superseded (cursor moved)
451
+ if self.current_file != file_path:
452
+ return
453
+
454
+ left = commits[left_idx]
455
+ right = commits[right_idx]
456
+
457
+ if left.hexsha == right.hexsha or left.is_wip or right.is_wip:
458
+ continue
459
+
460
+ left_key = left.hexsha + cache_key_suffix
461
+ if self.diff_cache.has(file_path, left_key, right.hexsha):
462
+ continue
463
+
464
+ self.diff_cache.get_or_compute(
465
+ file_path,
466
+ left_key,
467
+ right.hexsha,
468
+ lambda l=left, r=right: self.git_repo.get_diff(
469
+ file_path, l.hexsha, r.hexsha, context_lines=context
470
+ ),
471
+ )
472
+
385
473
  @on(DiffContextChanged)
386
474
  def on_diff_context_changed(self, event: DiffContextChanged) -> None:
387
475
  if not self.current_file or not self.current_commits:
@@ -422,7 +510,6 @@ class GVTApp(App):
422
510
  def _tmux_select_pane(direction: str) -> None:
423
511
  """Hand off navigation to tmux if running inside tmux."""
424
512
  if os.environ.get("TMUX"):
425
- import subprocess
426
513
  subprocess.run(["tmux", "select-pane", f"-{direction}"], check=False)
427
514
 
428
515
  def action_focus_left(self) -> None:
@@ -562,6 +649,12 @@ class GVTApp(App):
562
649
 
563
650
  self.push_screen(FileSearchModal(tracked_files), callback=on_result)
564
651
 
652
+ def action_global_search_diff(self) -> None:
653
+ diff_view = self.query_one("#diff-view", DiffViewWidget)
654
+ diff_view.focus()
655
+ self._current_pane_idx = 3
656
+ diff_view.action_start_search()
657
+
565
658
  def action_global_next_hunk(self) -> None:
566
659
  diff_view = self.query_one("#diff-view", DiffViewWidget)
567
660
  diff_view.focus()
@@ -577,13 +670,21 @@ class GVTApp(App):
577
670
  def action_toggle_whole_file(self) -> None:
578
671
  self.query_one("#diff-view", DiffViewWidget).action_toggle_full_file()
579
672
 
673
+ def action_toggle_side_by_side(self) -> None:
674
+ diff_view = self.query_one("#diff-view", DiffViewWidget)
675
+ diff_view.action_toggle_side_by_side()
676
+ status_bar = self.query_one(GVTStatusBar)
677
+ status_bar.diff_mode = "side-by-side" if diff_view.side_by_side else "inline"
678
+ status_bar.refresh()
679
+
580
680
  def action_toggle_blame(self) -> None:
581
681
  diff_view = self.query_one("#diff-view", DiffViewWidget)
582
682
  diff_view.action_toggle_blame()
583
683
  if diff_view.blame_enabled and self.current_file and self.current_commits:
584
684
  timeline = self.query_one("#timeline-widget", TimelineWidget)
585
685
  right_commit = self.current_commits[timeline.right_cursor]
586
- self._load_blame(self.current_file, right_commit.hexsha)
686
+ if not right_commit.is_wip:
687
+ self._load_blame(self.current_file, right_commit.hexsha)
587
688
 
588
689
  def action_flash_last_author(self) -> None:
589
690
  """Show who last modified the file and contributor breakdown."""
@@ -592,10 +693,58 @@ class GVTApp(App):
592
693
  timeline = self.query_one("#timeline-widget", TimelineWidget)
593
694
  commit = self.current_commits[timeline.cursor]
594
695
  contributors = self.git_repo.get_file_contributors(self.current_file)
595
- self.push_screen(FlashAuthorModal(
596
- commit.author, commit.short_hash, commit.date,
597
- contributors, self.current_file,
598
- ))
696
+
697
+ # Build contributor text for notification (no modal — avoids ghosting)
698
+ total = sum(count for _, count in contributors)
699
+ lines = [f"Last modified by {commit.author} ({commit.short_hash})"]
700
+ if total:
701
+ lines.append("")
702
+ for name, count in contributors[:8]:
703
+ pct = count / total * 100
704
+ bar = "█" * max(1, round(count / total * 20))
705
+ lines.append(f" {bar} {name} {count} commits ({pct:.0f}%)")
706
+ self.clear_notifications()
707
+ self.notify("\n".join(lines), title="Contributors", timeout=5)
708
+
709
+ def action_copy_short_hash(self) -> None:
710
+ if not self.current_commits:
711
+ return
712
+ timeline = self.query_one("#timeline-widget", TimelineWidget)
713
+ commit = self.current_commits[timeline.cursor]
714
+ self._copy_to_clipboard(commit.short_hash)
715
+
716
+ def action_copy_full_hash(self) -> None:
717
+ if not self.current_commits:
718
+ return
719
+ timeline = self.query_one("#timeline-widget", TimelineWidget)
720
+ commit = self.current_commits[timeline.cursor]
721
+ self._copy_to_clipboard(commit.hexsha)
722
+
723
+ def _copy_to_clipboard(self, text: str) -> None:
724
+ try:
725
+ if shutil.which("pbcopy"):
726
+ subprocess.run(["pbcopy"], input=text.encode(), check=True)
727
+ elif shutil.which("xclip"):
728
+ subprocess.run(["xclip", "-selection", "clipboard"], input=text.encode(), check=True)
729
+ elif shutil.which("xsel"):
730
+ subprocess.run(["xsel", "--clipboard", "--input"], input=text.encode(), check=True)
731
+ else:
732
+ self.notify("No clipboard tool found", timeout=2)
733
+ return
734
+ self.notify(f"Copied {text}", timeout=2)
735
+ except Exception:
736
+ self.notify("Failed to copy to clipboard", timeout=2)
737
+
738
+ def action_open_in_editor(self) -> None:
739
+ if not self.current_file:
740
+ return
741
+ editor = os.environ.get("VISUAL") or os.environ.get("EDITOR") or "vim"
742
+ file_path = os.path.join(self.repo_path, self.current_file)
743
+ self.suspend()
744
+ try:
745
+ subprocess.run([editor, file_path])
746
+ finally:
747
+ self.resume()
599
748
 
600
749
  @work(thread=True)
601
750
  def _load_blame(self, file_path: str, commit_sha: str) -> None:
@@ -73,3 +73,5 @@ def main():
73
73
 
74
74
  app = GVTApp(repo_path=repo.working_tree_dir, initial_file=initial_file)
75
75
  app.run()
76
+ # Force exit after app.run() returns — background worker threads may linger
77
+ os._exit(0)