Skip to content

feat(say): automatically merge compatible recent messages - #42

Merged
lizheming merged 2 commits into
mainfrom
codex/say-auto-merge
Nov 26, 2026
Merged

lizheming merged 2 commits into
mainfrom
codex/say-auto-merge

Conversation

@lizheming

@lizheming lizheming commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Add an admin-configurable automatic merge window (default 10 seconds, 0 disables, maximum 86400). The shared creation path checks the latest Say and applies existing merge rules, preserving its ID and original creation time. Publishing feedback reports the merged ID.

Require matching author, source, visibility and comment settings. Skip commented entries, unsupported combinations and merges exceeding 20 images.

Automatic merges use a database conditional UPDATE against the original content and state snapshot. If another request changes that snapshot, publish the incoming message as a separate entry instead of overwriting the winning update. Do not rely solely on second-resolution timestamps or process-local locks.

Validation: Say suite 164 passed, 2 optional tests skipped; git diff --check passed. Regression tests cover simultaneous images through one service and independent service instances sharing storage, verifying that all acknowledged content remains stored. Other tests cover the merge window and eligibility guards. Tests use the model fixture; real database concurrency and production channel delivery have not been exercised.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T15:49:26.427901Z 4e21604 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e21604e2d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/say/lib/say-service.js Outdated
Comment on lines +286 to +288
if (merged && (merged.images || []).length <= 20) {
const item = await this.update(latest.id, merged);
return {...item, autoMerged: true};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Make automatic merges atomic to prevent lost publications

When two compatible publications arrive concurrently within the merge window, both can read the same latest entry and compute independent replacements; the second update() then overwrites the first publication's content. This also occurs within a single process, not just across instances: using the service test fixture, creating a caption followed by two image publications through Promise.all() reports both as successfully merged into #1, but persists only the second image. The API route and distinct QQ messages can invoke this path concurrently. Protect the read/merge/write operation with database concurrency control, retrying against the current entry or creating a separate entry on conflict, so acknowledged publications are not silently lost.

Useful? React with 👍 / 👎.

@lizheming
lizheming merged commit 7101620 into main Nov 26, 2026
1 check passed
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.

1 participant