bots-garden/razorbillpublic Fork
⑂ a517971
Commits
⬇ Clone ▾
git clone https://git.rickub.com/bots-garden/razorbill.git
git clone ssh://git@rickub.com/bots-garden/razorbill.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

#63: TUI chat — reasoning in cyan, a colour of its own

Style.reasoning (ANSI 36) for the shown reasoning lines and the folded
line, streaming included; the answer stays in the default colour, stats
dim, errors red; the ⋯ prefix keeps it distinct without colours. The
"waiting for the model" line stays dim (it is not reasoning). Fixed
colour, no reasoning_color preference for now. ChatRendererTests moved
to their own file (file length limit) with colour tests. Docs EN+FR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
k33g committed 2026-11-27T08:07:27+01:00 Browse files
a517971 parent: 783675c
modified .quality/history.jsonl +1 -0
@@ -41,3 +41,4 @@
4141 {"branch": "feature/v0.3-tui", "breaches": [], "commit": "1dea285", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 373, "complex": 915, "cyclo": 1079, "fields": 1985, "funcs": 985, "lcom": 179, "lines": 17449, "loc": 13886}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 41, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T05:27:09Z"}
4242 {"branch": "feature/v0.3-tui", "breaches": ["warning-level issues: 1 (max 0)"], "commit": "3780f1a", "counts": {"warning": 1}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": false, "metrics": {"classes": 374, "complex": 945, "cyclo": 1101, "fields": 1998, "funcs": 997, "lcom": 181, "lines": 17665, "loc": 14066}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 42, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T06:31:51Z"}
4343 {"branch": "feature/v0.3-tui", "breaches": [], "commit": "3780f1a", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 375, "complex": 945, "cyclo": 1101, "fields": 2000, "funcs": 997, "lcom": 181, "lines": 17671, "loc": 14069}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 43, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T06:32:10Z"}
44+{"branch": "feature/v0.3-tui", "breaches": [], "commit": "783675c", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 375, "complex": 945, "cyclo": 1102, "fields": 2008, "funcs": 1003, "lcom": 182, "lines": 17738, "loc": 14115}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 44, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T07:05:16Z"}
@@ -41,3 +41,4 @@
41 {"branch": "feature/v0.3-tui", "breaches": [], "commit": "1dea285", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 373, "complex": 915, "cyclo": 1079, "fields": 1985, "funcs": 985, "lcom": 179, "lines": 17449, "loc": 13886}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 41, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T05:27:09Z"}41 {"branch": "feature/v0.3-tui", "breaches": [], "commit": "1dea285", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 373, "complex": 915, "cyclo": 1079, "fields": 1985, "funcs": 985, "lcom": 179, "lines": 17449, "loc": 13886}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 41, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T05:27:09Z"}
42 {"branch": "feature/v0.3-tui", "breaches": ["warning-level issues: 1 (max 0)"], "commit": "3780f1a", "counts": {"warning": 1}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": false, "metrics": {"classes": 374, "complex": 945, "cyclo": 1101, "fields": 1998, "funcs": 997, "lcom": 181, "lines": 17665, "loc": 14066}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 42, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T06:31:51Z"}42 {"branch": "feature/v0.3-tui", "breaches": ["warning-level issues: 1 (max 0)"], "commit": "3780f1a", "counts": {"warning": 1}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": false, "metrics": {"classes": 374, "complex": 945, "cyclo": 1101, "fields": 1998, "funcs": 997, "lcom": 181, "lines": 17665, "loc": 14066}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 42, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T06:31:51Z"}
43 {"branch": "feature/v0.3-tui", "breaches": [], "commit": "3780f1a", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 375, "complex": 945, "cyclo": 1101, "fields": 2000, "funcs": 997, "lcom": 181, "lines": 17671, "loc": 14069}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 43, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T06:32:10Z"}43 {"branch": "feature/v0.3-tui", "breaches": [], "commit": "3780f1a", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 375, "complex": 945, "cyclo": 1101, "fields": 2000, "funcs": 997, "lcom": 181, "lines": 17671, "loc": 14069}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 43, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T06:32:10Z"}
44+{"branch": "feature/v0.3-tui", "breaches": [], "commit": "783675c", "counts": {}, "gate": {"max_error": 0, "max_smells": 0, "max_warning": 0}, "gate_passed": true, "metrics": {"classes": 375, "complex": 945, "cyclo": 1102, "fields": 2008, "funcs": 1003, "lcom": 182, "lines": 17738, "loc": 14115}, "qlty_version": "qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)", "run": 44, "smells": 0, "swiftlint_version": "0.65.1", "timestamp": "2026-11-27T07:05:16Z"}
added .quality/report-20261127T070516Z.md +73 -0
new file mode 100644
@@ -0,0 +1,73 @@
1+# Quality report — 2026-11-27T07:05:16Z
2+
3+- **Gate**: ✅ **PASS**
4+- **Commit**: `783675c` on `feature/v0.3-tui`
5+- **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)
6+- **swiftlint**: 0.65.1 (run directly, merged into lint issues)
7+- **Run**: #44 (previous: 2026-11-27T06:32:10Z)
8+
9+## Lint issues (`qlty check`)
10+
11+_none_
12+
13+### Top rules
14+
15+_none_
16+
17+### Most affected files
18+
19+_none_
20+
21+## Code smells (`qlty smells`)
22+
23+Total: **0** (vs previous: ±0)
24+
25+_none_
26+
27+## Metrics (`qlty metrics`)
28+
29+| metric | total | vs previous |
30+|---|---|---|
31+| funcs | 1003 | +6 |
32+| classes | 375 | ±0 |
33+| fields | 2008 | +8 |
34+| cyclo | 1102 | +1 |
35+| complex | 945 | ±0 |
36+| lcom | 182 | +1 |
37+| lines | 17738 | +67 |
38+| loc | 14115 | +46 |
39+
40+### Most complex files
41+
42+| file | complex | cyclo | loc |
43+|---|---|---|---|
44+| Sources/RazorbillServer/CompletionsRoute.swift | 47 | 20 | 244 |
45+| Sources/RazorbillServer/Chat/CompletionStream.swift | 31 | 20 | 125 |
46+| Sources/RazorbillTUI/ChatScreen.swift | 31 | 41 | 230 |
47+| Sources/RazorbillTUI/TextLayout.swift | 28 | 15 | 63 |
48+| experiments/02-kv-cache-reuse/Sources/KVCacheReuse/KVCacheReuse.swift | 26 | 20 | 285 |
49+| Sources/RazorbillServer/ModelManager.swift | 25 | 26 | 268 |
50+| Sources/RazorbillTUI/DashboardScreen.swift | 24 | 22 | 136 |
51+| Sources/RazorbillMLX/MLXEngine.swift | 23 | 37 | 251 |
52+| Sources/RazorbillTUI/ServerAPI.swift | 23 | 23 | 158 |
53+| tools/host-runner/host_runner.py | 23 | 23 | 144 |
54+| Sources/RazorbillCore/Config/TUIPreferences.swift | 21 | 20 | 152 |
55+| Sources/RazorbillTUI/TUIApp.swift | 21 | 35 | 228 |
56+| Sources/RazorbillCore/Config/ConfigValue+JSON.swift | 20 | 25 | 71 |
57+| Sources/RazorbillCore/Config/ServerConfigLoader.swift | 20 | 17 | 227 |
58+| Sources/RazorbillTUI/Terminal.swift | 20 | 18 | 139 |
59+
60+## Trend
61+
62+| run | timestamp | error | warning | smells | complex | gate |
63+|---|---|---|---|---|---|---|
64+| 35 | 2026-11-26T14:42:16Z | 0 | 0 | 0 | 548 | PASS |
65+| 36 | 2026-11-26T21:35:08Z | 0 | 0 | 0 | 588 | PASS |
66+| 37 | 2026-11-27T04:12:05Z | 0 | 0 | 0 | 717 | PASS |
67+| 38 | 2026-11-27T04:37:14Z | 0 | 0 | 0 | 815 | PASS |
68+| 39 | 2026-11-27T05:12:36Z | 0 | 0 | 1 | 906 | FAIL |
69+| 40 | 2026-11-27T05:13:16Z | 0 | 0 | 0 | 890 | PASS |
70+| 41 | 2026-11-27T05:27:09Z | 0 | 0 | 0 | 915 | PASS |
71+| 42 | 2026-11-27T06:31:51Z | 0 | 1 | 0 | 945 | FAIL |
72+| 43 | 2026-11-27T06:32:10Z | 0 | 0 | 0 | 945 | PASS |
73+| 44 | 2026-11-27T07:05:16Z | 0 | 0 | 0 | 945 | PASS |
new file mode 100644
@@ -0,0 +1,73 @@
1+# Quality report — 2026-11-27T07:05:16Z
2+
3+- **Gate**: ✅ **PASS**
4+- **Commit**: `783675c` on `feature/v0.3-tui`
5+- **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)
6+- **swiftlint**: 0.65.1 (run directly, merged into lint issues)
7+- **Run**: #44 (previous: 2026-11-27T06:32:10Z)
8+
9+## Lint issues (`qlty check`)
10+
11+_none_
12+
13+### Top rules
14+
15+_none_
16+
17+### Most affected files
18+
19+_none_
20+
21+## Code smells (`qlty smells`)
22+
23+Total: **0** (vs previous: ±0)
24+
25+_none_
26+
27+## Metrics (`qlty metrics`)
28+
29+| metric | total | vs previous |
30+|---|---|---|
31+| funcs | 1003 | +6 |
32+| classes | 375 | ±0 |
33+| fields | 2008 | +8 |
34+| cyclo | 1102 | +1 |
35+| complex | 945 | ±0 |
36+| lcom | 182 | +1 |
37+| lines | 17738 | +67 |
38+| loc | 14115 | +46 |
39+
40+### Most complex files
41+
42+| file | complex | cyclo | loc |
43+|---|---|---|---|
44+| Sources/RazorbillServer/CompletionsRoute.swift | 47 | 20 | 244 |
45+| Sources/RazorbillServer/Chat/CompletionStream.swift | 31 | 20 | 125 |
46+| Sources/RazorbillTUI/ChatScreen.swift | 31 | 41 | 230 |
47+| Sources/RazorbillTUI/TextLayout.swift | 28 | 15 | 63 |
48+| experiments/02-kv-cache-reuse/Sources/KVCacheReuse/KVCacheReuse.swift | 26 | 20 | 285 |
49+| Sources/RazorbillServer/ModelManager.swift | 25 | 26 | 268 |
50+| Sources/RazorbillTUI/DashboardScreen.swift | 24 | 22 | 136 |
51+| Sources/RazorbillMLX/MLXEngine.swift | 23 | 37 | 251 |
52+| Sources/RazorbillTUI/ServerAPI.swift | 23 | 23 | 158 |
53+| tools/host-runner/host_runner.py | 23 | 23 | 144 |
54+| Sources/RazorbillCore/Config/TUIPreferences.swift | 21 | 20 | 152 |
55+| Sources/RazorbillTUI/TUIApp.swift | 21 | 35 | 228 |
56+| Sources/RazorbillCore/Config/ConfigValue+JSON.swift | 20 | 25 | 71 |
57+| Sources/RazorbillCore/Config/ServerConfigLoader.swift | 20 | 17 | 227 |
58+| Sources/RazorbillTUI/Terminal.swift | 20 | 18 | 139 |
59+
60+## Trend
61+
62+| run | timestamp | error | warning | smells | complex | gate |
63+|---|---|---|---|---|---|---|
64+| 35 | 2026-11-26T14:42:16Z | 0 | 0 | 0 | 548 | PASS |
65+| 36 | 2026-11-26T21:35:08Z | 0 | 0 | 0 | 588 | PASS |
66+| 37 | 2026-11-27T04:12:05Z | 0 | 0 | 0 | 717 | PASS |
67+| 38 | 2026-11-27T04:37:14Z | 0 | 0 | 0 | 815 | PASS |
68+| 39 | 2026-11-27T05:12:36Z | 0 | 0 | 1 | 906 | FAIL |
69+| 40 | 2026-11-27T05:13:16Z | 0 | 0 | 0 | 890 | PASS |
70+| 41 | 2026-11-27T05:27:09Z | 0 | 0 | 0 | 915 | PASS |
71+| 42 | 2026-11-27T06:31:51Z | 0 | 1 | 0 | 945 | FAIL |
72+| 43 | 2026-11-27T06:32:10Z | 0 | 0 | 0 | 945 | PASS |
73+| 44 | 2026-11-27T07:05:16Z | 0 | 0 | 0 | 945 | PASS |
modified .quality/report-latest.md +13 -15
@@ -1,16 +1,14 @@
1-# Quality report — 2026-11-27T06:32:10Z
1+# Quality report — 2026-11-27T07:05:16Z
22
33 - **Gate**: ✅ **PASS**
4-- **Commit**: `3780f1a` on `feature/v0.3-tui`
4+- **Commit**: `783675c` on `feature/v0.3-tui`
55 - **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)
66 - **swiftlint**: 0.65.1 (run directly, merged into lint issues)
7-- **Run**: #43 (previous: 2026-11-27T06:31:51Z)
7+- **Run**: #44 (previous: 2026-11-27T06:32:10Z)
88
99 ## Lint issues (`qlty check`)
1010
11-| level | count | vs previous |
12-|---|---|---|
13-| warning | 0 | -1 |
11+_none_
1412
1513 ### Top rules
1614
@@ -30,14 +28,14 @@ _none_
3028
3129 | metric | total | vs previous |
3230 |---|---|---|
33-| funcs | 997 | ±0 |
34-| classes | 375 | +1 |
35-| fields | 2000 | +2 |
36-| cyclo | 1101 | ±0 |
31+| funcs | 1003 | +6 |
32+| classes | 375 | ±0 |
33+| fields | 2008 | +8 |
34+| cyclo | 1102 | +1 |
3735 | complex | 945 | ±0 |
38-| lcom | 181 | ±0 |
39-| lines | 17671 | +6 |
40-| loc | 14069 | +3 |
36+| lcom | 182 | +1 |
37+| lines | 17738 | +67 |
38+| loc | 14115 | +46 |
4139
4240 ### Most complex files
4341
@@ -49,7 +47,7 @@ _none_
4947 | Sources/RazorbillTUI/TextLayout.swift | 28 | 15 | 63 |
5048 | experiments/02-kv-cache-reuse/Sources/KVCacheReuse/KVCacheReuse.swift | 26 | 20 | 285 |
5149 | Sources/RazorbillServer/ModelManager.swift | 25 | 26 | 268 |
52-| Sources/RazorbillTUI/DashboardScreen.swift | 25 | 23 | 132 |
50+| Sources/RazorbillTUI/DashboardScreen.swift | 24 | 22 | 136 |
5351 | Sources/RazorbillMLX/MLXEngine.swift | 23 | 37 | 251 |
5452 | Sources/RazorbillTUI/ServerAPI.swift | 23 | 23 | 158 |
5553 | tools/host-runner/host_runner.py | 23 | 23 | 144 |
@@ -63,7 +61,6 @@ _none_
6361
6462 | run | timestamp | error | warning | smells | complex | gate |
6563 |---|---|---|---|---|---|---|
66-| 34 | 2026-11-26T14:17:19Z | 0 | 0 | 0 | 547 | PASS |
6764 | 35 | 2026-11-26T14:42:16Z | 0 | 0 | 0 | 548 | PASS |
6865 | 36 | 2026-11-26T21:35:08Z | 0 | 0 | 0 | 588 | PASS |
6966 | 37 | 2026-11-27T04:12:05Z | 0 | 0 | 0 | 717 | PASS |
@@ -73,3 +70,4 @@ _none_
7370 | 41 | 2026-11-27T05:27:09Z | 0 | 0 | 0 | 915 | PASS |
7471 | 42 | 2026-11-27T06:31:51Z | 0 | 1 | 0 | 945 | FAIL |
7572 | 43 | 2026-11-27T06:32:10Z | 0 | 0 | 0 | 945 | PASS |
73+| 44 | 2026-11-27T07:05:16Z | 0 | 0 | 0 | 945 | PASS |
@@ -1,16 +1,14 @@
1-# Quality report — 2026-11-27T06:32:10Z1+# Quality report — 2026-11-27T07:05:16Z
2 2
3 - **Gate**: ✅ **PASS**3 - **Gate**: ✅ **PASS**
4-- **Commit**: `3780f1a` on `feature/v0.3-tui`4+- **Commit**: `783675c` on `feature/v0.3-tui`
5 - **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)5 - **qlty**: qlty 0.672.0 linux-arm64 (4362b62 2026-11-20)
6 - **swiftlint**: 0.65.1 (run directly, merged into lint issues)6 - **swiftlint**: 0.65.1 (run directly, merged into lint issues)
7-- **Run**: #43 (previous: 2026-11-27T06:31:51Z)7+- **Run**: #44 (previous: 2026-11-27T06:32:10Z)
8 8
9 ## Lint issues (`qlty check`)9 ## Lint issues (`qlty check`)
10 10
11-| level | count | vs previous |11+_none_
12-|---|---|---|
13-| warning | 0 | -1 |
14 12
15 ### Top rules13 ### Top rules
16 14
@@ -30,14 +28,14 @@ _none_
30 28
31 | metric | total | vs previous |29 | metric | total | vs previous |
32 |---|---|---|30 |---|---|---|
33-| funcs | 997 | ±0 |31+| funcs | 1003 | +6 |
34-| classes | 375 | +1 |32+| classes | 375 | ±0 |
35-| fields | 2000 | +2 |33+| fields | 2008 | +8 |
36-| cyclo | 1101 | ±0 |34+| cyclo | 1102 | +1 |
37 | complex | 945 | ±0 |35 | complex | 945 | ±0 |
38-| lcom | 181 | ±0 |36+| lcom | 182 | +1 |
39-| lines | 17671 | +6 |37+| lines | 17738 | +67 |
40-| loc | 14069 | +3 |38+| loc | 14115 | +46 |
41 39
42 ### Most complex files40 ### Most complex files
43 41
@@ -49,7 +47,7 @@ _none_
49 | Sources/RazorbillTUI/TextLayout.swift | 28 | 15 | 63 |47 | Sources/RazorbillTUI/TextLayout.swift | 28 | 15 | 63 |
50 | experiments/02-kv-cache-reuse/Sources/KVCacheReuse/KVCacheReuse.swift | 26 | 20 | 285 |48 | experiments/02-kv-cache-reuse/Sources/KVCacheReuse/KVCacheReuse.swift | 26 | 20 | 285 |
51 | Sources/RazorbillServer/ModelManager.swift | 25 | 26 | 268 |49 | Sources/RazorbillServer/ModelManager.swift | 25 | 26 | 268 |
52-| Sources/RazorbillTUI/DashboardScreen.swift | 25 | 23 | 132 |50+| Sources/RazorbillTUI/DashboardScreen.swift | 24 | 22 | 136 |
53 | Sources/RazorbillMLX/MLXEngine.swift | 23 | 37 | 251 |51 | Sources/RazorbillMLX/MLXEngine.swift | 23 | 37 | 251 |
54 | Sources/RazorbillTUI/ServerAPI.swift | 23 | 23 | 158 |52 | Sources/RazorbillTUI/ServerAPI.swift | 23 | 23 | 158 |
55 | tools/host-runner/host_runner.py | 23 | 23 | 144 |53 | tools/host-runner/host_runner.py | 23 | 23 | 144 |
@@ -63,7 +61,6 @@ _none_
63 61
64 | run | timestamp | error | warning | smells | complex | gate |62 | run | timestamp | error | warning | smells | complex | gate |
65 |---|---|---|---|---|---|---|63 |---|---|---|---|---|---|---|
66-| 34 | 2026-11-26T14:17:19Z | 0 | 0 | 0 | 547 | PASS |
67 | 35 | 2026-11-26T14:42:16Z | 0 | 0 | 0 | 548 | PASS |64 | 35 | 2026-11-26T14:42:16Z | 0 | 0 | 0 | 548 | PASS |
68 | 36 | 2026-11-26T21:35:08Z | 0 | 0 | 0 | 588 | PASS |65 | 36 | 2026-11-26T21:35:08Z | 0 | 0 | 0 | 588 | PASS |
69 | 37 | 2026-11-27T04:12:05Z | 0 | 0 | 0 | 717 | PASS |66 | 37 | 2026-11-27T04:12:05Z | 0 | 0 | 0 | 717 | PASS |
@@ -73,3 +70,4 @@ _none_
73 | 41 | 2026-11-27T05:27:09Z | 0 | 0 | 0 | 915 | PASS |70 | 41 | 2026-11-27T05:27:09Z | 0 | 0 | 0 | 915 | PASS |
74 | 42 | 2026-11-27T06:31:51Z | 0 | 1 | 0 | 945 | FAIL |71 | 42 | 2026-11-27T06:31:51Z | 0 | 1 | 0 | 945 | FAIL |
75 | 43 | 2026-11-27T06:32:10Z | 0 | 0 | 0 | 945 | PASS |72 | 43 | 2026-11-27T06:32:10Z | 0 | 0 | 0 | 945 | PASS |
73+| 44 | 2026-11-27T07:05:16Z | 0 | 0 | 0 | 945 | PASS |
modified .tickets/issues/0063-tui-chat-reasoning-in-its-own-colour.yaml +21 -5
@@ -1,12 +1,13 @@
11 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
22 id: 63
33 title: "TUI chat: show the reasoning in a colour of its own"
4-state: open
4+state: closed
55 author:
66 name: k33g
77 email: ph.charriere@gmail.com
88 createdAt: 2026-11-27T08:00:00.000Z
9-updatedAt: 2026-11-27T08:00:00.000Z
9+updatedAt: 2026-11-27T09:00:00.000Z
10+closedAt: 2026-11-27T09:00:00.000Z
1011 labels:
1112 - "kind::feature"
1213 - "area::tui"
@@ -33,18 +34,33 @@ body: |
3334 tasks:
3435 - id: 1
3536 title: "Reasoning colour in Style and ChatRenderer (shown, folded, streaming), tests"
36- state: open
37+ state: closed
3738 priority: medium
3839 author:
3940 name: k33g
4041 email: ph.charriere@gmail.com
4142 createdAt: 2026-11-27T08:00:00.000Z
43+ updatedAt: 2026-11-27T09:00:00.000Z
44+ closedAt: 2026-11-27T09:00:00.000Z
4245 - id: 2
4346 title: "Decide on a reasoning_color preference; docs EN+FR"
44- state: open
47+ state: closed
4548 priority: low
4649 author:
4750 name: k33g
4851 email: ph.charriere@gmail.com
4952 createdAt: 2026-11-27T08:00:00.000Z
50-comments: []
53+ updatedAt: 2026-11-27T09:00:00.000Z
54+ closedAt: 2026-11-27T09:00:00.000Z
55+comments:
56+ - id: 1
57+ author:
58+ name: k33g
59+ email: ph.charriere@gmail.com
60+ createdAt: 2026-11-27T09:00:00.000Z
61+ body: |
62+ Done on branch feature/v0.3-tui.
63+ - `Style.reasoning` (cyan, ANSI 36, readable on light and dark themes); `ChatRenderer.reasoning` uses it for the shown reasoning lines and the folded line, and so while the reasoning streams too. The answer stays in the default colour, the stats and "(stopped)" dim, errors red. The `⋯` prefix stays, so the reasoning is still distinct without colours (`NO_COLOR`, `colors: false`).
64+ - "⋯ waiting for the model…" stays dim: nothing has come yet, it is not reasoning, and the next piece may be the answer itself.
65+ - Decision (task 2): a fixed colour, no `reasoning_color` preference for now; one can come later, the constant lives in `Style`.
66+ - Tests (ChatRendererTests, moved to their own file to keep DashboardAndChatTests under the length limit): shown and folded lines carry `\u{1B}[36m` and the reset, the answer line does not, streaming reasoning is coloured, `Style(colors: false)` output unchanged. Docs EN+FR `reference/tui.md`, Chat.
@@ -1,12 +1,13 @@
1 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.1 # Managed by IssueSpec. Hand edits are welcome; keep the schema valid.
2 id: 632 id: 63
3 title: "TUI chat: show the reasoning in a colour of its own"3 title: "TUI chat: show the reasoning in a colour of its own"
4-state: open4+state: closed
5 author:5 author:
6 name: k33g6 name: k33g
7 email: ph.charriere@gmail.com7 email: ph.charriere@gmail.com
8 createdAt: 2026-11-27T08:00:00.000Z8 createdAt: 2026-11-27T08:00:00.000Z
9-updatedAt: 2026-11-27T08:00:00.000Z9+updatedAt: 2026-11-27T09:00:00.000Z
10+closedAt: 2026-11-27T09:00:00.000Z
10 labels:11 labels:
11 - "kind::feature"12 - "kind::feature"
12 - "area::tui"13 - "area::tui"
@@ -33,18 +34,33 @@ body: |
33 tasks:34 tasks:
34 - id: 135 - id: 1
35 title: "Reasoning colour in Style and ChatRenderer (shown, folded, streaming), tests"36 title: "Reasoning colour in Style and ChatRenderer (shown, folded, streaming), tests"
36- state: open37+ state: closed
37 priority: medium38 priority: medium
38 author:39 author:
39 name: k33g40 name: k33g
40 email: ph.charriere@gmail.com41 email: ph.charriere@gmail.com
41 createdAt: 2026-11-27T08:00:00.000Z42 createdAt: 2026-11-27T08:00:00.000Z
43+ updatedAt: 2026-11-27T09:00:00.000Z
44+ closedAt: 2026-11-27T09:00:00.000Z
42 - id: 245 - id: 2
43 title: "Decide on a reasoning_color preference; docs EN+FR"46 title: "Decide on a reasoning_color preference; docs EN+FR"
44- state: open47+ state: closed
45 priority: low48 priority: low
46 author:49 author:
47 name: k33g50 name: k33g
48 email: ph.charriere@gmail.com51 email: ph.charriere@gmail.com
49 createdAt: 2026-11-27T08:00:00.000Z52 createdAt: 2026-11-27T08:00:00.000Z
50-comments: []53+ updatedAt: 2026-11-27T09:00:00.000Z
54+ closedAt: 2026-11-27T09:00:00.000Z
55+comments:
56+ - id: 1
57+ author:
58+ name: k33g
59+ email: ph.charriere@gmail.com
60+ createdAt: 2026-11-27T09:00:00.000Z
61+ body: |
62+ Done on branch feature/v0.3-tui.
63+ - `Style.reasoning` (cyan, ANSI 36, readable on light and dark themes); `ChatRenderer.reasoning` uses it for the shown reasoning lines and the folded line, and so while the reasoning streams too. The answer stays in the default colour, the stats and "(stopped)" dim, errors red. The `⋯` prefix stays, so the reasoning is still distinct without colours (`NO_COLOR`, `colors: false`).
64+ - "⋯ waiting for the model…" stays dim: nothing has come yet, it is not reasoning, and the next piece may be the answer itself.
65+ - Decision (task 2): a fixed colour, no `reasoning_color` preference for now; one can come later, the constant lives in `Style`.
66+ - Tests (ChatRendererTests, moved to their own file to keep DashboardAndChatTests under the length limit): shown and folded lines carry `\u{1B}[36m` and the reset, the answer line does not, streaming reasoning is coloured, `Style(colors: false)` output unchanged. Docs EN+FR `reference/tui.md`, Chat.
modified Sources/RazorbillTUI/ChatRenderer.swift +4 -2
@@ -81,15 +81,17 @@ public struct ChatRenderer: Sendable {
8181 return lines
8282 }
8383
84+ /// Reasoning in its own colour (`Style.reasoning`), shown, folded or streaming alike; the
85+ /// `⋯` prefix keeps it apart from the answer when colours are off.
8486 func reasoning(_ text: String, display: ChatScreen.ReasoningDisplay, width: Int) -> [String] {
8587 switch display {
8688 case .hidden:
8789 return []
8890 case .folded:
8991 let words = text.split(whereSeparator: \.isWhitespace).count
90- return [style.dim(" ⋯ thinking (\(words) words) · Ctrl-R to show")]
92+ return [style.reasoning(" ⋯ thinking (\(words) words) · Ctrl-R to show")]
9193 case .shown:
92- return TextLayout.wrap(text, width: width - 4).map { style.dim(" ⋯ " + $0) }
94+ return TextLayout.wrap(text, width: width - 4).map { style.reasoning(" ⋯ " + $0) }
9395 }
9496 }
9597
@@ -81,15 +81,17 @@ public struct ChatRenderer: Sendable {
81 return lines81 return lines
82 }82 }
83 83
84+ /// Reasoning in its own colour (`Style.reasoning`), shown, folded or streaming alike; the
85+ /// `⋯` prefix keeps it apart from the answer when colours are off.
84 func reasoning(_ text: String, display: ChatScreen.ReasoningDisplay, width: Int) -> [String] {86 func reasoning(_ text: String, display: ChatScreen.ReasoningDisplay, width: Int) -> [String] {
85 switch display {87 switch display {
86 case .hidden:88 case .hidden:
87 return []89 return []
88 case .folded:90 case .folded:
89 let words = text.split(whereSeparator: \.isWhitespace).count91 let words = text.split(whereSeparator: \.isWhitespace).count
90- return [style.dim(" ⋯ thinking (\(words) words) · Ctrl-R to show")]92+ return [style.reasoning(" ⋯ thinking (\(words) words) · Ctrl-R to show")]
91 case .shown:93 case .shown:
92- return TextLayout.wrap(text, width: width - 4).map { style.dim(" ⋯ " + $0) }94+ return TextLayout.wrap(text, width: width - 4).map { style.reasoning(" ⋯ " + $0) }
93 }95 }
94 }96 }
95 97
modified Sources/RazorbillTUI/Style.swift +8 -0
@@ -19,6 +19,14 @@ public struct Style: Sendable, Equatable {
1919 public func green(_ text: String) -> String { wrap(text, "32") }
2020 public func red(_ text: String) -> String { wrap(text, "31") }
2121 public func yellow(_ text: String) -> String { wrap(text, "33") }
22+ /// The model's reasoning in the Chat screen: cyan (ANSI 36), so it cannot be taken for
23+ /// the answer (default colour) or the stats (dim), and stays readable on light and dark
24+ /// themes. A fixed colour for now; a `reasoning_color` preference could come later.
25+ ///
26+ /// ```swift
27+ /// Style(colors: true).reasoning(" ⋯ hmm") // "\u{1B}[36m ⋯ hmm\u{1B}[0m"
28+ /// ```
29+ public func reasoning(_ text: String) -> String { wrap(text, "36") }
2230
2331 private func wrap(_ text: String, _ code: String) -> String {
2432 colors ? "\u{1B}[\(code)m\(text)\u{1B}[0m" : text
@@ -19,6 +19,14 @@ public struct Style: Sendable, Equatable {
19 public func green(_ text: String) -> String { wrap(text, "32") }19 public func green(_ text: String) -> String { wrap(text, "32") }
20 public func red(_ text: String) -> String { wrap(text, "31") }20 public func red(_ text: String) -> String { wrap(text, "31") }
21 public func yellow(_ text: String) -> String { wrap(text, "33") }21 public func yellow(_ text: String) -> String { wrap(text, "33") }
22+ /// The model's reasoning in the Chat screen: cyan (ANSI 36), so it cannot be taken for
23+ /// the answer (default colour) or the stats (dim), and stays readable on light and dark
24+ /// themes. A fixed colour for now; a `reasoning_color` preference could come later.
25+ ///
26+ /// ```swift
27+ /// Style(colors: true).reasoning(" ⋯ hmm") // "\u{1B}[36m ⋯ hmm\u{1B}[0m"
28+ /// ```
29+ public func reasoning(_ text: String) -> String { wrap(text, "36") }
22 30
23 private func wrap(_ text: String, _ code: String) -> String {31 private func wrap(_ text: String, _ code: String) -> String {
24 colors ? "\u{1B}[\(code)m\(text)\u{1B}[0m" : text32 colors ? "\u{1B}[\(code)m\(text)\u{1B}[0m" : text
added Tests/RazorbillTUITests/ChatRendererTests.swift +113 -0
new file mode 100644
@@ -0,0 +1,113 @@
1+import Testing
2+
3+@testable import RazorbillTUI
4+
5+@Suite struct ChatRendererTests {
6+ let renderer = ChatRenderer(style: plain)
7+
8+ func answered(reasoning display: Int = 0) -> ChatScreen {
9+ var chat = ChatScreen()
10+ chat.setModels(["qwen"])
11+ for character in "hello" { _ = chat.handle(.character(character)) }
12+ _ = chat.handle(.enter)
13+ chat.receive(.reasoning("one two three"))
14+ chat.receive(.content("Hi there"))
15+ chat.finish(generationSeconds: nil)
16+ for _ in 0 ..< display { _ = chat.handle(.control("r")) }
17+ return chat
18+ }
19+
20+ @Test func conversationWithFoldedReasoning() throws {
21+ let (lines, cursor) = renderer.render(answered(), width: 60, height: 10)
22+ #expect(lines.count == 10)
23+ #expect(lines.contains("you › hello"))
24+ #expect(lines.contains(" ⋯ thinking (3 words) · Ctrl-R to show"))
25+ let name = try #require(lines.firstIndex(of: "qwen"))
26+ #expect(lines[name + 2] == "Hi there")
27+ #expect(lines[9] == "› " && cursor.row == 9 && cursor.column == 2)
28+ #expect(lines[8].contains("Enter send"))
29+ }
30+
31+ @Test func hiddenAndShownReasoning() {
32+ let hidden = renderer.render(answered(reasoning: 1), width: 60, height: 10).lines
33+ #expect(!hidden.contains { $0.contains("⋯") })
34+ let shown = renderer.render(answered(reasoning: 2), width: 60, height: 10).lines
35+ #expect(shown.contains(" ⋯ one two three"))
36+ }
37+
38+ @Test func emptyConversationExplainsWhatToDo() {
39+ let lines = renderer.render(ChatScreen(), width: 80, height: 8).lines
40+ #expect(lines.contains { $0.contains("Type a message") })
41+ #expect(lines.contains { $0.contains("none yet (Ctrl-P)") })
42+ }
43+
44+ @Test func waitingLineWhileTheFirstPieceIsAwaited() {
45+ var chat = ChatScreen()
46+ chat.setModels(["qwen"])
47+ _ = chat.handle(.character("x"))
48+ _ = chat.handle(.enter)
49+ let lines = renderer.render(chat, width: 60, height: 8).lines
50+ #expect(lines.contains(" ⋯ waiting for the model…"))
51+ #expect(lines[6].contains("Esc stop"))
52+ }
53+
54+ @Test func reasoningHasAColourOfItsOwn() {
55+ let colour = ChatRenderer(style: Style(colors: true))
56+ let cyan = "\u{1B}[36m"
57+ let reset = "\u{1B}[0m"
58+ let shown = colour.render(answered(reasoning: 2), width: 60, height: 10).lines
59+ #expect(shown.contains(cyan + " ⋯ one two three" + reset))
60+ let folded = colour.render(answered(), width: 60, height: 10).lines
61+ #expect(folded.contains(cyan + " ⋯ thinking (3 words) · Ctrl-R to show" + reset))
62+ #expect(shown.contains("Hi there"))
63+ #expect(!shown.contains { $0.contains("Hi there") && $0.contains(cyan) })
64+ }
65+
66+ @Test func reasoningColourWhileItStreams() {
67+ var chat = ChatScreen()
68+ chat.setModels(["qwen"])
69+ _ = chat.handle(.character("x"))
70+ _ = chat.handle(.enter)
71+ chat.receive(.reasoning("pondering"))
72+ for _ in 0 ..< 2 { _ = chat.handle(.control("r")) }
73+ let lines = ChatRenderer(style: Style(colors: true)).render(chat, width: 60, height: 8)
74+ #expect(lines.lines.contains("\u{1B}[36m ⋯ pondering\u{1B}[0m"))
75+ }
76+
77+ @Test func styleReasoningIsPlainWithoutColours() {
78+ #expect(plain.reasoning(" ⋯ x") == " ⋯ x")
79+ #expect(Style(colors: true).reasoning("x") == "\u{1B}[36mx\u{1B}[0m")
80+ }
81+
82+ @Test func longModelIdsDoNotShiftTheAnswer() {
83+ var chat = ChatScreen()
84+ chat.setModels(["mlx-community/Qwen3-4B-4bit"])
85+ _ = chat.handle(.character("x"))
86+ _ = chat.handle(.enter)
87+ chat.receive(.content(String(repeating: "word ", count: 12)))
88+ chat.finish(generationSeconds: nil)
89+ let lines = renderer.render(chat, width: 30, height: 12).lines
90+ let name = lines.firstIndex(of: "mlx-community/Qwen3-4B-4bit")
91+ #expect(name != nil)
92+ #expect(lines[(name ?? 0) + 1].hasPrefix("word word word word word"))
93+ }
94+
95+ @Test func longInputShowsItsEnd() {
96+ var chat = ChatScreen()
97+ for character in String(repeating: "a", count: 50) + "XYZ" {
98+ _ = chat.handle(.character(character))
99+ }
100+ let (lines, cursor) = renderer.render(chat, width: 20, height: 4)
101+ #expect(lines[3].hasSuffix("XYZ") && lines[3].count <= 20)
102+ #expect(cursor.column == lines[3].count)
103+ }
104+
105+ @Test func pickerListsTheModels() {
106+ var chat = ChatScreen()
107+ chat.setModels(["a", "b"])
108+ _ = chat.handle(.control("p"))
109+ let lines = renderer.render(chat, width: 60, height: 8).lines
110+ #expect(lines.contains { $0.contains("Choose a model") })
111+ #expect(lines.contains { $0.contains("a (current)") })
112+ }
113+}
new file mode 100644
@@ -0,0 +1,113 @@
1+import Testing
2+
3+@testable import RazorbillTUI
4+
5+@Suite struct ChatRendererTests {
6+ let renderer = ChatRenderer(style: plain)
7+
8+ func answered(reasoning display: Int = 0) -> ChatScreen {
9+ var chat = ChatScreen()
10+ chat.setModels(["qwen"])
11+ for character in "hello" { _ = chat.handle(.character(character)) }
12+ _ = chat.handle(.enter)
13+ chat.receive(.reasoning("one two three"))
14+ chat.receive(.content("Hi there"))
15+ chat.finish(generationSeconds: nil)
16+ for _ in 0 ..< display { _ = chat.handle(.control("r")) }
17+ return chat
18+ }
19+
20+ @Test func conversationWithFoldedReasoning() throws {
21+ let (lines, cursor) = renderer.render(answered(), width: 60, height: 10)
22+ #expect(lines.count == 10)
23+ #expect(lines.contains("you › hello"))
24+ #expect(lines.contains(" ⋯ thinking (3 words) · Ctrl-R to show"))
25+ let name = try #require(lines.firstIndex(of: "qwen"))
26+ #expect(lines[name + 2] == "Hi there")
27+ #expect(lines[9] == "› " && cursor.row == 9 && cursor.column == 2)
28+ #expect(lines[8].contains("Enter send"))
29+ }
30+
31+ @Test func hiddenAndShownReasoning() {
32+ let hidden = renderer.render(answered(reasoning: 1), width: 60, height: 10).lines
33+ #expect(!hidden.contains { $0.contains("⋯") })
34+ let shown = renderer.render(answered(reasoning: 2), width: 60, height: 10).lines
35+ #expect(shown.contains(" ⋯ one two three"))
36+ }
37+
38+ @Test func emptyConversationExplainsWhatToDo() {
39+ let lines = renderer.render(ChatScreen(), width: 80, height: 8).lines
40+ #expect(lines.contains { $0.contains("Type a message") })
41+ #expect(lines.contains { $0.contains("none yet (Ctrl-P)") })
42+ }
43+
44+ @Test func waitingLineWhileTheFirstPieceIsAwaited() {
45+ var chat = ChatScreen()
46+ chat.setModels(["qwen"])
47+ _ = chat.handle(.character("x"))
48+ _ = chat.handle(.enter)
49+ let lines = renderer.render(chat, width: 60, height: 8).lines
50+ #expect(lines.contains(" ⋯ waiting for the model…"))
51+ #expect(lines[6].contains("Esc stop"))
52+ }
53+
54+ @Test func reasoningHasAColourOfItsOwn() {
55+ let colour = ChatRenderer(style: Style(colors: true))
56+ let cyan = "\u{1B}[36m"
57+ let reset = "\u{1B}[0m"
58+ let shown = colour.render(answered(reasoning: 2), width: 60, height: 10).lines
59+ #expect(shown.contains(cyan + " ⋯ one two three" + reset))
60+ let folded = colour.render(answered(), width: 60, height: 10).lines
61+ #expect(folded.contains(cyan + " ⋯ thinking (3 words) · Ctrl-R to show" + reset))
62+ #expect(shown.contains("Hi there"))
63+ #expect(!shown.contains { $0.contains("Hi there") && $0.contains(cyan) })
64+ }
65+
66+ @Test func reasoningColourWhileItStreams() {
67+ var chat = ChatScreen()
68+ chat.setModels(["qwen"])
69+ _ = chat.handle(.character("x"))
70+ _ = chat.handle(.enter)
71+ chat.receive(.reasoning("pondering"))
72+ for _ in 0 ..< 2 { _ = chat.handle(.control("r")) }
73+ let lines = ChatRenderer(style: Style(colors: true)).render(chat, width: 60, height: 8)
74+ #expect(lines.lines.contains("\u{1B}[36m ⋯ pondering\u{1B}[0m"))
75+ }
76+
77+ @Test func styleReasoningIsPlainWithoutColours() {
78+ #expect(plain.reasoning(" ⋯ x") == " ⋯ x")
79+ #expect(Style(colors: true).reasoning("x") == "\u{1B}[36mx\u{1B}[0m")
80+ }
81+
82+ @Test func longModelIdsDoNotShiftTheAnswer() {
83+ var chat = ChatScreen()
84+ chat.setModels(["mlx-community/Qwen3-4B-4bit"])
85+ _ = chat.handle(.character("x"))
86+ _ = chat.handle(.enter)
87+ chat.receive(.content(String(repeating: "word ", count: 12)))
88+ chat.finish(generationSeconds: nil)
89+ let lines = renderer.render(chat, width: 30, height: 12).lines
90+ let name = lines.firstIndex(of: "mlx-community/Qwen3-4B-4bit")
91+ #expect(name != nil)
92+ #expect(lines[(name ?? 0) + 1].hasPrefix("word word word word word"))
93+ }
94+
95+ @Test func longInputShowsItsEnd() {
96+ var chat = ChatScreen()
97+ for character in String(repeating: "a", count: 50) + "XYZ" {
98+ _ = chat.handle(.character(character))
99+ }
100+ let (lines, cursor) = renderer.render(chat, width: 20, height: 4)
101+ #expect(lines[3].hasSuffix("XYZ") && lines[3].count <= 20)
102+ #expect(cursor.column == lines[3].count)
103+ }
104+
105+ @Test func pickerListsTheModels() {
106+ var chat = ChatScreen()
107+ chat.setModels(["a", "b"])
108+ _ = chat.handle(.control("p"))
109+ let lines = renderer.render(chat, width: 60, height: 8).lines
110+ #expect(lines.contains { $0.contains("Choose a model") })
111+ #expect(lines.contains { $0.contains("a (current)") })
112+ }
113+}
modified Tests/RazorbillTUITests/DashboardAndChatTests.swift +0 -82
@@ -246,88 +246,6 @@ let plain = Style(colors: false)
246246 }
247247 }
248248
249-@Suite struct ChatRendererTests {
250- let renderer = ChatRenderer(style: plain)
251-
252- func answered(reasoning display: Int = 0) -> ChatScreen {
253- var chat = ChatScreen()
254- chat.setModels(["qwen"])
255- for character in "hello" { _ = chat.handle(.character(character)) }
256- _ = chat.handle(.enter)
257- chat.receive(.reasoning("one two three"))
258- chat.receive(.content("Hi there"))
259- chat.finish(generationSeconds: nil)
260- for _ in 0 ..< display { _ = chat.handle(.control("r")) }
261- return chat
262- }
263-
264- @Test func conversationWithFoldedReasoning() throws {
265- let (lines, cursor) = renderer.render(answered(), width: 60, height: 10)
266- #expect(lines.count == 10)
267- #expect(lines.contains("you › hello"))
268- #expect(lines.contains(" ⋯ thinking (3 words) · Ctrl-R to show"))
269- let name = try #require(lines.firstIndex(of: "qwen"))
270- #expect(lines[name + 2] == "Hi there")
271- #expect(lines[9] == "› " && cursor.row == 9 && cursor.column == 2)
272- #expect(lines[8].contains("Enter send"))
273- }
274-
275- @Test func hiddenAndShownReasoning() {
276- let hidden = renderer.render(answered(reasoning: 1), width: 60, height: 10).lines
277- #expect(!hidden.contains { $0.contains("⋯") })
278- let shown = renderer.render(answered(reasoning: 2), width: 60, height: 10).lines
279- #expect(shown.contains(" ⋯ one two three"))
280- }
281-
282- @Test func emptyConversationExplainsWhatToDo() {
283- let lines = renderer.render(ChatScreen(), width: 80, height: 8).lines
284- #expect(lines.contains { $0.contains("Type a message") })
285- #expect(lines.contains { $0.contains("none yet (Ctrl-P)") })
286- }
287-
288- @Test func waitingLineWhileTheFirstPieceIsAwaited() {
289- var chat = ChatScreen()
290- chat.setModels(["qwen"])
291- _ = chat.handle(.character("x"))
292- _ = chat.handle(.enter)
293- let lines = renderer.render(chat, width: 60, height: 8).lines
294- #expect(lines.contains(" ⋯ waiting for the model…"))
295- #expect(lines[6].contains("Esc stop"))
296- }
297-
298- @Test func longModelIdsDoNotShiftTheAnswer() {
299- var chat = ChatScreen()
300- chat.setModels(["mlx-community/Qwen3-4B-4bit"])
301- _ = chat.handle(.character("x"))
302- _ = chat.handle(.enter)
303- chat.receive(.content(String(repeating: "word ", count: 12)))
304- chat.finish(generationSeconds: nil)
305- let lines = renderer.render(chat, width: 30, height: 12).lines
306- let name = lines.firstIndex(of: "mlx-community/Qwen3-4B-4bit")
307- #expect(name != nil)
308- #expect(lines[(name ?? 0) + 1].hasPrefix("word word word word word"))
309- }
310-
311- @Test func longInputShowsItsEnd() {
312- var chat = ChatScreen()
313- for character in String(repeating: "a", count: 50) + "XYZ" {
314- _ = chat.handle(.character(character))
315- }
316- let (lines, cursor) = renderer.render(chat, width: 20, height: 4)
317- #expect(lines[3].hasSuffix("XYZ") && lines[3].count <= 20)
318- #expect(cursor.column == lines[3].count)
319- }
320-
321- @Test func pickerListsTheModels() {
322- var chat = ChatScreen()
323- chat.setModels(["a", "b"])
324- _ = chat.handle(.control("p"))
325- let lines = renderer.render(chat, width: 60, height: 8).lines
326- #expect(lines.contains { $0.contains("Choose a model") })
327- #expect(lines.contains { $0.contains("a (current)") })
328- }
329-}
330-
331249 @Suite struct TUIAppScreensTests {
332250 func app(_ terminal: FakeTerminal, _ server: ScriptedServer) -> TUIApp {
333251 TUIApp(
@@ -246,88 +246,6 @@ let plain = Style(colors: false)
246 }246 }
247 }247 }
248 248
249-@Suite struct ChatRendererTests {
250- let renderer = ChatRenderer(style: plain)
251-
252- func answered(reasoning display: Int = 0) -> ChatScreen {
253- var chat = ChatScreen()
254- chat.setModels(["qwen"])
255- for character in "hello" { _ = chat.handle(.character(character)) }
256- _ = chat.handle(.enter)
257- chat.receive(.reasoning("one two three"))
258- chat.receive(.content("Hi there"))
259- chat.finish(generationSeconds: nil)
260- for _ in 0 ..< display { _ = chat.handle(.control("r")) }
261- return chat
262- }
263-
264- @Test func conversationWithFoldedReasoning() throws {
265- let (lines, cursor) = renderer.render(answered(), width: 60, height: 10)
266- #expect(lines.count == 10)
267- #expect(lines.contains("you › hello"))
268- #expect(lines.contains(" ⋯ thinking (3 words) · Ctrl-R to show"))
269- let name = try #require(lines.firstIndex(of: "qwen"))
270- #expect(lines[name + 2] == "Hi there")
271- #expect(lines[9] == "› " && cursor.row == 9 && cursor.column == 2)
272- #expect(lines[8].contains("Enter send"))
273- }
274-
275- @Test func hiddenAndShownReasoning() {
276- let hidden = renderer.render(answered(reasoning: 1), width: 60, height: 10).lines
277- #expect(!hidden.contains { $0.contains("⋯") })
278- let shown = renderer.render(answered(reasoning: 2), width: 60, height: 10).lines
279- #expect(shown.contains(" ⋯ one two three"))
280- }
281-
282- @Test func emptyConversationExplainsWhatToDo() {
283- let lines = renderer.render(ChatScreen(), width: 80, height: 8).lines
284- #expect(lines.contains { $0.contains("Type a message") })
285- #expect(lines.contains { $0.contains("none yet (Ctrl-P)") })
286- }
287-
288- @Test func waitingLineWhileTheFirstPieceIsAwaited() {
289- var chat = ChatScreen()
290- chat.setModels(["qwen"])
291- _ = chat.handle(.character("x"))
292- _ = chat.handle(.enter)
293- let lines = renderer.render(chat, width: 60, height: 8).lines
294- #expect(lines.contains(" ⋯ waiting for the model…"))
295- #expect(lines[6].contains("Esc stop"))
296- }
297-
298- @Test func longModelIdsDoNotShiftTheAnswer() {
299- var chat = ChatScreen()
300- chat.setModels(["mlx-community/Qwen3-4B-4bit"])
301- _ = chat.handle(.character("x"))
302- _ = chat.handle(.enter)
303- chat.receive(.content(String(repeating: "word ", count: 12)))
304- chat.finish(generationSeconds: nil)
305- let lines = renderer.render(chat, width: 30, height: 12).lines
306- let name = lines.firstIndex(of: "mlx-community/Qwen3-4B-4bit")
307- #expect(name != nil)
308- #expect(lines[(name ?? 0) + 1].hasPrefix("word word word word word"))
309- }
310-
311- @Test func longInputShowsItsEnd() {
312- var chat = ChatScreen()
313- for character in String(repeating: "a", count: 50) + "XYZ" {
314- _ = chat.handle(.character(character))
315- }
316- let (lines, cursor) = renderer.render(chat, width: 20, height: 4)
317- #expect(lines[3].hasSuffix("XYZ") && lines[3].count <= 20)
318- #expect(cursor.column == lines[3].count)
319- }
320-
321- @Test func pickerListsTheModels() {
322- var chat = ChatScreen()
323- chat.setModels(["a", "b"])
324- _ = chat.handle(.control("p"))
325- let lines = renderer.render(chat, width: 60, height: 8).lines
326- #expect(lines.contains { $0.contains("Choose a model") })
327- #expect(lines.contains { $0.contains("a (current)") })
328- }
329-}
330-
331 @Suite struct TUIAppScreensTests {249 @Suite struct TUIAppScreensTests {
332 func app(_ terminal: FakeTerminal, _ server: ScriptedServer) -> TUIApp {250 func app(_ terminal: FakeTerminal, _ server: ScriptedServer) -> TUIApp {
333 TUIApp(251 TUIApp(
modified docs/en/reference/tui.md +2 -0
@@ -54,6 +54,8 @@ The server's version, uptime and address; the engine's memory as a gauge of acti
5454
5555 A streamed conversation with a chat model of the server. Each answer starts with the model's name on a line of its own; the answer follows at the full width. The conversation is kept by `rzb tui` and resent whole with each message; the server's prompt cache makes that cheap. The model is the first loaded chat model of `/v1/models`, else the first chat model listed. After each answer: prompt+completion tokens, cached prompt tokens, tokens per second from the first piece to the last.
5656
57+The reasoning of an answer (shown, or folded into its one line) is drawn in cyan, while it streams too, so it cannot be taken for the answer (default colour), the stats (dim) or an error (red). Each of its lines starts with `⋯`, which keeps it apart from the answer without colours (`NO_COLOR`, colours off in the preferences).
58+
5759 | Key | Effect |
5860 | --- | --- |
5961 | `Enter` | Send the message, or run a command |
@@ -54,6 +54,8 @@ The server's version, uptime and address; the engine's memory as a gauge of acti
54 54
55 A streamed conversation with a chat model of the server. Each answer starts with the model's name on a line of its own; the answer follows at the full width. The conversation is kept by `rzb tui` and resent whole with each message; the server's prompt cache makes that cheap. The model is the first loaded chat model of `/v1/models`, else the first chat model listed. After each answer: prompt+completion tokens, cached prompt tokens, tokens per second from the first piece to the last.55 A streamed conversation with a chat model of the server. Each answer starts with the model's name on a line of its own; the answer follows at the full width. The conversation is kept by `rzb tui` and resent whole with each message; the server's prompt cache makes that cheap. The model is the first loaded chat model of `/v1/models`, else the first chat model listed. After each answer: prompt+completion tokens, cached prompt tokens, tokens per second from the first piece to the last.
56 56
57+The reasoning of an answer (shown, or folded into its one line) is drawn in cyan, while it streams too, so it cannot be taken for the answer (default colour), the stats (dim) or an error (red). Each of its lines starts with `⋯`, which keeps it apart from the answer without colours (`NO_COLOR`, colours off in the preferences).
58+
57 | Key | Effect |59 | Key | Effect |
58 | --- | --- |60 | --- | --- |
59 | `Enter` | Send the message, or run a command |61 | `Enter` | Send the message, or run a command |
modified docs/fr/reference/tui.md +2 -0
@@ -54,6 +54,8 @@ La version, la durée de fonctionnement et l'adresse du serveur ; la mémoire du
5454
5555 Une conversation en flux avec un modèle de chat du serveur. Chaque réponse commence par le nom du modèle sur une ligne à lui ; la réponse suit sur toute la largeur. La conversation est gardée par `rzb tui` et renvoyée entière à chaque message ; le cache de prompt du serveur rend cela peu coûteux. Le modèle est le premier modèle de chat chargé de `/v1/models`, sinon le premier modèle de chat listé. Après chaque réponse : tokens prompt+complétion, tokens du prompt repris du cache, tokens par seconde du premier morceau au dernier.
5656
57+Le raisonnement d'une réponse (affiché, ou replié sur sa ligne unique) s'écrit en cyan, y compris pendant qu'il arrive, pour qu'on ne le confonde ni avec la réponse (couleur par défaut), ni avec les statistiques (atténuées), ni avec une erreur (rouge). Chacune de ses lignes commence par `⋯`, ce qui le distingue de la réponse même sans couleurs (`NO_COLOR`, couleurs désactivées dans les préférences).
58+
5759 | Touche | Effet |
5860 | --- | --- |
5961 | `Entrée` | Envoyer le message, ou lancer une commande |
@@ -54,6 +54,8 @@ La version, la durée de fonctionnement et l'adresse du serveur ; la mémoire du
54 54
55 Une conversation en flux avec un modèle de chat du serveur. Chaque réponse commence par le nom du modèle sur une ligne à lui ; la réponse suit sur toute la largeur. La conversation est gardée par `rzb tui` et renvoyée entière à chaque message ; le cache de prompt du serveur rend cela peu coûteux. Le modèle est le premier modèle de chat chargé de `/v1/models`, sinon le premier modèle de chat listé. Après chaque réponse : tokens prompt+complétion, tokens du prompt repris du cache, tokens par seconde du premier morceau au dernier.55 Une conversation en flux avec un modèle de chat du serveur. Chaque réponse commence par le nom du modèle sur une ligne à lui ; la réponse suit sur toute la largeur. La conversation est gardée par `rzb tui` et renvoyée entière à chaque message ; le cache de prompt du serveur rend cela peu coûteux. Le modèle est le premier modèle de chat chargé de `/v1/models`, sinon le premier modèle de chat listé. Après chaque réponse : tokens prompt+complétion, tokens du prompt repris du cache, tokens par seconde du premier morceau au dernier.
56 56
57+Le raisonnement d'une réponse (affiché, ou replié sur sa ligne unique) s'écrit en cyan, y compris pendant qu'il arrive, pour qu'on ne le confonde ni avec la réponse (couleur par défaut), ni avec les statistiques (atténuées), ni avec une erreur (rouge). Chacune de ses lignes commence par `⋯`, ce qui le distingue de la réponse même sans couleurs (`NO_COLOR`, couleurs désactivées dans les préférences).
58+
57 | Touche | Effet |59 | Touche | Effet |
58 | --- | --- |60 | --- | --- |
59 | `Entrée` | Envoyer le message, ou lancer une commande |61 | `Entrée` | Envoyer le message, ou lancer une commande |