git-visual-timeline 0.2.0__tar.gz → 0.2.2__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 (40) hide show
  1. {git_visual_timeline-0.2.0/src/git_visual_timeline.egg-info → git_visual_timeline-0.2.2}/PKG-INFO +49 -17
  2. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/README.md +48 -16
  3. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/pyproject.toml +4 -1
  4. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2/src/git_visual_timeline.egg-info}/PKG-INFO +49 -17
  5. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/SOURCES.txt +5 -0
  6. git_visual_timeline-0.2.2/src/gvt/__init__.py +1 -0
  7. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/app.py +52 -29
  8. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/cli.py +31 -19
  9. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/git/cache.py +22 -12
  10. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/git/repo.py +70 -39
  11. git_visual_timeline-0.2.2/src/gvt/logging_setup.py +40 -0
  12. git_visual_timeline-0.2.2/src/gvt/styles/app.tcss +178 -0
  13. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/widgets/commit_bar.py +1 -1
  14. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/widgets/diff_view.py +2 -6
  15. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/widgets/modals.py +0 -89
  16. git_visual_timeline-0.2.2/tests/test_app_actions.py +125 -0
  17. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/tests/test_app_integration.py +30 -0
  18. git_visual_timeline-0.2.2/tests/test_logging_setup.py +99 -0
  19. git_visual_timeline-0.2.2/tests/test_repo_resilience.py +60 -0
  20. git_visual_timeline-0.2.0/src/gvt/__init__.py +0 -1
  21. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/LICENSE +0 -0
  22. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/setup.cfg +0 -0
  23. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/dependency_links.txt +0 -0
  24. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/entry_points.txt +0 -0
  25. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/requires.txt +0 -0
  26. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/top_level.txt +0 -0
  27. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/git/__init__.py +0 -0
  28. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/widgets/__init__.py +0 -0
  29. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/widgets/changed_files.py +0 -0
  30. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/widgets/commit_toast.py +0 -0
  31. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/widgets/file_tree.py +0 -0
  32. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/widgets/status_bar.py +0 -0
  33. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/src/gvt/widgets/timeline.py +0 -0
  34. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/tests/test_cache.py +0 -0
  35. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/tests/test_changed_files.py +0 -0
  36. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/tests/test_diff_view_logic.py +0 -0
  37. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/tests/test_git_repo.py +0 -0
  38. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/tests/test_git_repo_extended.py +0 -0
  39. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/tests/test_timeline_logic.py +0 -0
  40. {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.2}/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.2.0
3
+ Version: 0.2.2
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
@@ -39,6 +39,10 @@ Dynamic: license-file
39
39
 
40
40
  A keyboard-driven TUI for exploring the commit history of any file in a git repo. Think lazygit meets a video timeline scrubber, focused on per-file history.
41
41
 
42
+ ![gvt full layout](assets/gvt-full-layout.png)
43
+
44
+ **gvt is a read-only history explorer, not a git UI.** It doesn't stage, commit, push, or manage branches — lazygit is great for that. gvt does one thing: lets you scrub through a file's commit timeline, see what changed and when, and understand how code evolved over time. It's the tool you reach for when you're staring at a file and asking "how did this get here?"
45
+
42
46
  ## Install
43
47
 
44
48
  ```bash
@@ -55,30 +59,58 @@ gvt
55
59
  gvt path/to/file.py
56
60
  ```
57
61
 
62
+ ## Layout
63
+
64
+ gvt uses a 5-pane layout, each accessible by number key:
65
+
66
+ | Pane | Name | What it shows |
67
+ |------|------|---------------|
68
+ | 1 | Files | File tree with lazy-loading directories |
69
+ | 2 | Timeline | Heatmap of commits (green=adds, red=deletes, amber=mixed) |
70
+ | 3 | Commits | Message, hash, date, and stats for visible commits |
71
+ | 4 | Diff | Syntax-highlighted diff with blame, search, and context controls |
72
+ | 5 | Changed Files | All files touched by the current commit |
73
+
58
74
  ## Features
59
75
 
60
- - **Visual timeline** with heatmap-colored ticks (green=adds, red=deletes, amber=mixed)
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, `X` to snap nearest pin
63
- - **Syntax-highlighted diffs** with inline, whole-file, and side-by-side views
76
+ ### Timeline Navigation
77
+
78
+ Scrub through a file's commit history one tick at a time. Each tick is colored by change type — green for additions, red for deletions, amber for mixed.
79
+
80
+ ![Timeline navigation](assets/gvt-timeline-navigation.gif)
81
+
82
+ ### Pin Mode
83
+
84
+ Press `x` to pin a commit, then move to another and press `x` again to diff any two commits. Press `x` a third time to clear. Use `X` to snap the nearest pin to your cursor.
85
+
86
+ ![Pin mode](assets/gvt-pin-mode.gif)
87
+
88
+ ### Inline Blame
89
+
90
+ Toggle blame annotations with `b` to see who last modified each line, right-aligned alongside the diff.
91
+
92
+ ![Blame mode](assets/gvt-blame-mode.gif)
93
+
94
+ ### File Search
95
+
96
+ Press `f` for an fzf-style fuzzy file picker that filters as you type.
97
+
98
+ ![File search](assets/gvt-file-search.gif)
99
+
100
+ ### All Features
101
+
102
+ - **Syntax-highlighted diffs** with inline, whole-file (`w`), and side-by-side (`d`) views
64
103
  - **Diff search** (`/`) — regex search within the diff with `n`/`p` to navigate matches
65
- - **Commit search** (`c`) — fuzzy search all repo commits by message, branch name, or author, then drill into changed files
66
- - **File search** (`f`) — fzf-style file picker
104
+ - **Commit search** (`c`) — fuzzy search all repo commits by message, branch, or author
67
105
  - **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, 6m, 1y, custom date)
68
- - **Inline blame** (`b`) — right-aligned blame annotations
69
- - **Contributor breakdown** (`B`) — visual bar chart of who changed the file
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
106
+ - **Contributor breakdown** (`B`) — who changed the file and how much
107
+ - **WIP indicator** — hollow tick showing uncommitted changes
108
+ - **Copy to clipboard** (`y`/`Y`) — short or full commit hash
74
109
  - **Open in editor** (`e`) — open current file in `$VISUAL`/`$EDITOR`/vim
75
110
  - **Remember last file** — reopens to the last file you were viewing per repo
76
- - **5-pane layout** with numbered switching (1-5) and Ctrl+hjkl navigation
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
111
+ - **tmux integration** — seamless pane switching at edges
79
112
  - **Preloaded diffs** — adjacent commits pre-cached for instant navigation
80
113
  - **Context-sensitive status bar** showing relevant shortcuts per pane
81
- - **Untracked files** — shown in a separate section, viewable as read-only preview
82
114
 
83
115
  ## Keybindings
84
116
 
@@ -2,6 +2,10 @@
2
2
 
3
3
  A keyboard-driven TUI for exploring the commit history of any file in a git repo. Think lazygit meets a video timeline scrubber, focused on per-file history.
4
4
 
5
+ ![gvt full layout](assets/gvt-full-layout.png)
6
+
7
+ **gvt is a read-only history explorer, not a git UI.** It doesn't stage, commit, push, or manage branches — lazygit is great for that. gvt does one thing: lets you scrub through a file's commit timeline, see what changed and when, and understand how code evolved over time. It's the tool you reach for when you're staring at a file and asking "how did this get here?"
8
+
5
9
  ## Install
6
10
 
7
11
  ```bash
@@ -18,30 +22,58 @@ gvt
18
22
  gvt path/to/file.py
19
23
  ```
20
24
 
25
+ ## Layout
26
+
27
+ gvt uses a 5-pane layout, each accessible by number key:
28
+
29
+ | Pane | Name | What it shows |
30
+ |------|------|---------------|
31
+ | 1 | Files | File tree with lazy-loading directories |
32
+ | 2 | Timeline | Heatmap of commits (green=adds, red=deletes, amber=mixed) |
33
+ | 3 | Commits | Message, hash, date, and stats for visible commits |
34
+ | 4 | Diff | Syntax-highlighted diff with blame, search, and context controls |
35
+ | 5 | Changed Files | All files touched by the current commit |
36
+
21
37
  ## Features
22
38
 
23
- - **Visual timeline** with heatmap-colored ticks (green=adds, red=deletes, amber=mixed)
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, `X` to snap nearest pin
26
- - **Syntax-highlighted diffs** with inline, whole-file, and side-by-side views
39
+ ### Timeline Navigation
40
+
41
+ Scrub through a file's commit history one tick at a time. Each tick is colored by change type — green for additions, red for deletions, amber for mixed.
42
+
43
+ ![Timeline navigation](assets/gvt-timeline-navigation.gif)
44
+
45
+ ### Pin Mode
46
+
47
+ Press `x` to pin a commit, then move to another and press `x` again to diff any two commits. Press `x` a third time to clear. Use `X` to snap the nearest pin to your cursor.
48
+
49
+ ![Pin mode](assets/gvt-pin-mode.gif)
50
+
51
+ ### Inline Blame
52
+
53
+ Toggle blame annotations with `b` to see who last modified each line, right-aligned alongside the diff.
54
+
55
+ ![Blame mode](assets/gvt-blame-mode.gif)
56
+
57
+ ### File Search
58
+
59
+ Press `f` for an fzf-style fuzzy file picker that filters as you type.
60
+
61
+ ![File search](assets/gvt-file-search.gif)
62
+
63
+ ### All Features
64
+
65
+ - **Syntax-highlighted diffs** with inline, whole-file (`w`), and side-by-side (`d`) views
27
66
  - **Diff search** (`/`) — regex search within the diff with `n`/`p` to navigate matches
28
- - **Commit search** (`c`) — fuzzy search all repo commits by message, branch name, or author, then drill into changed files
29
- - **File search** (`f`) — fzf-style file picker
67
+ - **Commit search** (`c`) — fuzzy search all repo commits by message, branch, or author
30
68
  - **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, 6m, 1y, custom date)
31
- - **Inline blame** (`b`) — right-aligned blame annotations
32
- - **Contributor breakdown** (`B`) — visual bar chart of who changed the file
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
69
+ - **Contributor breakdown** (`B`) — who changed the file and how much
70
+ - **WIP indicator** — hollow tick showing uncommitted changes
71
+ - **Copy to clipboard** (`y`/`Y`) — short or full commit hash
37
72
  - **Open in editor** (`e`) — open current file in `$VISUAL`/`$EDITOR`/vim
38
73
  - **Remember last file** — reopens to the last file you were viewing per repo
39
- - **5-pane layout** with numbered switching (1-5) and Ctrl+hjkl navigation
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
74
+ - **tmux integration** — seamless pane switching at edges
42
75
  - **Preloaded diffs** — adjacent commits pre-cached for instant navigation
43
76
  - **Context-sensitive status bar** showing relevant shortcuts per pane
44
- - **Untracked files** — shown in a separate section, viewable as read-only preview
45
77
 
46
78
  ## Keybindings
47
79
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "git-visual-timeline"
7
- version = "0.2.0"
7
+ version = "0.2.2"
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.2.0
3
+ Version: 0.2.2
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
@@ -39,6 +39,10 @@ Dynamic: license-file
39
39
 
40
40
  A keyboard-driven TUI for exploring the commit history of any file in a git repo. Think lazygit meets a video timeline scrubber, focused on per-file history.
41
41
 
42
+ ![gvt full layout](assets/gvt-full-layout.png)
43
+
44
+ **gvt is a read-only history explorer, not a git UI.** It doesn't stage, commit, push, or manage branches — lazygit is great for that. gvt does one thing: lets you scrub through a file's commit timeline, see what changed and when, and understand how code evolved over time. It's the tool you reach for when you're staring at a file and asking "how did this get here?"
45
+
42
46
  ## Install
43
47
 
44
48
  ```bash
@@ -55,30 +59,58 @@ gvt
55
59
  gvt path/to/file.py
56
60
  ```
57
61
 
62
+ ## Layout
63
+
64
+ gvt uses a 5-pane layout, each accessible by number key:
65
+
66
+ | Pane | Name | What it shows |
67
+ |------|------|---------------|
68
+ | 1 | Files | File tree with lazy-loading directories |
69
+ | 2 | Timeline | Heatmap of commits (green=adds, red=deletes, amber=mixed) |
70
+ | 3 | Commits | Message, hash, date, and stats for visible commits |
71
+ | 4 | Diff | Syntax-highlighted diff with blame, search, and context controls |
72
+ | 5 | Changed Files | All files touched by the current commit |
73
+
58
74
  ## Features
59
75
 
60
- - **Visual timeline** with heatmap-colored ticks (green=adds, red=deletes, amber=mixed)
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, `X` to snap nearest pin
63
- - **Syntax-highlighted diffs** with inline, whole-file, and side-by-side views
76
+ ### Timeline Navigation
77
+
78
+ Scrub through a file's commit history one tick at a time. Each tick is colored by change type — green for additions, red for deletions, amber for mixed.
79
+
80
+ ![Timeline navigation](assets/gvt-timeline-navigation.gif)
81
+
82
+ ### Pin Mode
83
+
84
+ Press `x` to pin a commit, then move to another and press `x` again to diff any two commits. Press `x` a third time to clear. Use `X` to snap the nearest pin to your cursor.
85
+
86
+ ![Pin mode](assets/gvt-pin-mode.gif)
87
+
88
+ ### Inline Blame
89
+
90
+ Toggle blame annotations with `b` to see who last modified each line, right-aligned alongside the diff.
91
+
92
+ ![Blame mode](assets/gvt-blame-mode.gif)
93
+
94
+ ### File Search
95
+
96
+ Press `f` for an fzf-style fuzzy file picker that filters as you type.
97
+
98
+ ![File search](assets/gvt-file-search.gif)
99
+
100
+ ### All Features
101
+
102
+ - **Syntax-highlighted diffs** with inline, whole-file (`w`), and side-by-side (`d`) views
64
103
  - **Diff search** (`/`) — regex search within the diff with `n`/`p` to navigate matches
65
- - **Commit search** (`c`) — fuzzy search all repo commits by message, branch name, or author, then drill into changed files
66
- - **File search** (`f`) — fzf-style file picker
104
+ - **Commit search** (`c`) — fuzzy search all repo commits by message, branch, or author
67
105
  - **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, 6m, 1y, custom date)
68
- - **Inline blame** (`b`) — right-aligned blame annotations
69
- - **Contributor breakdown** (`B`) — visual bar chart of who changed the file
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
106
+ - **Contributor breakdown** (`B`) — who changed the file and how much
107
+ - **WIP indicator** — hollow tick showing uncommitted changes
108
+ - **Copy to clipboard** (`y`/`Y`) — short or full commit hash
74
109
  - **Open in editor** (`e`) — open current file in `$VISUAL`/`$EDITOR`/vim
75
110
  - **Remember last file** — reopens to the last file you were viewing per repo
76
- - **5-pane layout** with numbered switching (1-5) and Ctrl+hjkl navigation
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
111
+ - **tmux integration** — seamless pane switching at edges
79
112
  - **Preloaded diffs** — adjacent commits pre-cached for instant navigation
80
113
  - **Context-sensitive status bar** showing relevant shortcuts per pane
81
- - **Untracked files** — shown in a separate section, viewable as read-only preview
82
114
 
83
115
  ## Keybindings
84
116
 
@@ -10,9 +10,11 @@ src/git_visual_timeline.egg-info/top_level.txt
10
10
  src/gvt/__init__.py
11
11
  src/gvt/app.py
12
12
  src/gvt/cli.py
13
+ src/gvt/logging_setup.py
13
14
  src/gvt/git/__init__.py
14
15
  src/gvt/git/cache.py
15
16
  src/gvt/git/repo.py
17
+ src/gvt/styles/app.tcss
16
18
  src/gvt/widgets/__init__.py
17
19
  src/gvt/widgets/changed_files.py
18
20
  src/gvt/widgets/commit_bar.py
@@ -22,11 +24,14 @@ src/gvt/widgets/file_tree.py
22
24
  src/gvt/widgets/modals.py
23
25
  src/gvt/widgets/status_bar.py
24
26
  src/gvt/widgets/timeline.py
27
+ tests/test_app_actions.py
25
28
  tests/test_app_integration.py
26
29
  tests/test_cache.py
27
30
  tests/test_changed_files.py
28
31
  tests/test_diff_view_logic.py
29
32
  tests/test_git_repo.py
30
33
  tests/test_git_repo_extended.py
34
+ tests/test_logging_setup.py
35
+ tests/test_repo_resilience.py
31
36
  tests/test_timeline_logic.py
32
37
  tests/test_widgets.py
@@ -0,0 +1 @@
1
+ __version__ = "0.2.2"
@@ -4,16 +4,25 @@ from __future__ import annotations
4
4
 
5
5
  import hashlib
6
6
  import os
7
+ import shutil
8
+ import subprocess
9
+ from datetime import datetime, timezone
7
10
  from pathlib import Path
8
11
 
12
+ from git.exc import GitCommandError
13
+ from rich.text import Text
9
14
  from textual import on, work
10
15
  from textual.app import App, ComposeResult
11
16
  from textual.binding import Binding
12
17
  from textual.containers import Container, Horizontal, Vertical
18
+ from textual.css.query import NoMatches
13
19
  from textual.widget import Widget
14
20
 
15
21
  from gvt.git.cache import DiffCache
16
22
  from gvt.git.repo import CommitInfo, GitRepo
23
+ from gvt.logging_setup import get_logger
24
+
25
+ log = get_logger(__name__)
17
26
  from gvt.widgets.changed_files import ChangedFilesWidget, ChangedFileSelected, ChangedFileHighlighted
18
27
  from gvt.widgets.commit_bar import CommitMessageBar, ShowCommitDetail
19
28
  from gvt.widgets.diff_view import DiffContextChanged, DiffViewWidget
@@ -23,7 +32,6 @@ from gvt.widgets.modals import (
23
32
  CommitFilesModal,
24
33
  CommitSearchModal,
25
34
  FileSearchModal,
26
- FlashAuthorModal,
27
35
  HelpModal,
28
36
  QuitConfirmModal,
29
37
  TimeFilterModal,
@@ -206,7 +214,6 @@ class GVTApp(App):
206
214
  diff_view.set_diff("")
207
215
  diff_view.set_message("")
208
216
  # Build a simple preview with line numbers
209
- from rich.text import Text
210
217
  lines = []
211
218
  for i, line_text in enumerate(content.split("\n"), 1):
212
219
  t = Text()
@@ -240,8 +247,6 @@ class GVTApp(App):
240
247
  @work(thread=True)
241
248
  def _do_load_file(self, file_path: str) -> None:
242
249
  """Load file commits in background thread."""
243
- from datetime import datetime, timezone
244
-
245
250
  commits = self.git_repo.get_file_commits(file_path)
246
251
 
247
252
  # Append WIP tick if file has uncommitted changes
@@ -259,8 +264,8 @@ class GVTApp(App):
259
264
  is_wip=True,
260
265
  )
261
266
  commits.append(wip_commit)
262
- except Exception:
263
- pass
267
+ except GitCommandError as e:
268
+ log.warning("WIP probe for %s failed: %s", file_path, e)
264
269
 
265
270
  self.call_from_thread(self._apply_loaded_file, file_path, commits)
266
271
 
@@ -373,11 +378,18 @@ class GVTApp(App):
373
378
  @work(thread=True)
374
379
  def _load_diff(self, file_path: str, left_idx: int, right_idx: int) -> None:
375
380
  """Load diff between two commits, using cache."""
376
- if not self.current_commits:
381
+ commits = list(self.current_commits)
382
+ if not commits:
383
+ return
384
+
385
+ if left_idx >= len(commits) or right_idx >= len(commits):
386
+ return
387
+
388
+ if self.current_file != file_path:
377
389
  return
378
390
 
379
- left = self.current_commits[left_idx]
380
- right = self.current_commits[right_idx]
391
+ left = commits[left_idx]
392
+ right = commits[right_idx]
381
393
  diff_view = self.query_one("#diff-view", DiffViewWidget)
382
394
 
383
395
  if left.hexsha == right.hexsha:
@@ -426,11 +438,11 @@ class GVTApp(App):
426
438
  @work(thread=True, exclusive=True, group="preload")
427
439
  def _preload_adjacent_diffs(self, file_path: str, cursor_idx: int, context: int) -> None:
428
440
  """Preload diffs for adjacent timeline positions into the cache."""
429
- if not self.current_commits or len(self.current_commits) < 2:
441
+ commits = list(self.current_commits)
442
+ if not commits or len(commits) < 2:
430
443
  return
431
444
 
432
445
  cache_key_suffix = f"_ctx{context}"
433
- commits = self.current_commits
434
446
 
435
447
  # Adjacent pairs to preload: (N-1 → N) and (N → N+1)
436
448
  pairs = []
@@ -482,8 +494,8 @@ class GVTApp(App):
482
494
  try:
483
495
  widget = self.query_one(f"#{widget_id}")
484
496
  widget.focus()
485
- except Exception:
486
- pass
497
+ except NoMatches:
498
+ log.debug("focus_pane: widget #%s not present", widget_id)
487
499
 
488
500
  def action_focus_next_pane(self) -> None:
489
501
  self._current_pane_idx = (self._current_pane_idx + 1) % len(self._pane_order)
@@ -503,7 +515,6 @@ class GVTApp(App):
503
515
  def _tmux_select_pane(direction: str) -> None:
504
516
  """Hand off navigation to tmux if running inside tmux."""
505
517
  if os.environ.get("TMUX"):
506
- import subprocess
507
518
  subprocess.run(["tmux", "select-pane", f"-{direction}"], check=False)
508
519
 
509
520
  def action_focus_left(self) -> None:
@@ -677,7 +688,8 @@ class GVTApp(App):
677
688
  if diff_view.blame_enabled and self.current_file and self.current_commits:
678
689
  timeline = self.query_one("#timeline-widget", TimelineWidget)
679
690
  right_commit = self.current_commits[timeline.right_cursor]
680
- self._load_blame(self.current_file, right_commit.hexsha)
691
+ if not right_commit.is_wip:
692
+ self._load_blame(self.current_file, right_commit.hexsha)
681
693
 
682
694
  def action_flash_last_author(self) -> None:
683
695
  """Show who last modified the file and contributor breakdown."""
@@ -686,10 +698,18 @@ class GVTApp(App):
686
698
  timeline = self.query_one("#timeline-widget", TimelineWidget)
687
699
  commit = self.current_commits[timeline.cursor]
688
700
  contributors = self.git_repo.get_file_contributors(self.current_file)
689
- self.push_screen(FlashAuthorModal(
690
- commit.author, commit.short_hash, commit.date,
691
- contributors, self.current_file,
692
- ))
701
+
702
+ # Build contributor text for notification (no modal — avoids ghosting)
703
+ total = sum(count for _, count in contributors)
704
+ lines = [f"Last modified by {commit.author} ({commit.short_hash})"]
705
+ if total:
706
+ lines.append("")
707
+ for name, count in contributors[:8]:
708
+ pct = count / total * 100
709
+ bar = "█" * max(1, round(count / total * 20))
710
+ lines.append(f" {bar} {name} {count} commits ({pct:.0f}%)")
711
+ self.clear_notifications()
712
+ self.notify("\n".join(lines), title="Contributors", timeout=5)
693
713
 
694
714
  def action_copy_short_hash(self) -> None:
695
715
  if not self.current_commits:
@@ -706,8 +726,6 @@ class GVTApp(App):
706
726
  self._copy_to_clipboard(commit.hexsha)
707
727
 
708
728
  def _copy_to_clipboard(self, text: str) -> None:
709
- import subprocess
710
- import shutil
711
729
  try:
712
730
  if shutil.which("pbcopy"):
713
731
  subprocess.run(["pbcopy"], input=text.encode(), check=True)
@@ -719,21 +737,26 @@ class GVTApp(App):
719
737
  self.notify("No clipboard tool found", timeout=2)
720
738
  return
721
739
  self.notify(f"Copied {text}", timeout=2)
722
- except Exception:
740
+ except (subprocess.CalledProcessError, OSError) as e:
741
+ log.warning("clipboard copy failed: %s", e)
723
742
  self.notify("Failed to copy to clipboard", timeout=2)
724
743
 
725
744
  def action_open_in_editor(self) -> None:
726
745
  if not self.current_file:
727
746
  return
728
- import shutil
729
747
  editor = os.environ.get("VISUAL") or os.environ.get("EDITOR") or "vim"
730
748
  file_path = os.path.join(self.repo_path, self.current_file)
731
- self.suspend()
732
- try:
733
- import subprocess
734
- subprocess.run([editor, file_path])
735
- finally:
736
- self.resume()
749
+ result = None
750
+ with self.suspend():
751
+ try:
752
+ result = subprocess.run([editor, file_path])
753
+ except (OSError, FileNotFoundError) as e:
754
+ log.warning("editor %s failed to launch: %s", editor, e)
755
+ if result is None:
756
+ self.notify(f"Could not launch editor: {editor}", timeout=3)
757
+ elif result.returncode != 0:
758
+ log.warning("editor %s exited with code %d", editor, result.returncode)
759
+ self.notify(f"Editor exited with code {result.returncode}", timeout=2)
737
760
 
738
761
  @work(thread=True)
739
762
  def _load_blame(self, file_path: str, commit_sha: str) -> None:
@@ -26,31 +26,41 @@ def main():
26
26
 
27
27
  args = parser.parse_args()
28
28
 
29
- # Validate we're in a git repo
30
29
  from git import InvalidGitRepositoryError, Repo
31
30
 
32
- try:
33
- repo = Repo(os.getcwd(), search_parent_directories=True)
34
- except InvalidGitRepositoryError:
35
- print("Error: not a git repository (or any parent)", file=sys.stderr)
36
- sys.exit(1)
31
+ initial_file = None
32
+ abs_target = os.path.abspath(args.file) if args.file else None
33
+
34
+ if abs_target:
35
+ # Determine which repo the target lives in.
36
+ # If the target is a directory, treat it as a repo root (or search up);
37
+ # if it's a file, search from its parent directory.
38
+ search_dir = abs_target if os.path.isdir(abs_target) else os.path.dirname(abs_target)
39
+ try:
40
+ repo = Repo(search_dir, search_parent_directories=True)
41
+ except InvalidGitRepositoryError:
42
+ print(f"Error: {args.file} is not inside a git repository", file=sys.stderr)
43
+ sys.exit(1)
37
44
 
38
- # Validate file argument if provided
39
- if args.file:
40
45
  repo_root = repo.working_tree_dir
41
- file_path = os.path.relpath(os.path.abspath(args.file), repo_root)
42
- full_path = os.path.join(repo_root, file_path)
43
- if not os.path.exists(full_path):
44
- print(f"Error: file not found: {args.file}", file=sys.stderr)
46
+ if os.path.isdir(abs_target):
47
+ # Target is a directory (repo root) — open without initial file
48
+ initial_file = None
49
+ else:
50
+ if not os.path.exists(abs_target):
51
+ print(f"Error: file not found: {args.file}", file=sys.stderr)
52
+ sys.exit(1)
53
+ initial_file = os.path.relpath(abs_target, repo_root)
54
+ else:
55
+ # No argument — use cwd's repo
56
+ try:
57
+ repo = Repo(os.getcwd(), search_parent_directories=True)
58
+ except InvalidGitRepositoryError:
59
+ print("Error: not a git repository (or any parent)", file=sys.stderr)
45
60
  sys.exit(1)
46
61
 
47
62
  from gvt.app import GVTApp
48
63
 
49
- initial_file = None
50
- if args.file:
51
- repo_root = repo.working_tree_dir
52
- initial_file = os.path.relpath(os.path.abspath(args.file), repo_root)
53
-
54
64
  import signal
55
65
  import subprocess
56
66
 
@@ -65,8 +75,10 @@ def main():
65
75
  sys.stdout.write("\033[0m") # reset colors
66
76
  sys.stdout.write("\033c") # full terminal reset
67
77
  sys.stdout.flush()
68
- except Exception:
69
- pass
78
+ except Exception as e:
79
+ # Signal handler — must never raise. Log best-effort then exit.
80
+ from gvt.logging_setup import get_logger
81
+ get_logger(__name__).warning("terminal cleanup failed: %s", e)
70
82
  os._exit(128 + signum)
71
83
 
72
84
  signal.signal(signal.SIGTERM, _cleanup_terminal)
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import threading
5
6
  from collections import OrderedDict
6
7
  from typing import Callable
7
8
 
@@ -14,6 +15,7 @@ class DiffCache:
14
15
  def __init__(self, max_size: int = 100):
15
16
  self.max_size = max_size
16
17
  self._cache: OrderedDict[tuple[str, str, str], str] = OrderedDict()
18
+ self._lock = threading.Lock()
17
19
 
18
20
  def get_or_compute(
19
21
  self,
@@ -26,30 +28,38 @@ class DiffCache:
26
28
  Return cached diff or compute it and cache the result.
27
29
  """
28
30
  key = (file_path, commit_a, commit_b)
29
- if key in self._cache:
30
- self._cache.move_to_end(key)
31
- return self._cache[key]
31
+ with self._lock:
32
+ if key in self._cache:
33
+ self._cache.move_to_end(key)
34
+ return self._cache[key]
32
35
 
36
+ # Compute outside the lock to avoid blocking other threads
33
37
  value = compute_fn()
34
- self._cache[key] = value
35
- if len(self._cache) > self.max_size:
36
- self._cache.popitem(last=False)
38
+
39
+ with self._lock:
40
+ self._cache[key] = value
41
+ if len(self._cache) > self.max_size:
42
+ self._cache.popitem(last=False)
37
43
  return value
38
44
 
39
45
  def get(self, file_path: str, commit_a: str, commit_b: str) -> str | None:
40
46
  """Return cached diff or None."""
41
47
  key = (file_path, commit_a, commit_b)
42
- if key in self._cache:
43
- self._cache.move_to_end(key)
44
- return self._cache[key]
48
+ with self._lock:
49
+ if key in self._cache:
50
+ self._cache.move_to_end(key)
51
+ return self._cache[key]
45
52
  return None
46
53
 
47
54
  def has(self, file_path: str, commit_a: str, commit_b: str) -> bool:
48
55
  """Check if a diff is already cached."""
49
- return (file_path, commit_a, commit_b) in self._cache
56
+ with self._lock:
57
+ return (file_path, commit_a, commit_b) in self._cache
50
58
 
51
59
  def clear(self) -> None:
52
- self._cache.clear()
60
+ with self._lock:
61
+ self._cache.clear()
53
62
 
54
63
  def __len__(self) -> int:
55
- return len(self._cache)
64
+ with self._lock:
65
+ return len(self._cache)