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

Aperta
#1,149 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
2.5k
Fork
355
Merge medio
2g 15h
PR unite (30g)
42

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vercel/chat

Tutte le issue di vercel/chat

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.