Skip to content

fix: track message.updated for mining#6

Open
fengjikui wants to merge 2 commits into
option-K:mainfrom
fengjikui:codex/track-message-updated-mining
Open

fix: track message.updated for mining#6
fengjikui wants to merge 2 commits into
option-K:mainfrom
fengjikui:codex/track-message-updated-mining

Conversation

@fengjikui

@fengjikui fengjikui commented Jul 8, 2026

Copy link
Copy Markdown

Summary

  • track OpenCode's real message.updated events in the plugin event hook so MemPalace marks active sessions as dirty
  • reuse the same mining path for threshold-triggered mining, idle/deleted/status-idle flushing, and the legacy chat.message compatibility hook
  • update the README hook list to document message.updated as the primary message activity signal

Root cause

OpenCode publishes message activity through the event hook as message.updated, but the plugin only incremented its per-session message counter from a chat.message hook. In the affected flow, relying on chat.message alone left stateManager.hasPendingMessages(sessionID) false on session.idle, so conversation mining was skipped after normal chat activity. Current OpenCode can also emit chat.message and message.updated for the same user message, so the two signals are deduplicated by message ID.

Fixes #4.

Validation

  • Failing-first regression before the fix: npm test -- --runInBand src/index.test.ts -t 'tracks OpenCode message.updated' failed with zero mine() calls
  • npm test -- --runInBand (22 tests)
  • npm run build
  • npm run lint
  • npx prettier --check src/index.ts src/index.test.ts README.md
  • git diff --check
  • npm pack --dry-run --json

@fengjikui

Copy link
Copy Markdown
Author

Self-review against anomalyco/opencode at 7c76bd6 found that the current runtime triggers chat.message and then publishes message.updated for the same user message, while assistant lifecycle updates publish additional message.updated events. Commit 1758a6c now counts only user-message updates and deduplicates the compatibility hook by message ID, using output.message.id when the optional input messageID is absent. Validation: full suite (22 tests), build, lint, Prettier, npm pack dry-run, and git diff --check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: plugin subscribes to 'chat.message' which opencode never publishes — counter never increments, plugin never mines

1 participant