feat(gchat): option to keep threads in direct messages

Open
#1,149 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Start in the Google Chat adapter's handleMessageEvent, where DM messages are mapped to a thread ID, and compare with how the Slack adapter's agentView handles DM thread roots. Check how the proposed threadedDMs flag would alter the :dm ID and whether openDM() subscriptions still match. Done means that with the option on, a new DM thread gets its own ID and reply, the default behaviour is unchanged, and the option name is settled with maintainers first.

Written by the indexing model from the issue text.

Description

Problem Statement

In a Google Chat direct message, the Google Chat adapter maps every message to one space-only thread ID (gchat:spaces/DM_SPACE:dm) and drops message.thread.name. A DM is therefore one endless conversation for the bot: replies always go to the top level, and a user who starts a new thread in the DM (Google Chat supports threads in DMs) still lands in the same conversation and memory as everything before it.

The Slack adapter handles this differently. In a Slack DM, a reply inside a thread keeps its thread_ts, so it stays a separate conversation, and agentView: true makes every top-level DM message its own thread root, while still routing to the openDM() subscription when that one is subscribed. Google Chat has no equivalent, so the same bot behaves differently on the two platforms.

We build internal agents for colleagues (one case = one thread) and work around this today by replacing the adapter's handleMessageEvent with a copy that keeps the thread name for DMs. That copy breaks with every adapter change.

Proposed Solution

An adapter option, for example threadedDMs: true (name open), with which a DM message is encoded with its thread name, like messages in spaces:

const threadName = isDM && !this.threadedDMs ? undefined : message.thread?.name || message.name;

with the :dm marker kept so thread.isDM stays true. Like Slack's agentView bridge, a message could route to the space-only ID when that ID has a subscription from openDM(), so proactive flows keep working.

Default stays as today, so nothing changes for existing users.

Alternatives Considered
  • Overriding handleMessageEvent in our own code (what we do now): works, but depends on adapter internals.
  • Making thread-aware DMs the default: closer to Slack's default (thread replies keep thread_ts), but changes behaviour for existing bots.
Use Case
import { createGoogleChatAdapter } from '@chat-adapter/gchat';

const gchat = createGoogleChatAdapter({
  // ...
  threadedDMs: true,
});

// A new thread in a DM -> its own thread ID, its own conversation and memory;
// the bot's reply goes into that thread instead of the top level.
Priority

Important

Contribution
  • I am willing to help implement this feature
Additional Context

Related: #1135 (card clicks in a DM get a different thread ID than the DM's messages). With this option, a click and the messages of the same DM thread would both carry the thread name, which also removes the mismatch described there for threaded DMs.

The Teams adapter has no equivalent, but Teams 1:1 chats have no reply threads, so there is nothing to keep there.

Dominant language
TypeScript
Stars
2.5k
Forks
355
Avg merge
2d 15h
Merged PRs (30d)
42

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel/chat

All issues in vercel/chat

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.