Skip to content

Commit df76979

Browse files
author
SqlRush
committed
Accept prompt history display aliases
1 parent b7e9f78 commit df76979

4 files changed

Lines changed: 34 additions & 2 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,8 @@ M7 补充:prompt history `LogEntry` 读取现在接受 `sessionID`/`session`/`
474474

475475
本轮补充:prompt history `LogEntry` 读取现在接受 `projectPath`/`cwd`/`workingDirectory`/`workspacePath` 等 project 别名,以及 `createdAt`/`unixTimestamp` 等 timestamp 别名;RFC3339 时间会归一为毫秒时间戳,避免旧 history 因字段名不同被 project/session 过滤漏掉。
476476

477+
本轮补充:prompt history 的显示文本读取现在接受 `prompt`/`text`/`input`/`content`/`value` 等 display 别名,runtime history 和 stored history 都不会因旧字段名把 prompt 恢复成空字符串。
478+
477479
本轮补充:snapshot corpus 支持 `.ansi` only baselines,方便复用真实终端输出 corpus,而不必预先生成 `.txt` companion 文件。
478480

479481
本轮补充:terminal lifecycle 增加可选 extended-key mode,按官方 `CSI >1u`/`CSI >4;2m` 启用 kitty keyboard protocol 和 modifyOtherKeys,退出时重置 modifyOtherKeys 并 pop kitty stack,reassert 时先 pop 再 push,避免长期会话 stack 泄漏。

docs/first-second-parity-audit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ M7 progress now includes:
321321
- `internal/session`: prompt-history `pastedContents`/`pasted_contents` now accepts map, list, and single-object shapes for runtime and stored history, rebuilding maps from content IDs and aliases.
322322
- `internal/session`/`internal/tui`: pasted-content reference parsing now accepts case differences and placeholders such as `pasted image`/`input-image`/`input_text`, sharing that recognition across text expansion, image filtering, and next pasted ID seeding.
323323
- `internal/session`: prompt-history `LogEntry` loading now accepts project aliases such as `projectPath`/`cwd`/`workingDirectory`/`workspacePath` and timestamp aliases such as `createdAt`/`unixTimestamp`, including RFC3339 timestamp normalization to Unix milliseconds.
324+
- `internal/session`: prompt-history display text loading now accepts aliases such as `prompt`/`text`/`input`/`content`/`value` for runtime and stored history.
324325

325326
Still missing for full M6/M7 parity:
326327

internal/session/history_aliases.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func (e *HistoryEntry) UnmarshalJSON(data []byte) error {
323323
return err
324324
}
325325
*e = HistoryEntry{
326-
Display: historyStringJSONField(fields, "display"),
326+
Display: historyStringJSONField(fields, "display", "prompt", "text", "input", "content", "value"),
327327
PastedContents: historyPastedContentsJSONField(fields, "pastedContents", "pasted_contents"),
328328
}
329329
return nil
@@ -335,7 +335,7 @@ func (e *LogEntry) UnmarshalJSON(data []byte) error {
335335
return err
336336
}
337337
*e = LogEntry{
338-
Display: historyStringJSONField(fields, "display"),
338+
Display: historyStringJSONField(fields, "display", "prompt", "text", "input", "content", "value"),
339339
PastedContents: historyStoredPastedContentsJSONField(fields, "pastedContents", "pasted_contents"),
340340
Timestamp: historyTimestampJSONField(fields, "timestamp", "createdAt", "created_at", "time", "unixTimestamp", "unix_timestamp"),
341341
Project: historyStringJSONField(fields, "project", "projectPath", "project_path", "cwd", "cwdPath", "cwd_path", "workingDirectory", "working_directory", "workspacePath", "workspace_path", "workspace"),

internal/session/history_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,35 @@ func TestLoadPromptHistoryAcceptsProjectAndTimestampAliases(t *testing.T) {
186186
}
187187
}
188188

189+
func TestHistoryEntryAcceptsDisplayFieldAliases(t *testing.T) {
190+
var entry HistoryEntry
191+
if err := json.Unmarshal([]byte(`{"prompt":"run [Pasted text #1]","pastedContents":[{"id":1,"type":"text","content":"memo"}]}`), &entry); err != nil {
192+
t.Fatal(err)
193+
}
194+
if entry.Display != "run [Pasted text #1]" || entry.PastedContents[1].Content != "memo" {
195+
t.Fatalf("history entry = %#v", entry)
196+
}
197+
}
198+
199+
func TestLoadPromptHistoryAcceptsDisplayFieldAliases(t *testing.T) {
200+
path := filepath.Join(t.TempDir(), "history.jsonl")
201+
lines := []string{
202+
`{"text":"text alias","pasted_contents":{},"timestamp":100,"project":"/repo","sessionID":"session"}`,
203+
`{"input":"input alias","pasted_contents":{},"timestamp":200,"project":"/repo","sessionID":"other"}`,
204+
}
205+
if err := os.WriteFile(path, []byte(strings.Join(lines, "\n")+"\n"), 0o600); err != nil {
206+
t.Fatal(err)
207+
}
208+
209+
history, err := LoadHistory(path, "/repo", "session", MaxHistoryItems, nil)
210+
if err != nil {
211+
t.Fatal(err)
212+
}
213+
if got := displays(history); strings.Join(got, ",") != "text alias,input alias" {
214+
t.Fatalf("history = %#v", got)
215+
}
216+
}
217+
189218
func TestHistoryEntryAcceptsPastedContentFieldAliases(t *testing.T) {
190219
var entry HistoryEntry
191220
err := json.Unmarshal([]byte(`{"display":"restore [Image #1] [Pasted text #2]","pasted_contents":{"1":{"pastedContentId":"1","kind":"inputImage","base64":"AAAA","mimeType":"image/png","name":"chart.png","path":"/tmp/chart.png","dimensions":{"width":4000,"height":2000}},"2":{"attachmentID":"2","pastedType":"pasted-text","value":"memo","contentType":"text/plain"}}}`), &entry)

0 commit comments

Comments
 (0)