4259fb5dff46
close the log removal's review findings: completion, stale names, three sharper tests (3.0.93)
- time
- 2026-09-27 14:52 UTC · 2 weeks ago
- machine
- Junes-MacBook-Pro.local
- agent
- deepseek/deepseek-flash
- session
- koh3 help and history
- parent
- ea43d4f3e936
↓ koh-4259fb5d.tar.gzatlas at this save
files changed5 files
VERSION+1 −1shell/koh3.plugin.zsh+3 −5src/cli/cmd_view.v+4 −4tests/cli_test.v+10 −5v.mod+1 −1shell/koh3.plugin.zsh+3 −5
@@ -125,7 +125,7 @@125125 'save:snapshot the working tree'126126 'checkpoint:save, even with no changes'127127 'status:what changed since the last save'128- 'log:the line, newest first'128+ 'view:the history, saves and checkpoints'129129 'diff:unified diff'130130 'undo:step back n saves'131131 'revert:discard unsaved changes'@@ -141,12 +141,10 @@141141 'strip:remove a path from history'142142 'migrate:convert a Koh 2 repo here'143143 'man:the manual, built in'144- 'saves:the history view on the saves tab'145- 'checkpoints:the history view on the checkpoints tab'146144 )147145 _koh3_ids() {148146 local -a ids149- ids=(${(f)"$(command $(_koh_bin) log --json 2>/dev/null |147+ ids=(${(f)"$(command $(_koh_bin) view --json 2>/dev/null |150148 grep -o '"id":"[0-9a-f]*","parent":"[0-9a-f]*","message":"[^"]*"' |151149 sed -E 's/"id":"([0-9a-f]*)".*"message":"([^"]*)"/\1:\2/' | head -30)"})152150 _describe 'save' ids@@ -157,7 +155,7 @@157155 fi158156 case $words[2] in159157 save|checkpoint) _arguments '--agent[model name]:agent:' '--session[session name]:session:' '--json' ;;160- log) _arguments '--since[filter by time]:expr:' '--session[session name]:session:' '--json' ;;158+ view) _arguments '--checkpoints[start on the checkpoints tab]' '--since[filter by time]:expr:' '--session[session name]:session:' '--json' ;;161159 diff|load|peek) _koh3_ids ;;162160 pluck) _arguments '--reverse' '--dry-run' '*:save:_koh3_ids' ;;163161 flag) _arguments '--reason[why]:reason:' '--clear' '--json' '*:save:_koh3_ids' ;;src/cli/cmd_view.v+4 −4
@@ -59,7 +59,7 @@5959 shown << save6060 }6161 if args.json() {62- emit_json(json2.encode(LogJson{62+ emit_json(json2.encode(ViewJson{6363 head_id: head_id6464 saves: shown.map(to_json(it))6565 }))@@ -70,7 +70,7 @@7070 return 07171 }7272 for save in shown {73- println(log_line(save, save.id == head_id, flags))73+ println(view_line(save, save.id == head_id, flags))7474 }7575 return 07676 }@@ -138,7 +138,7 @@138138 replayed_from string139139 }140140 141-struct LogJson {141+struct ViewJson {142142 head_id string143143 saves []SaveJson144144 }@@ -158,7 +158,7 @@158158 }159159 }160160 161-fn log_line(save history.Save, is_head bool, flags map[string]events.Flag) string {161+fn view_line(save history.Save, is_head bool, flags map[string]events.Flag) string {162162 marker := if is_head { fmt.amber('▸') } else { ' ' }163163 mut line := ' ${marker} ${fmt.dim('[' + save.id + ']')} ${fmt.stamp(save.created_at)} ${save.message}'164164 mut tags := []string{}tests/cli_test.v+10 −5
@@ -584,6 +584,7 @@584584 session := run(dir, 'view', '--session', 'alpha')585585 assert session.out.contains('one')586586 assert !session.out.contains('two')587+ assert run(dir, 'view', '--since', '9999-01-01').out.contains('no saves in that range')587588 write(dir, 'a.txt', 'three\n')588589 d := run(dir, 'diff')589590 assert d.code == 0@@ -807,12 +808,16 @@807808 assert json_checkpoints.code == 0808809 assert json_checkpoints.out.contains('"is_checkpoint":true')809810 assert !json_checkpoints.out.contains('"is_checkpoint":false')810- // `view` takes no arguments, so a stray one is a usage error, and `log` is811- // gone rather than hidden.811+ // `view` takes no arguments, so a stray one is a usage error, and the names812+ // it replaced are gone rather than hidden: the diagnostic says which.812813 assert run(dir, 'view', 'extra').code == 2813- assert run(dir, 'log').code == 2814- assert run(dir, 'saves').code == 2815- assert run(dir, 'checkpoints').code == 2814+ for gone in ['log', 'saves', 'checkpoints'] {815+ refused := run(dir, gone)816+ assert refused.code == 2817+ assert refused.err.contains('unknown command "${gone}"')818+ }819+ // Every save is on the whole line exactly once, as the JSON says.820+ assert line.out.split_into_lines().len == json_line.out.count('"id":"')816821 }817822 818823 fn test_remote_configuration_is_isolated_and_atomic() {v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 name: 'koh3'3- version: '3.0.92'3+ version: '3.0.93'44 description: 'One SQLite file per repo, one line of history.'55 license: 'MIT'66 }