Commit 86201a5
feat(chat): Claude-Code-style TUI for
deepagents ships a separate `deepagents-cli` package with a TUI —
streaming, tool-call visibility, slash commands, HITL — but it wraps
a different agent definition and can't host ours. User asked for the
same UX on top of our agent.
Rewrote `thesis chat` end-to-end:
Streaming + inline tool rendering
- Replaced `agent.invoke()` with `agent.stream(stream_mode="values")`.
- Each yielded state delta is diffed against the previous seen count
and new messages are rendered as they arrive.
- `AIMessage` with `tool_calls` → one line per call showing
`→ tool_name(arg_preview)` where the preview prefers file_path /
path / pattern / old_string, truncated at 60 chars.
- `ToolMessage` → indented `↳ <result preview>` (newlines collapsed
to `⏎`, truncated at 120 chars).
- Final `AIMessage` content → `rich.markdown.Markdown` rendered inside
a green Panel titled "agent".
Slash commands (all new)
/help reprint the banner / cheat sheet
/new rotate to a fresh `t-<timestamp>` thread
/thread [id] show current or switch to a specific thread
/status thread + raw/wiki/chapter counts (reads disk, no LLM)
/model table of drafter / curator / researcher active models
/clear clear the terminal (history is preserved in sqlite)
/history [N] acknowledge + point at `data/checkpoints.db`
/quit /exit leave
Multi-line input
- Trailing `\` continues on the next line (prompt changes to `…`)
- Opening triple-backticks ``` enters a fenced paste mode; the block
closes on a standalone ``` line
Control flow
- `KeyboardInterrupt` during generation → "turn cancelled" + loop
continues. Second Ctrl-C at the prompt exits cleanly.
- `--quiet` flag suppresses tool-call traces; only the final assistant
reply is shown in its markdown panel.
Helpers extracted + unit-tested
_preview_tool_args(name, args) - picks the most informative key
and truncates; never raises on
empty args
_preview_tool_result(content) - collapses newlines, truncates,
safe on non-string content
_read_multiline(prompt) - backslash + fenced block handling
_handle_slash(cmd, p, tid) - returns (new_thread_id, keep_running)
_render_new_messages(state, seen,
current_tools) - diff-render helper; returns the
new seen count
Tests
tests/test_chat_tui.py - 18 new tests covering banner, each slash
command, multi-line variants, streaming
tool-call rendering, --quiet mode, and the
four preview helpers.
tests/test_commands.py - updated `_StubAgent` + the inline Flaky
class to implement `.stream()` as well as
`.invoke()` so the existing chat tests
keep working.
Smoke-tested manually: banner, /help, /status, /model, /quit render
correctly under Windows PowerShell with UTF-8 glyphs.
Totals
- 330 passed, 1 skipped (symlink sandbox test on Windows)
- Ruff clean
- No new external dependencies (rich + typer were already in)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>thesis chat
1 parent 891abd8 commit 86201a5
5 files changed
Lines changed: 589 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
991 | 991 | | |
992 | 992 | | |
993 | 993 | | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
994 | 1192 | | |
995 | 1193 | | |
996 | 1194 | | |
997 | 1195 | | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
998 | 1200 | | |
999 | | - | |
1000 | | - | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
1001 | 1209 | | |
1002 | 1210 | | |
1003 | 1211 | | |
1004 | | - | |
1005 | 1212 | | |
1006 | 1213 | | |
1007 | 1214 | | |
1008 | 1215 | | |
1009 | 1216 | | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
| 1217 | + | |
| 1218 | + | |
1017 | 1219 | | |
1018 | 1220 | | |
1019 | 1221 | | |
1020 | 1222 | | |
1021 | | - | |
| 1223 | + | |
1022 | 1224 | | |
1023 | 1225 | | |
1024 | 1226 | | |
1025 | | - | |
| 1227 | + | |
| 1228 | + | |
1026 | 1229 | | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
1034 | 1238 | | |
1035 | 1239 | | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
1036 | 1246 | | |
1037 | | - | |
1038 | | - | |
| 1247 | + | |
1039 | 1248 | | |
1040 | | - | |
1041 | | - | |
1042 | | - | |
1043 | | - | |
1044 | | - | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
1050 | 1269 | | |
1051 | 1270 | | |
| 1271 | + | |
1052 | 1272 | | |
1053 | 1273 | | |
1054 | 1274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
233 | | - | |
234 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
0 commit comments