Repository navigation
Commit e84ec68
committed
Control UI + auto-reply: address upstream review on scaffolding/metadata strip
Five review points across Codex, Copilot, and Greptile on the Control UI
cleanup PR and its TUI symmetry follow-up:
1. Narrow System-event line signature (Codex P1, Copilot P1)
The original per-line sweep stripped any line starting with `System:` or
`System (untrusted):`. Two practical problems:
- `sanitizeInboundSystemTags()` deliberately rewrites a user line-leading
`System:` to `System (untrusted):`, so any legitimate user message
whose first line happens to start with `System:` (pasted logs, exec
output, YAML snippets, notes) was getting silently deleted after
sanitization.
- `stripInboundMetadata` is used beyond Control UI rendering
(`command-detection.ts`, `send-policy.ts`, `chat-sanitize.ts`,
`cli-session-history.merge.ts`, `session-cost-usage.ts`), so
over-stripping here corrupts downstream command detection and
session/cost accounting, not just UI.
Tighten `SYSTEM_EVENT_LINE_RE` to require the bracketed timestamp
marker `[Weekday YYYY-MM-DD HH:MM:SS TZ]` that
`session-system-events.ts` always emits on the first sub-line of each
injected event. User-authored `System:` prefixes without the
timestamp signature stay intact. Continuation sub-lines of a single
injected event may still leak, but that is strictly better than
silently deleting real user input.
2. Narrow internal-instruction prefix matches (Codex P1, Copilot P1)
Replaced `INTERNAL_INSTRUCTION_LINE_PREFIXES` with anchored regexes.
- `Current time: ` was too generic — a user note like
"Current time: I'll be free after lunch" matched. Require the
injected shape `Current time: … / YYYY-MM-DD HH:MM UTC` emitted by
`resolveCronStyleNow`.
- `An async command you ran earlier has completed.` kept, since the
full sentence emitted by `heartbeat-events-filter.ts` is long and
specific enough.
3. Constrain stripLeadingInboundMetadata to leading metadata region
(Codex P1 on commit 5ba2f48)
The TUI formatter uses `stripLeadingInboundMetadata` for `user` and
`command` turns. The previous follow-up applied the System/instruction
filter globally, which silently truncated command transcript bodies
containing `System: …` lines. Move the filter into the leading-metadata
skip loop: drop timestamped System-event and injected-instruction lines
only while we are still in the leading prelude (alongside leading blank
lines); the moment we hit the first real user/command content line,
filtering stops. Added tests for mid-body `System:` preservation.
4. Preserve reasoning-only assistant turns (Codex P2)
Routing grouped assistant text through `processMessageText` stripped
`<think>…</think>` scaffolding before the bubble-visibility check, so
an assistant turn that produced only a reasoning block and no visible
final answer was suppressed by the empty-group guard — the reasoning
panel itself disappeared too. Include `reasoningMarkdown` in the
visibility check in `renderGroupedMessage` and also treat reasoning
content as visible in `groupHasVisibleContent`, so reasoning-only
turns still render with the reasoning panel intact.
5. Use extractTextCached + normalize role (Copilot P2 x2, Greptile P2)
- `renderGroupedMessage` and `groupHasVisibleContent` now read visible
text through `extractTextCached(message)` instead of rebuilding it
from `normalizeMessage(...).content`. `normalizeMessage` drops each
block's `textSignature`, so the rebuilt path lost the assistant
phase contract — `final_answer` preference and commentary-only
suppression — and could re-introduce scaffolding that
`extractTextCached` already handles. Routing both surfaces through
the shared extractor also collapses the duplicated precheck work.
- `processMessageText` and `extractText` now consistently normalise
the role to lowercase before dispatching, so a `role: "Assistant"`
message no longer skips the thinking-tag strip path.
New tests cover:
- User-authored `System:` prefix without timestamp stays intact.
- User-authored `Current time: …` prose without the injected UTC suffix
stays intact.
- Mid-body `System: …` line in TUI command transcript is preserved.1 parent 5ba2f48 commit e84ec68
4 files changed
Lines changed: 128 additions & 65 deletions
File tree
- src/auto-reply/reply
- ui/src/ui/chat
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
251 | 251 | | |
252 | | - | |
253 | | - | |
| 252 | + | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
260 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
261 | 263 | | |
262 | 264 | | |
263 | 265 | | |
| |||
275 | 277 | | |
276 | 278 | | |
277 | 279 | | |
278 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
279 | 296 | | |
280 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
281 | 306 | | |
282 | 307 | | |
283 | 308 | | |
| |||
293 | 318 | | |
294 | 319 | | |
295 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
296 | 331 | | |
297 | 332 | | |
298 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
26 | 34 | | |
27 | | - | |
| 35 | + | |
| 36 | + | |
28 | 37 | | |
29 | 38 | | |
30 | | - | |
31 | | - | |
32 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
33 | 50 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
37 | 54 | | |
38 | 55 | | |
39 | 56 | | |
| |||
56 | 73 | | |
57 | 74 | | |
58 | 75 | | |
59 | | - | |
60 | | - | |
61 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
62 | 81 | | |
63 | 82 | | |
64 | 83 | | |
65 | 84 | | |
66 | | - | |
67 | | - | |
68 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
69 | 89 | | |
70 | 90 | | |
71 | 91 | | |
| |||
81 | 101 | | |
82 | 102 | | |
83 | 103 | | |
84 | | - | |
85 | | - | |
| 104 | + | |
86 | 105 | | |
87 | 106 | | |
88 | 107 | | |
| |||
288 | 307 | | |
289 | 308 | | |
290 | 309 | | |
291 | | - | |
292 | | - | |
293 | | - | |
| 310 | + | |
294 | 311 | | |
295 | 312 | | |
296 | | - | |
297 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
298 | 327 | | |
299 | 328 | | |
300 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
169 | 168 | | |
170 | 169 | | |
171 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
186 | 184 | | |
187 | 185 | | |
188 | 186 | | |
189 | 187 | | |
190 | 188 | | |
| 189 | + | |
191 | 190 | | |
192 | 191 | | |
193 | 192 | | |
| |||
1106 | 1105 | | |
1107 | 1106 | | |
1108 | 1107 | | |
1109 | | - | |
1110 | | - | |
1111 | | - | |
1112 | | - | |
1113 | | - | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
1123 | 1115 | | |
1124 | 1116 | | |
1125 | 1117 | | |
| |||
1142 | 1134 | | |
1143 | 1135 | | |
1144 | 1136 | | |
1145 | | - | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
1146 | 1141 | | |
1147 | 1142 | | |
1148 | 1143 | | |
| 1144 | + | |
1149 | 1145 | | |
1150 | 1146 | | |
1151 | 1147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
0 commit comments