Skip to content

Replace built-in messenger system with chat-system crate#159

Merged
rexlunae merged 5 commits intomainfrom
copilot/remove-built-in-messenger-support
Apr 6, 2026
Merged

Replace built-in messenger system with chat-system crate#159
rexlunae merged 5 commits intomainfrom
copilot/remove-built-in-messenger-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 5, 2026

  • rustyclaw-core/Cargo.toml: Add chat-system git dependency; update feature flags (matrix, whatsapp, signal-cli) to forward to chat-system; keep workspace rusqlite at 0.37
  • messengers/mod.rs: Rewrite to re-export types from chat-system; keep CLI messenger modules and media, streaming, group_chat (pending chat-system PRs)
  • Delete 12 replaced messenger files: console.rs, discord.rs, google_chat.rs, imessage.rs, irc.rs, matrix.rs, slack.rs, teams.rs, telegram.rs, webhook.rs, whatsapp.rs, signal_cli.rs
  • Update CLI messenger files: matrix_cli.rs, telegram_cli.rs, discord_cli.rs, slack_cli.rs — change imports to chat_system types, add reactions: None to Message { } constructions
  • lib.rs: Update re-exports to include PresenceStatus from chat-system
  • gateway/messenger_handler.rs: Update imports; adapt MessengerManager API calls (add_boxed, messengers()); add get_messenger_by_type helper; update Teams/GoogleChat/IMessage/Matrix/Signal/WhatsApp constructors to match chat-system API
  • vendor/chat-system/: Vendor copy of chat-system with rusqlite upgraded 0.32→0.37; use [patch."https://github.com/rexlunae/chat-system"] to redirect the git dependency
  • mnemo/sqlite_store.rs: Use query_row for PRAGMA journal_mode=WAL; log warning on WAL checkpoint failure
  • vendor/chat-system/src/servers/irc.rs: Add monotonic counter suffix to IRC server message IDs
  • Cargo.lock: Removed from version control; both our branch and main independently added it to .gitignore
  • Branch up to date with main: Merged all main commits through 8ce42e8 (Device flow improvements)
  • CI fix: Add missing listen_addr field to ssh::SshConfig initializer in gateway/mod.rs:511; the 8ce42e8 "Device flow improvements" commit added listen_addr to SshConfig but a second SSH init block (from the SSH transport PR merge) was missing it, causing error[E0063]: missing field listen_addr

@rexlunae
Copy link
Copy Markdown
Owner

rexlunae commented Apr 5, 2026

@copilot The Cargo.lock file isn't even supposed to be in the repo. Can we just get rid of it to resolve the conflict?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 5, 2026

@copilot The Cargo.lock file isn't even supposed to be in the repo. Can we just get rid of it to resolve the conflict?

Done in e66b5d3. Added Cargo.lock to .gitignore and removed it from git tracking.

Copilot AI requested a review from rexlunae April 5, 2026 22:02
@rexlunae rexlunae marked this pull request as ready for review April 5, 2026 22:14
@rexlunae
Copy link
Copy Markdown
Owner

rexlunae commented Apr 5, 2026

@copilot Can you fix the resolve conflict?

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

⚠️ 1 issue in files not directly in the diff

⚠️ recommended_strategy uses stale messenger_type strings after chat-system migration (crates/rustyclaw-core/src/messengers/streaming.rs:273)

The recommended_strategy function in streaming.rs:273 matches on the old "teams" and "google_chat" strings, but the new chat-system implementations return "msteams" and "googlechat" from messenger_type() respectively (see vendor/chat-system/src/messengers/teams.rs:243 and vendor/chat-system/src/messengers/google_chat.rs:239). Any caller passing the new messenger_type() value for Teams or Google Chat will fall through to the default BufferAll strategy instead of the intended EditInPlace strategy. These match arms are now dead code.

View 5 additional findings in Devin Review.

Open in Devin Review

@rexlunae
Copy link
Copy Markdown
Owner

rexlunae commented Apr 5, 2026

@copilot Can you fix the branch conflict?

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 8 additional findings in Devin Review.

Open in Devin Review

Comment on lines +193 to +198
.context("Matrix requires 'user_id'")?;
let password = config.password.clone();
let access_token = config.access_token.clone();

// Store path for Matrix SQLite database
let store_path = dirs::data_dir()
.context("Failed to get data directory")?
.join("rustyclaw")
.join("matrix")
.join(&name);

let messenger = if let Some(pwd) = password {
MatrixMessenger::with_password(name.clone(), homeserver, user_id, pwd, store_path)
} else if let Some(token) = access_token {
// Device ID is optional, defaults to "RUSTYCLAW" if not provided
MatrixMessenger::with_token(
name.clone(),
homeserver,
user_id,
token,
None,
store_path,
)
} else {
anyhow::bail!("Matrix requires either 'password' or 'access_token'");
};
Box::new(messenger)
let password = config
.password
.clone()
.context("Matrix requires 'password'")?;
Box::new(MatrixMessenger::new(name, homeserver, user_id, password))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Matrix access_token authentication silently removed, breaking existing configurations

The migration to chat-system's MatrixMessenger removed support for access-token-based Matrix authentication. Previously, users could configure Matrix with either password or access_token (crates/rustyclaw-core/src/messengers/matrix.rs:135-167 in the deleted file). The new code unconditionally requires password and will fail with "Matrix requires 'password'" for any configuration that used access_token instead. The new MatrixMessenger in vendor/chat-system/src/messengers/matrix.rs:243-282 only supports m.login.password. Users who relied on token-based auth (common for bots with pre-generated tokens) will be broken with no migration path within the matrix feature.

Prompt for agents
The Matrix messenger creation in create_messenger() (messenger_handler.rs around lines 184-199) now requires password and only calls MatrixMessenger::new(name, homeserver, user_id, password). Previously, the code checked for password first, then fell back to access_token, and failed only if neither was provided.

The root cause is that vendor/chat-system/src/messengers/matrix.rs only implements m.login.password authentication. To fix this, either:

1. Add access_token/session-restore support to the vendored chat-system MatrixMessenger (a with_token constructor or similar), OR
2. Restore the old branching logic in create_messenger() that checks for password first and access_token second, and create an appropriate messenger for each case.

The old code path for access_token used matrix-sdk's session restore with MatrixSession containing the token, device_id, and user_id. The new chat-system MatrixMessenger would need an equivalent path that sets the access_token directly and skips the login call in initialize().
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 5, 2026

@copilot Can you fix the resolve conflict?

Done in cfa66f3. Merged origin/main (SSH transport + pairing PR #138) into the branch. The only conflict was the Cargo.lock modify/delete — resolved by keeping it deleted as it's now in .gitignore.

@copilot Can you fix the branch conflict?

Fixed in cfa66f3 — merged origin/main into the branch. The branch is now up to date with no conflicts.

Copilot AI requested a review from rexlunae April 5, 2026 23:13
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 10 additional findings in Devin Review.

Open in Devin Review

Comment on lines +261 to +263
let mut messenger = SignalCliMessenger::new(name, phone);
// signal-cli path can be overridden via config or just use system default
Box::new(messenger)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Unused mut on SignalCliMessenger variable generates a compiler warning, violating CONTRIBUTING.md rule

let mut messenger = SignalCliMessenger::new(name, phone); declares the variable as mutable, but messenger is never mutated — it is immediately moved into Box::new(messenger). This produces an unused_mut warning. The CONTRIBUTING.md states: "No PR should be considered finished while warnings are still present. Warnings slow down compilation, make CI noisier, and often indicate real issues."

Suggested change
let mut messenger = SignalCliMessenger::new(name, phone);
// signal-cli path can be overridden via config or just use system default
Box::new(messenger)
let messenger = SignalCliMessenger::new(name, phone);
// signal-cli path can be overridden via config or just use system default
Box::new(messenger)
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@rexlunae
Copy link
Copy Markdown
Owner

rexlunae commented Apr 6, 2026

@copilot fix the conflicts preventing rebase.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 6, 2026

@copilot fix the conflicts preventing rebase.

Done in 5120db8. The branch is now fully up to date with main — merged the two new main commits (a5b31d4 "Don't track Cargo.lock" and 8ce42e8 "Device flow improvements") with no conflicts.

@rexlunae
Copy link
Copy Markdown
Owner

rexlunae commented Apr 6, 2026

@copilot : It's still saying it can't be merged due to conflicts.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 6, 2026

@copilot : It's still saying it can't be merged due to conflicts.

Fixed in a039436. The "can't be merged" was caused by a CI build failure — the 8ce42e8 "Device flow improvements" commit added a listen_addr field to ssh::SshConfig, but a second SSH server initialization block in gateway/mod.rs (from the earlier SSH transport PR merge) was constructing SshConfig without it, causing error[E0063]: missing field 'listen_addr'. That's now fixed. The branch also has a clean linear rebase history on top of the merge commits, which should allow all merge strategies to work.

@copilot Can you fix the branch conflict?

The branch conflict has been resolved — the branch is now fully up to date with main through 8ce42e8 (Device flow improvements), and the CI build failure blocking the merge has been fixed in a039436.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/rexlunae/chat-system/commits/HEAD
    • Triggering command: /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo check --package rustyclaw-core --features full (http block)
    • Triggering command: /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo check --package rustyclaw-core --features full ame nfig/composer/vendor/bin/git (http block)
  • https://api.github.com/repos/signalapp/curve25519-dalek/commits/signal-curve25519-4.1.3
    • Triggering command: /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo check --package rustyclaw-core --features full (http block)
    • Triggering command: /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo /home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/cargo check --package rustyclaw-core --features full ame nfig/composer/vendor/bin/git (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@rexlunae
Copy link
Copy Markdown
Owner

rexlunae commented Apr 6, 2026

@copilot: it still says This branch cannot be rebased due to conflicts

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 11 additional findings in Devin Review.

Open in Devin Review

Comment on lines +151 to +154
if let (Some(token), Some(space_id)) =
(&config.token, config.spaces.first())
{
Box::new(GoogleChatMessenger::new_api(name, token, space_id))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Google Chat spaces config values get double-prefixed, breaking API calls

The old GoogleChatMessenger documented spaces entries as full resource names like "spaces/AAAA". The new create_messenger passes config.spaces.first() directly to GoogleChatMessenger::new_api as the space_id. However, the chat-system's GoogleChatMessenger internally prepends spaces/ in its helper methods (vendor/chat-system/src/messengers/google_chat.rs:140-145), producing URLs like spaces/spaces/AAAA — a double-prefixed path that will 404 against the Google Chat API.

Path construction in chat-system

vendor/chat-system/src/messengers/google_chat.rs:140:

fn space_path(space_id: &str) -> String {
    format!("spaces/{space_id}")
}

So when the config has spaces = ["spaces/AAAA"], the API URL becomes https://chat.googleapis.com/v1/spaces/spaces/AAAA.

Prompt for agents
The config.spaces entries may contain full resource names like "spaces/AAAA" (the old documented format) or bare IDs like "AAAA". The chat-system GoogleChatMessenger::new_api stores the value as-is in space_id and then wraps it with format!("spaces/{space_id}") internally. This produces double-prefixed paths for existing configs.

Two possible fixes:
1. In create_messenger (messenger_handler.rs around line 152), strip any leading "spaces/" prefix before passing to new_api: space_id.strip_prefix("spaces/").unwrap_or(space_id)
2. Update the chat-system GoogleChatMessenger to handle both formats by checking if space_id already starts with "spaces/" in its helper methods.

Option 1 is simpler and keeps the fix local.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 6, 2026

@copilot: it still says This branch cannot be rebased due to conflicts

The "Rebase and merge" conflict is a history problem, not a code conflict. The branch contains two old merge commits that pull in earlier commits (9015ec8, 84a25f8, e66b5d3) which touch Cargo.lock — and GitHub's rebase tries to replay those one-by-one onto main, hitting a conflict immediately.

Two easier options that work today:

  • "Create a merge commit" — works fine, branch is already up to date with main
  • "Squash and merge" — works fine, squashes everything into one clean commit

If you specifically need "Rebase and merge", you can clean up the branch history locally with a force-push:

git fetch origin
git checkout -b temp-clean origin/main
git cherry-pick ef390fc 08b2ffd a039436
git push --force-with-lease origin temp-clean:copilot/remove-built-in-messenger-support
git branch -D temp-clean

Those three cherry-picks apply cleanly onto main with no conflicts (verified locally). This replaces the branch with a clean linear 3-commit history that GitHub can rebase successfully.

Copilot AI and others added 3 commits April 6, 2026 17:36
- Remove 12 messenger implementation files replaced by chat-system crate
- Rewrite messengers/mod.rs to re-export types from chat-system
- Update CLI messenger files (matrix_cli, telegram_cli, discord_cli, slack_cli)
- Update gateway/messenger_handler.rs: use MessengerManager::add_boxed(), messengers()
- Update lib.rs re-exports to include PresenceStatus from chat-system
- Add chat-system git dependency to rustyclaw-core/Cargo.toml

Co-authored-by: rexlunae <6726134+rexlunae@users.noreply.github.com>
…ace rusqlite 0.37

- Add vendor/chat-system with rusqlite bumped from 0.32 to 0.37
- Use query_row for PRAGMA journal_mode=WAL (returns a result row)
- Log warning on WAL checkpoint failure instead of propagating error

Co-authored-by: rexlunae <6726134+rexlunae@users.noreply.github.com>
…r init

The 'Device flow improvements' commit (8ce42e8) added a listen_addr field to
ssh::SshConfig. A second SSH server initialization block (from the earlier SSH
transport PR merge) was constructing SshConfig without this field, causing:
  error[E0063]: missing field 'listen_addr' in initializer of 'ssh::SshConfig'

Fix: parse the bind address before the SshConfig struct and include it as
listen_addr. Remove the now-redundant bind_addr declaration inside the match arm.

Co-authored-by: rexlunae <6726134+rexlunae@users.noreply.github.com>
@rexlunae rexlunae force-pushed the copilot/remove-built-in-messenger-support branch from a039436 to 10dbda1 Compare April 6, 2026 23:36
Copilot AI and others added 2 commits April 6, 2026 17:37
- Remove 12 messenger implementation files replaced by chat-system crate
- Rewrite messengers/mod.rs to re-export types from chat-system
- Update CLI messenger files (matrix_cli, telegram_cli, discord_cli, slack_cli)
- Update gateway/messenger_handler.rs: use MessengerManager::add_boxed(), messengers()
- Update lib.rs re-exports to include PresenceStatus from chat-system
- Add chat-system git dependency to rustyclaw-core/Cargo.toml

Co-authored-by: rexlunae <6726134+rexlunae@users.noreply.github.com>
…ace rusqlite 0.37

- Add vendor/chat-system with rusqlite bumped from 0.32 to 0.37
- Use query_row for PRAGMA journal_mode=WAL (returns a result row)
- Log warning on WAL checkpoint failure instead of propagating error

Co-authored-by: rexlunae <6726134+rexlunae@users.noreply.github.com>
@rexlunae rexlunae merged commit 0909a71 into main Apr 6, 2026
14 checks passed
@rexlunae rexlunae deleted the copilot/remove-built-in-messenger-support branch April 6, 2026 23:47
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.

2 participants