b4580cd02192

compute the history view's detail diff once per save, not per key (3.0.25, codex review pending)

time
2026-09-23 22:35 UTC · 2 weeks ago
machine
koh2
agent
claude-opus-5-5
session
koh 3 review fixes
parent
b3e8bdf8a104
3 files VERSION+1 −1src/view/view.v+14 −6v.mod+1 −1
VERSION+1 −1
@@ -1 +1 @@1-3.0.241+3.0.25

view file

src/view/view.v+14 −6
@@ -81,6 +81,9 @@8181 	typed  string8282 	// set when an action changed history, so the lists are read again8383 	stale bool84+	// the detail's diff, worked out once per save rather than per key85+	deltas     []snapshot.Delta86+	deltas_for string8487 }8588 8689 // run shows the view until the user leaves it. `act` performs a chosen action@@ -114,7 +117,7 @@114117 			session.screen.selected = move_selection(session.screen.selected, 0,115118 				session.screen.items.len)116119 		}117-		paint(frame_for(store, session))120+		paint(frame_for(store, mut session))118121 		key := read_key()119122 		if key.kind in [.interrupt, .eof] {120123 			return@@ -132,13 +135,18 @@132135 	}133136 }134137 135-fn frame_for(store &storage.Store, session Session) string {138+fn frame_for(store &storage.Store, mut session Session) string {136139 	match session.mode {137140 		.detail, .reason {138-			delta := snapshot.diff_trees(store, parent_tree(store, session.target), child_tree(store,139-				session.target)) or { []snapshot.Delta{} }140-			return detail_frame(session.screen, session.target, delta, session.mode == .reason,141-				session.typed)141+			// Typing a flag reason repaints on every key; diffing a large save142+			// each time would stall the typing.143+			if session.deltas_for != session.target.id {144+				session.deltas = snapshot.diff_trees(store, parent_tree(store, session.target), child_tree(store,145+					session.target)) or { []snapshot.Delta{} }146+				session.deltas_for = session.target.id147+			}148+			return detail_frame(session.screen, session.target, session.deltas,149+				session.mode == .reason, session.typed)142150 		}143151 		else {144152 			return render(session.screen)

view file

v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 	name: 'koh3'3-	version: '3.0.24'3+	version: '3.0.25'44 	description: 'One SQLite file per repo, one line of history.'55 	license: 'MIT'66 }

view file