Skip to content

fix(slack): polish threaded replies and proactive delivery - #3475

Merged
Re-bin merged 6 commits into
mainfrom
fix/slack-experience-polish
Apr 27, 2026
Merged

Re-bin merged 6 commits into
mainfrom
fix/slack-experience-polish

Conversation

@Re-bin

@Re-bin Re-bin commented Apr 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR tightens Slack as a first-class chat surface instead of treating it like a plain message sink.

It fixes the thread context path for proactive replies, /restart, and slash commands, then adds a few Slack-specific UX improvements: long message splitting, Block Kit buttons for ask-user choices, safer thread-context hydration, and clearer docs for file upload permissions.

What Changed

  • Preserve Slack thread routing for proactive messages:

    • Cron jobs now persist channelMeta and sessionKey across store reloads.
    • Cron replies are recorded into the originating channel/thread session so the conversation can continue naturally.
    • /restart now carries channel metadata across os.execv, so Restart completed lands in the same Slack thread.
  • Improve reminder quality:

    • Cron fire-time prompts now ask the agent to speak directly to the user.
    • This avoids status-report replies like Done ✅ 已提醒 U0....
  • Keep slash commands command-shaped:

    • Slack thread context is skipped for messages that start with /.
    • This prevents /restart from being wrapped inside thread history and routed to the LLM as normal chat.
  • Improve Slack message rendering:

    • Split long Slack replies before hitting Slack’s message size limit.
    • Render OutboundMessage.buttons with Slack Block Kit.
    • Route button clicks back into the same Slack thread/session.
    • Keep prior bot replies in hydrated thread context so follow-up questions have the right local history.
    • Bound the thread-context cache to avoid unbounded growth in long-running gateways.
  • Update docs:

    • Document files:write as required for Slack image/video/file uploads.
    • Add a short README reminder for Slack media uploads.

Test Plan

  • python -m pytest tests/channels/test_slack_channel.py tests/utils/test_restart.py tests/cli/test_restart_command.py tests/tools/test_message_tool.py tests/agent/test_loop_tool_context.py -q

Result: 37 passed

Re-bin added 6 commits April 27, 2026 04:33
Without writing these fields into jobs.json, cron jobs created in a
Slack thread lost their thread_ts (and original session_key) after the
service was reloaded, so reminders fired into the channel root.

Made-with: Cursor
…nder

The old prompt framed cron firing as a "task triggered" status report,
which led the agent to reply with things like "Done ✅ 已提醒
U0AV8BJPV8D 喝水" — exposing the user id and reading like a system log
instead of a friendly reminder. Reword it to instruct the agent to
speak directly to the user and forbid status-style language.

Made-with: Cursor
…s in thread

cmd_restart only persisted channel + chat_id across the os.execv boundary, so
when the new process announced "Restart completed" the OutboundMessage had
no Slack thread_ts and the reply fell back to the channel root.

Serialize msg.metadata into NANOBOT_RESTART_NOTIFY_METADATA, restore it on the
RestartNotice, and forward it to OutboundMessage so the completion message
follows the same routing as the original /restart invocation.

Made-with: Cursor
… buried

_with_thread_context prepends conversation history to the message
content.  This turned "/restart" into "Slack thread context...\n\n
Current message:\n/restart", which the command router could not match
as a priority command.  Skip the context enrichment when the stripped
text starts with "/".

Made-with: Cursor
Keep the root README focused on the main setup path and leave Slack-specific upload permissions in the chat apps guide.

Made-with: Cursor
@Re-bin
Re-bin merged commit d89a824 into main Apr 27, 2026
8 checks passed
@Re-bin
Re-bin deleted the fix/slack-experience-polish branch April 27, 2026 04:45
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