feat(discord): auto-rename generic thread titles - #33862
Conversation
|
The cleanup regexes look solid. One thing that tripped me up on a similar project: Discord thread names from forum channels can include trailing ellipsis or truncation markers that arent caught by the edge regex. Worth checking if theres a |
7925831 to
1d6fd3a
Compare
|
Addressed the truncation edge case called out above:
Also rewrote the commit author to a GitHub noreply address so the contributor-attribution check should stop failing on Local validation after the update: |
1d6fd3a to
fe7495f
Compare
fe7495f to
3feb16a
Compare
teknium1
left a comment
There was a problem hiding this comment.
Thanks for the conservative, opt-in approach. Current main now has a narrower semantic-title flow for newly Hermes-created threads, but this PR remains distinct because it targets pre-existing generic titles.
Problems
plugins/platforms/discord/adapter.py:794-796passescurrent_namebefore message content; the helper selects its first usable input at line 230. An enablednova threadtherefore becomes onlyNova thread, not a title derived from the message. The added tests do not cover that enabled generic-title path.plugins/platforms/discord/adapter.py:149-156uses code-point slicing. Current main changed Discord thread title truncation to UTF-16-aware helpers in commit1deeaf71a(plugins/platforms/discord/adapter.py:5417-5421), so this would reintroduce an emoji boundary bug.- The write at proposed line 801 can affect any existing parented thread matched by a heuristic. Current main deliberately limits renames to recorded Hermes-created threads and checks the original title before editing (
gateway/run.py:13647-13692).
Suggested changes
- Prefer inbound message text for the candidate and add a generic-title regression test.
- Reuse the UTF-16 truncation helpers.
- Add durable provenance plus an expected-current-name guard, or narrow the feature to Hermes-created threads.
Automated hermes-sweeper review.
|
|
||
| def _discord_truncate_thread_title(title: str, max_length: int = _DISCORD_THREAD_TITLE_MAX_LENGTH) -> str: | ||
| title = _discord_clean_thread_title_text(title) | ||
| if len(title) <= max_length: |
There was a problem hiding this comment.
Discord thread-name limits are measured in UTF-16 code units, not Python code points. Current main uses utf16_len and _prefix_within_utf16_limit for this path (plugins/platforms/discord/adapter.py:5417-5421); please reuse those helpers so emoji cannot exceed the configured wire budget.
| if not should_rename: | ||
| return False | ||
| title = _discord_thread_title_from_messages( | ||
| [current_name, str(getattr(message, "content", "") or "")], |
There was a problem hiding this comment.
This order prevents a generic title from being replaced by message content: _discord_thread_title_from_messages() always uses its first usable input. For example, nova thread becomes only Nova thread. Pass meaningful inbound content first and add an enabled generic-title regression test.
| if not title or title == current_name: | ||
| return False | ||
| try: | ||
| await channel.edit(name=title, reason="Hermes auto-renamed generic Discord thread title") |
There was a problem hiding this comment.
This edits any pre-existing thread that the heuristic classifies. Current main protects manual/pre-existing names by restricting semantic renames to provenance-marked Hermes-created threads and requiring the recorded initial name to still match. Please add an equivalent ownership/current-name guard before writing.
3feb16a to
c65da59
Compare
|
Thanks for the review — addressed on the refreshed branch.
Validation: 531 Discord-adjacent tests pass; all required CI checks are green. |
5da6d5f to
9f28724
Compare
9f28724 to
5276d81
Compare
What does this PR do?
Extends the existing guarded Discord semantic-title flow to pre-existing threads whose titles are generic, truncated, URL-heavy, or at Discord's title limit.
The feature remains opt-in (
discord.auto_rename_threads.enabled: false). It does not add another title generator or rename path:rename_thread(..., only_if_current_name=...)guard prevents overwriting a human rename;Hermes-created auto-threads already use this flow. This PR only opts pre-existing generic threads into it.
Related Issue
Related to #29983, #26477, #15757, #30559.
Type of Change
Changes Made
auto_thread_rename_allowedprovenance and the expected current title inSessionSource.rename_threadimplementation.discord.auto_rename_threadsinto Discord platform config.Manage Threadspermission.Review Feedback Addressed
nova threadpath, serialization, existing durable titles, config bridging, and human-name preservation.Validation
Checklist
mainused as base