Commit 7bee442
fix(#129): mark m[0]/m[1] history prepends synthetic so they don't suppress titles
OpenCode's auto-title generation (SessionPrompt.ensureTitle) only titles a
session when EXACTLY ONE "real" user message exists, where real =
`role === "user" && !parts.every(p => p.synthetic)` — it does NOT check
`ignored`. Magic Context injects its history blocks by prepending two
`role: "user"` messages (m[0] cumulative baseline + m[1] delta) on every
transform — including a brand-new session's first turn, where m[0] is an empty
placeholder and m[1] is minimal. Those parts had no `synthetic` flag, so a fresh
first turn presented THREE real user messages (m0 + m1 + the actual prompt) →
`filter(real).length !== 1` → ensureTitle returned without titling, permanently.
Reproduced in clean OpenCode (no custom build) in Docker: MC-enabled fresh
session never titles ("New session - <ISO>"); plugin-disabled titles fine;
disabling auto-search did NOT help (auto-search only appends text, keeping the
count at 1) — isolating the m[0]/m[1] prepend as the cause. The git-vs-non-git
asymmetry the reporter saw is a timing artifact of the title fiber forking with
the shared, about-to-be-transformed `msgs` array.
Fix: mark all three prepend sites' text parts `synthetic: true` (the two v2
m[0]/m[1] blocks + the v1 `<session-history>` fallback). `synthetic` keeps them
in the real model call — OpenCode's `toModelMessagesEffect` filters on `ignored`,
NOT `synthetic`, so history injection is preserved — while excluding them from
the title gate. `ignored: true` would have been wrong: it strips parts from the
model call and would have removed the injected history from the agent's context.
OpenCode-only; Pi has no equivalent title gate.
Verified in Docker before/after: the two previously-failing fresh-session cases
now title correctly. Prior fix afb19b2 (v0.23.0) only guarded notification posts
and never touched this prepend — which is why the issue persisted.
Co-authored-by: Alfonso [Magic Context] <288211368+alfonso-magic-context@users.noreply.github.com>1 parent 51fd299 commit 7bee442
1 file changed
Lines changed: 21 additions & 3 deletions
Lines changed: 21 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
539 | 542 | | |
540 | 543 | | |
541 | | - | |
| 544 | + | |
542 | 545 | | |
543 | 546 | | |
544 | 547 | | |
| |||
2169 | 2172 | | |
2170 | 2173 | | |
2171 | 2174 | | |
| 2175 | + | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
2172 | 2184 | | |
2173 | 2185 | | |
2174 | 2186 | | |
2175 | | - | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
2176 | 2194 | | |
2177 | 2195 | | |
2178 | 2196 | | |
2179 | | - | |
| 2197 | + | |
2180 | 2198 | | |
2181 | 2199 | | |
2182 | 2200 | | |
| |||
0 commit comments