Skip to content

feat(discord): sync thread names from session titles - #26477

Open
JackALaing wants to merge 1 commit into
NousResearch:mainfrom
JackALaing:feat/discord-thread-title-sync
Open

feat(discord): sync thread names from session titles#26477
JackALaing wants to merge 1 commit into
NousResearch:mainfrom
JackALaing:feat/discord-thread-title-sync

Conversation

@JackALaing

Copy link
Copy Markdown

Summary

  • Add a Discord thread rename helper so gateway session titles can update the corresponding thread name.
  • Sync manual /title ... changes immediately when the command is run from a Discord thread.
  • Wire auto-generated session titles through a callback that schedules the Discord rename on the gateway event loop, avoiding polling the session DB or using a stale/nonexistent loop from the auto-title background thread.

Test Plan

  • python -m pytest tests/gateway/test_title_command.py -q
  • python -m py_compile gateway/platforms/discord.py gateway/run.py
  • Live Discord behavior was smoke-tested via manual title updates and has been exercised in production use; automated coverage uses gateway tests/mocks.

Platforms Tested

  • macOS arm64.

Related / competing PRs

  • PR #15757, feat(gateway/discord): sync thread names with session titles, targets the same user-visible Discord thread/session title sync behavior. This PR supersedes it by avoiding the DB polling loop, scheduling auto-title renames directly from the title callback onto the gateway event loop, keeping the scope focused, and adding regression tests.
  • PR #24311 is an even closer duplicate of the callback-based approach, but it was closed as duplicate and did not cover immediate manual /title renames in the same tested path. This PR is a consolidated successor rather than another duplicate.
  • PR #3009 and PR #17378 are adjacent Discord auto-thread-title work, but they focus on generated auto-thread names rather than syncing established session titles to existing Discord thread names.
  • PR #18429 and PR #16059 are closed related attempts to rename Discord-owned threads after title generation.
  • PR #9921, PR #16408, PR #20681, PR #21111 are Telegram topic-title sync analogues, not Discord thread sync.

Notes/Risks

  • Cross-platform impact is limited to the Discord gateway path. The implementation uses asyncio scheduling and discord.py channel editing; it does not add file I/O, shell commands, terminal handling, or process management.
  • Thread renames are best-effort. If the Discord adapter is unavailable, the source is not a Discord thread, or Discord rejects the edit, the title command/session flow still succeeds.

@alt-glitch alt-glitch added P3 Low — cosmetic, nice to have type/feature New feature or request comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter labels May 15, 2026
@TF0rd

TF0rd commented May 25, 2026

Copy link
Copy Markdown

+1 on this — clean implementation, covers both the auto-title and manual /title cases.

We're running Hermes with auto_thread: true on our Discord server and the raw first-message-derived thread names are painful to scan. This PR does exactly what's needed.

Cherry-picked this locally against current main (c016949) — applied cleanly, all 16 tests in test_title_command.py pass. No config toggle needed, it's automatic for Discord thread sessions, which is the right default. The run_coroutine_threadsafe bridge from the auto-title background thread is the correct pattern (matches the Telegram topic rename path).

Would be great to get this reviewed and merged. This feature has been attempted 5 times in prior PRs that all got bot-staled — this one actually has clean code and tests.

Closes #18430

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused callback-based implementation. Current main now contains the generated-title half of this behavior, but with safety constraints the PR predates.

Problems

  • The PR's automatic path would rename any Discord thread and calls channel.edit without an initial-name guard. Current main deliberately confines generated renames to Hermes-created auto-threads (gateway/run.py:13527-13535) and refuses to overwrite a changed thread name (plugins/platforms/discord/adapter.py:5401-5405).
  • The patch is against superseded integration points: the Discord adapter now lives at plugins/platforms/discord/adapter.py, and /title is handled in gateway/slash_commands.py:3445-3505. Current /title only schedules Telegram topic renames (gateway/slash_commands.py:3487-3504), so the manual Discord portion needs a port rather than a cherry-pick.

Suggested changes

  • Port only the explicit /title sync to the current slash-command path, while preserving the existing generated-title auto-thread guard and adding coverage for human-managed threads.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
@teknium1 teknium1 added the area/sessions Session lifecycle, resume, persistence, history label Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/sessions Session lifecycle, resume, persistence, history comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/discord Discord bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants