Skip to content

Preserve Codex question and answer history - #46

Merged
milanshen merged 7 commits into
mainfrom
debug/question
Aug 10, 2026
Merged

Preserve Codex question and answer history#46
milanshen merged 7 commits into
mainfrom
debug/question

Conversation

@milanshen

@milanshen milanshen commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Context

Codex input requests can contain multiple questions, with responses recorded separately. coSlash previously retained only the first question and omitted its answer, leaving the session timeline incomplete.

Changes

  • Parse every question in Codex input requests and correlate responses by call and question ID
  • Preserve unanswered questions and combine multi-select responses
  • Display each answer beneath its question in the session timeline

Test

Before: if a session asked 3 questions in a row, only displayed the last question
After: all questions displayed

@milanshen milanshen added the bug Something isn't working label Aug 6, 2026
Comment thread collector/internal/vendors/codex/parse.go Outdated
Comment thread collector/internal/vendors/codex/parse.go Outdated
@calvintvu

calvintvu commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review

This review covers complexity only. It does not cover correctness, security, or performance.

1. The answer travels inside a display string

collector/internal/vendors/codex/parse.go:247 and frontend/src/pages/coslash/components/SessionInspector.tsx:495-497

The Go code joins the question and the answer with a " ↳ " separator. The React code then splits them apart with indexOf and slice. Add Answer string with the tag json:"answer,omitempty" to session.DigestEntry. Set the field on the entry, then render entry.answer. This removes the concatenation and the 3-line split. A question that contains the separator glyph currently splits at the wrong position.

2. A unicode glyph acts as a UI icon

frontend/src/pages/coslash/components/SessionInspector.tsx:506

The line ↳ {answer} uses a glyph as an icon. frontend/CLAUDE.md forbids this. Use a lucide icon (CornerDownRight) or plain indentation.

3. The payload text idiom is duplicated

collector/internal/vendors/codex/parse.go:522-527

questionsFrom reads payload.Arguments first, then falls back to payload.Input. This is the fourth copy of that block. It also reverses the priority that notePlan and commandFrom use. Extract one function, payloadText(p codexPayload) string. Then call it in all three places.

4. The bool return value is derivable

collector/internal/vendors/codex/parse.go:522

questionsFrom returns ([]codexQuestion, bool). Every path that returns a non-empty slice also returns true. Return the slice alone. Then test len(questions) > 0 at the call site.

5. Two decode paths for one format

collector/internal/vendors/codex/parse.go:563-581

questionAnswersFrom decodes Output as a raw value and as a JSON string. spawnedAgentID in the same file already fixes the format: Output is always a JSON-encoded string. Remove the raw path and match spawnedAgentID.

6. A loop rebuilds one map into another

collector/internal/vendors/codex/parse.go:575-580

The loop copies map[string]struct{Answers []string} into map[string][]string. Name the inner struct once, then return result.Answers directly. Index it as answers[id].Answers at the use site.

Total

net: -22 lines possible.

Two notes outside the complexity scope

  • The codex package holds no test file. questionsFrom and questionAnswersFrom each hold four branches. Add one parse_test.go with two cases: one multi-question row with answers, and one malformed payload.
  • CoslashPage.tsx and SessionCard.tsx hold format-only changes. Both are correct. Both are unrelated to this PR.

Comment thread collector/internal/vendors/codex/parse.go
Comment thread collector/internal/vendors/codex/parse.go
@milanshen
milanshen merged commit 68fd958 into main Aug 10, 2026
3 checks passed
@milanshen
milanshen deleted the debug/question branch August 13, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants