Add pin and unpin actions for user and assistant text messages, with clear compaction-survival labels, localized tooltips, status-info active styling, and VS Code gating where the server runtime is unavailable. Persist pinned message IDs, creation timestamps, and roles under the OpenChamber session metadata namespace using fresh-read merge updates so goal, review, and other metadata remain intact. Introduce a server runtime that reacts to OpenCode's dedicated session.compacted event, fetches pinned messages by ID, extracts and chronologically orders their text parts, and injects them as hidden synthetic context through prompt_async. The restoration prompt tells the agent to use the context silently while work remains and limits idle summaries to one short paragraph. Track the last handled compaction summary to avoid replay duplication, tolerate individually missing pinned messages, integrate runtime shutdown, document ownership and limitations, and cover metadata round trips plus compaction injection behavior with focused tests.
20 lines
1.0 KiB
Markdown
20 lines
1.0 KiB
Markdown
# Context Obligatory Messages
|
|
|
|
Messages explicitly pinned by the user are stored under
|
|
`session.metadata.openchamber.context_obligatory_messages` as `{ id, createdAt,
|
|
role }`. The UI uses a fresh-read metadata merge when pinning or unpinning.
|
|
|
|
The server runtime listens for OpenCode's dedicated `session.compacted` event.
|
|
It fetches every pinned message by ID, keeps non-empty text parts, sorts them
|
|
by the stored creation time, and immediately sends one synthetic user part
|
|
through `prompt_async`. OpenCode's session runner serializes this with its own
|
|
post-compaction continuation. Missing individual messages are skipped without
|
|
discarding the remaining context. Ordinary idle events perform no work and
|
|
make no requests.
|
|
|
|
After a successful send, the runtime merge-writes
|
|
`context_obligatory_last_compaction_message_id`. This cursor prevents a
|
|
replayed compaction event from reinjecting the same summary. The runtime is
|
|
owned by the OpenChamber web backend and therefore is not available in
|
|
extension-only VS Code mode.
|