Skip to content

fix(core): /setproject writes to conversation DB id, not platform id#1937

Open
aryrabelo wants to merge 1 commit into
coleam00:devfrom
aryrabelo:fix/setproject-db-id
Open

fix(core): /setproject writes to conversation DB id, not platform id#1937
aryrabelo wants to merge 1 commit into
coleam00:devfrom
aryrabelo:fix/setproject-db-id

Conversation

@aryrabelo

@aryrabelo aryrabelo commented Jun 9, 2026

Copy link
Copy Markdown

Summary

  • Problem: /setproject <name> failed with Error: Conversation not found: <id> on Telegram (and any platform where the conversations-table primary key differs from the platform conversation id).
  • Why it matters: Binding a conversation to a registered codebase is the entry point for multi-project use from chat platforms; the command was unusable outside the web adapter (where DB id happened to equal the platform id).
  • What changed: handleSetProject now passes conversation.id (the DB primary key) to updateConversation instead of the raw platform conversationId. Added a regression test where the DB id differs from the platform conversation id.
  • What did not change (scope boundary): No change to name resolution, the dispatch surface, the reply path (still sent to the platform conversation id), or any other command handler.

UX Journey

Before

User (Telegram)            Archon
────                       ──────
/setproject brainlist ───▶ resolve codebase  -> ok
                           updateConversation(WHERE id = '<telegram-chat-id>')
                           -> 0 rows matched
sees error  ◀───────────── "Error: Conversation not found: <chat-id>"

After

User (Telegram)            Archon
────                       ──────
/setproject brainlist ───▶ resolve codebase  -> ok
                           updateConversation(WHERE id = [conversation.id])  *DB pk*
                           -> 1 row updated
sees success ◀──────────── "Project set to <name> / Working directory: <cwd>"

Architecture Diagram

Before

handleMessage(conversationId=<platform id>, conversation=<row>)
   └─ handleSetProject(message, conversationId)      --x--  [wrong id]
         └─ db.updateConversation(conversationId)  -> WHERE id = <platform id>  (0 rows)

After

handleMessage(conversationId=<platform id>, conversation=<row>)
   └─ handleSetProject(message, conversation.id)     ===    [DB pk]
         └─ db.updateConversation(conversationDbId) -> WHERE id = <DB pk>  (1 row)

Connection inventory:

From To Status Notes
handleMessage handleSetProject modified now passes conversation.id instead of conversationId
handleSetProject db.updateConversation modified keys on DB primary key (matches every other call site)
handleSetProject platform.sendMessage unchanged reply still addressed by platform conversation id

Label Snapshot

  • Risk: risk: low
  • Size: size: XS
  • Scope: core
  • Module: core:orchestrator

Testing

  • Added regression test: DB id (db-hex-id) differs from platform conversation id (40865006); asserts updateConversation is called with the DB id and the reply is addressed to the platform id.
  • bun test orchestrator-agent.test.ts -t setproject → 9 pass, 0 fail.
  • bun run type-check clean; lint 0 errors.
  • Verified end-to-end against a live Telegram bot: /setproject now returns Project set to ....

Notes

No linked issue (bug found during local setup). Happy to file one if preferred.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed /setproject command to use the database conversation identifier when updating conversation records, replacing incorrect platform identifier usage. Corrected message routing to ensure proper delivery.
  • Tests

    • Added regression test for /setproject command to validate database and platform conversation identifier handling.

handleSetProject passed the platform conversation id (Telegram chat id,
GitHub owner/repo#n) straight to updateConversation, which keys on the
conversations-table primary key. On every platform where the DB id differs
from the platform id the UPDATE matched 0 rows and threw
"Conversation not found: <platform-id>", so /setproject never bound the
codebase to the conversation.

Pass conversation.id (the DB primary key) instead, mirroring every other
updateConversation call site in the orchestrator. Add a regression test
where the DB id differs from the platform conversation id.
@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 554e0909-404c-4611-be25-f76334e9ae79

📥 Commits

Reviewing files that changed from the base of the PR and between d72c20c and 0a95124.

📒 Files selected for processing (2)
  • packages/core/src/orchestrator/orchestrator-agent.test.ts
  • packages/core/src/orchestrator/orchestrator-agent.ts

📝 Walkthrough

Walkthrough

The PR fixes a bug where the /setproject command handler incorrectly used the platform conversation ID instead of the database conversation ID when updating conversation records. The implementation now passes conversation.id to the database update, and a regression test ensures the fix remains correct.

Changes

Orchestrator /setproject DB ID Fix

Layer / File(s) Summary
Fix /setproject to use DB conversation ID
packages/core/src/orchestrator/orchestrator-agent.ts, packages/core/src/orchestrator/orchestrator-agent.test.ts
The /setproject command handler now passes the conversation database primary key (conversation.id) to handleSetProject, which updates conversation records with the DB id instead of the platform conversation id. Logging and the helper function signature were aligned accordingly. A regression test validates that updateConversation receives the DB id while sendMessage still targets the platform conversation id for user-facing replies.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly Related PRs

  • coleam00/Archon#1917: Related changes to the /setproject implementation and test coverage in orchestrator-agent.ts.

Poem

🐰 A rabbit hops through ID fields with glee,
Conversation keys now correctly agree—
DB primary, not platform chat's name,
Each update now matches the database's claim,
Tests guard the fix 'gainst regression's shame! 🔒

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: using the conversation DB id instead of the platform id for the /setproject command.
Description check ✅ Passed The PR description is comprehensive and addresses the core template requirements with clear problem statement, rationale, architecture diagrams, testing evidence, and security/compatibility confirmations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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