Adds /let-them-talk, which starts Let Them Talk and opens it in your browser; shows Claude Code's suggested next prompt in its Send box; and runs a Chat in IDE…

The Claude Code plugin of Let Them Talk, a visual board for your Claude Code sessions. It does four things:
/let-them-talk, typed in any chat, starts Let Them Talk with uvx let-them-talk and opens it in your browser. It needs uv. The board keeps running after that chat ends; if it already runs, the command only opens it.It runs no command in your chats by itself, so nothing of its own appears in their terminals. The suggestion, the model and the messages between WSL and Windows need Let Them Talk running on port 8765, the default, or the port LTT_PORT names where Claude Code runs. It talks only to the app on your own machine, and does nothing when the app isn't running.
claude plugin marketplace add abdullahkavakli/let-them-talk
claude plugin install let-them-talk@let-them-talk
Or, inside a chat: /plugin install let-them-talk --marketplace abdullahkavakli/let-them-talk.
It was called let-them-talk-suggestions before. If you installed it under that name, remove the old one: claude plugin uninstall let-them-talk-suggestions@let-them-talk.
The plugin is the mod of the latest release, the same release as the app uvx let-them-talk runs, so the two match. A change made to the mod since then reaches you with the next release.
Chats started before the plugin was installed show no suggestion and have no /let-them-talk until they are restarted.
More, including how to load it from a copy of the repository (which then follows that copy, not the release), how to stop a board started with /let-them-talk, and what to do if the app runs on another port: Configuration.
hooks/register.ts 312 lines1import type { Register } from 'claude-code'
2
3// Let Them Talk (this repo) shows each chat's suggested next prompt in its
4// Send box: exactly what this chat's own prompt box shows, or nothing.
5//
6// - When Claude Code shows its own suggestion, it is passed on.
7// - When it made none (the terminal is unfocused, or a background agent has
8// nobody attached) and Let Them Talk has this chat open, one is made the
9// way Claude Code makes its own ($.model.fork over the cached conversation)
10// and shown in this chat's prompt box too, so both match.
11// - A background agent that ends its turn waiting on you is left alone:
12// Claude Code makes that one itself and saves it, and the app reads it there.
13// Only text the box really shows is reported; otherwise "none".
14//
15// It also runs a chat on the model picked in the app's New agent, for a Chat in
16// IDE: the editor link that opens one can't name a model, so the app says
17// which when the chat's first turns start, and this names it on the chat's
18// own requests (not its subagents'). A model you then pick in the chat wins.
19//
20// It runs no command in a chat: no command line of its own shows in its terminal.
21//
22// And it adds /let-them-talk, which starts the app the README's way (uvx
23// let-them-talk) and opens it in the browser, with no Claude turn: see START.
24//
25// Last, it lets a chat in WSL and one on Windows message each other, when you
26// have drawn an arrow between them: Claude Code keeps the two sides' chats
27// apart, so a message a chat sends is first handed to the app, which delivers
28// it on the other side when it has such an arrow (see forwardAnswer), and
29// otherwise lets SendMessage go on as it would.
30
31// Where the app listens, as this chat finds it: the port LTT_PORT names where
32// Claude Code runs (a copy of the app on another port, say), else the default.
33// The app accepts only this address as its Host (localhost:<port>).
34export async function appUrl($: { env: { get: (name: string) => Promise<string | undefined> } }) {
35 return `http://localhost:${(await $.env.get('LTT_PORT')) || '8765'}`
36}
37const HEADERS = { 'Content-Type': 'application/json', 'X-Let-Them-Talk': '1' }
38const TICK_MS = 2000
39const OWN_WAIT_MS = 12000 // Claude Code makes its own within a few seconds of the turn's end
40const WINDOW_MS = 300_000 // after that the conversation may no longer be cached (server: MOD_WINDOW)
41const HELLO_EVERY_MS = 300_000 // so the app keeps counting this chat as having the mod
42const MODEL_ASKS = 3 // turns at a chat's start the app is asked for a model (it knows by the first)
43
44const PROMPT = `[Suggestion only. Do not answer this message or continue the task.]
45Predict what the user will most likely type next in this chat. Predict what they
46would type, not what they should do: they should think "I was about to type that".
47If you just asked whether to go on, answer like "yes" or "go ahead"; if you offered
48options, pick the one this user would; if a task is done and the next step is
49obvious, name it, like "commit it" or "run the tests"; after an error or a
50misunderstanding, suggest nothing. Be specific. Never suggest thanks or praise, a
51question, your own voice ("Let me..."), or anything new the user didn't ask for.
52One sentence of 2 to 12 words, in the user's language and style. If the next step
53isn't obvious, reply with a single hyphen. Reply with only the suggestion.`
54
55const SILENT = /^\W*(-|none|nothing|silence|no suggestion.*|nothing to suggest.*|done)\W*$|^[[(].*[\])]$/i
56
57/** What to tell the app about a suggestion: the text only if the box shows it. */
58export function report(text: string | undefined, isShown: boolean, made: 'claude' | 'fork') {
59 return text?.trim() && isShown ? { text, made } : { text: '', made: 'none' as const }
60}
61
62export function cleanSuggestion(text: string): string | undefined {
63 const line = text.trim().split('\n')[0].trim().replace(/^["'“”]+|["'“”]+$/g, '').trim()
64 return line && !SILENT.test(line) && line.split(/\s+/).length <= 12 ? line : undefined
65}
66
67/** The model a request of this chat names: the app's pick (a full id), until
68 * the chat's own model changes under it (you picked another in the chat), then
69 * the chat's. The chat's own spelling of the same model ([1m]) is kept. */
70export function modelFor(wanted: string | undefined, startedOn: string | undefined, now: string) {
71 if (!wanted) return { model: now, startedOn, dropped: false }
72 if (startedOn !== undefined && now !== startedOn) return { model: now, startedOn, dropped: true }
73 return { model: now.startsWith(wanted) ? now : wanted, startedOn: startedOn ?? now, dropped: false }
74}
75
76/** What the app answered to a message about to be sent (POST /api/xsend): it
77 * has it (forwarded), or SendMessage goes on, with the app's reason when it
78 * says the message can't be sent. Anything else, an error status included,
79 * means SendMessage goes on. */
80export function forwardAnswer(reply: { ok: boolean; text: string }): { forwarded: boolean; reason?: string } {
81 try {
82 const got = reply.ok ? JSON.parse(reply.text) : undefined
83 if (got?.forwarded === true) return { forwarded: true }
84 if (typeof got?.reason === 'string' && got.reason) return { forwarded: false, reason: got.reason }
85 } catch {
86 // not an answer of the app's
87 }
88 return { forwarded: false }
89}
90
91export const UV_LINK = 'https://docs.astral.sh/uv/'
92
93// Variables a chat sets for what it starts: server.py's SESSION_ENV, the same
94// list. The app is started without them, as from a terminal, so nothing it
95// starts is taken for a part of this chat.
96export const SESSION_ENV = ['CLAUDECODE', 'CLAUDE_CODE_SESSION_ID', 'CLAUDE_CODE_MESSAGING_SOCKET',
97 'CLAUDE_CODE_MESSAGING_TOKEN', 'CLAUDE_CODE_CHILD_SESSION', 'CLAUDE_CODE_ENTRYPOINT', 'CLAUDE_JOB_DIR',
98 'CLAUDE_CODE_SESSION_ATTENDED', 'TRACEPARENT', 'TRACESTATE']
99
100// /let-them-talk's start, run by sh with the board's address as $1. It finds
101// uvx (on the PATH, or where uv's installer puts it) and starts
102// `uvx let-them-talk` from the home folder in a session of its own (setsid;
103// nohup where there is none, as on macOS), with no pipe or terminal of this
104// chat's, so it keeps running after the chat ends. The app opens the page
105// itself, and when it runs already it only opens the page and ends. This waits
106// up to 15 s for it to print the address (it runs) or end, then prints
107// `no-uv`, `running` or `ended <exit code>`, and below that what the app printed.
108export const START = `uvx=
109for f in "$(command -v uvx)" "$HOME/.local/bin/uvx" "$HOME/.cargo/bin/uvx"; do
110 if [ -z "$uvx" ] && [ -n "$f" ] && [ -x "$f" ]; then uvx=$f; fi
111done
112if [ -z "$uvx" ]; then echo no-uv; exit 0; fi
113dir=$(mktemp -d 2>/dev/null || mktemp -d -t let-them-talk) || exit 1
114cd "$HOME" 2>/dev/null || cd /
115unset ${SESSION_ENV.join(' ')}
116run='"$0" let-them-talk > "$1/out" 2>&1; echo $? > "$1/code"'
117if command -v setsid > /dev/null 2>&1; then
118 setsid sh -c "$run" "$uvx" "$dir" < /dev/null > /dev/null 2>&1 &
119else
120 nohup sh -c "$run" "$uvx" "$dir" < /dev/null > /dev/null 2>&1 &
121fi
122i=0
123while [ ! -s "$dir/code" ] && ! grep -q -F "$1" "$dir/out" 2> /dev/null && [ $i -lt 60 ]; do
124 sleep 0.25
125 i=$((i + 1))
126done
127if [ -s "$dir/code" ]; then echo "ended $(cat "$dir/code")"; else echo running; fi
128cat "$dir/out" 2> /dev/null
129rm -rf "$dir"
130`
131
132/** What /let-them-talk says, from what START printed and whether the app
133 * already answered at `url` before it ran. `exitCode` is for a
134 * `claude -p /let-them-talk` run from a shell. */
135export function startReport(printed: string, url: string, wasRunning: boolean): { text: string; exitCode?: number } {
136 const [status = '', ...rest] = printed.split('\n')
137 const said = rest.join('\n').trim()
138 if (status === 'no-uv') {
139 return {
140 text: `Let Them Talk starts with uv, which isn't installed. Install uv (${UV_LINK}), then run /let-them-talk again.`,
141 exitCode: 1,
142 }
143 }
144 const failed = status !== 'running' && status !== 'ended 0'
145 if (wasRunning) return { text: `Let Them Talk is already running. ${failed ? 'Open' : 'Opening'} ${url} in your browser.` }
146 if (failed) return { text: `Let Them Talk didn't start.${said ? `\n\n${said}` : ''}`, exitCode: 1 }
147 const after = 'It keeps running after this chat ends.'
148 if (status === 'running' && !said.includes(url)) {
149 return { text: `Let Them Talk is starting. The first start downloads it, which can take a minute; then it opens in your browser at ${url}. ${after}` }
150 }
151 return { text: `Let Them Talk is running at ${url} and opens in your browser. ${after}` }
152}
153
154export const register: Register = on => {
155 on('command.run', { command: 'let-them-talk' }, async $ => {
156 const url = await appUrl($)
157 let wasRunning = false
158 try {
159 const page = await $.http.fetch(`${url}/`)
160 wasRunning = (page.headers.server ?? '').startsWith('LetThemTalk/')
161 } catch {
162 // nothing answers there
163 }
164 try {
165 const run = await $.process.run(['sh', '-c', START, 'let-them-talk', url], { timeoutMs: 30_000 })
166 return startReport(run.stdout, url, wasRunning)
167 } catch (error) {
168 return { text: `Let Them Talk didn't start: ${error instanceof Error ? error.message : String(error)}`, exitCode: 1 }
169 }
170 })
171
172 let turn = 0 // main-loop turns ended so far
173 let starts = 0 // main-loop turns started so far
174 let ownFor = -1 // the turn Claude Code's own suggestion came after
175 let pending: { turn: number; starts: number; waited: number } | undefined // a turn still without one
176 let busy = false
177 let helloFor: string | undefined
178 let sinceHello = 0
179 let unsent: string | undefined // a report the app didn't take (it was down), sent again next tick
180 let wanted: string | undefined // the model the app picked for this chat
181 let startedOn: string | undefined // the chat's own model when that took over
182 let asked = 0
183
184 // Work after a turn outlives the turn's own hooks, so a timer started here does it.
185 on('session.start', async ($, e, next) => {
186 const started = await next(e)
187 try {
188 await $.command.register({ name: 'let-them-talk', description: 'Start Let Them Talk and open it in your browser' })
189 } catch {
190 // refused: the suggestions below still run
191 }
192 // A headless run (claude -p, such as the app's own TL;DR runs) has no prompt box.
193 if (!e.isInteractive) return started
194 $.clock.every(TICK_MS, () => {
195 if (busy) return
196 busy = true
197 void (async () => {
198 try {
199 // Read each time: /clear and /resume carry on under another id.
200 const sessionId = await $.session.id()
201 sinceHello += TICK_MS
202 if (sessionId !== helloFor || sinceHello >= HELLO_EVERY_MS) {
203 await $.http.fetch(`${await appUrl($)}/api/suggestion/hello`, {
204 method: 'POST', headers: HEADERS, body: JSON.stringify({ sessionId, bridge: true }),
205 })
206 helloFor = sessionId
207 sinceHello = 0
208 }
209 if (unsent) {
210 const sent = await $.http.fetch(`${await appUrl($)}/api/suggestion`, { method: 'POST', headers: HEADERS, body: unsent })
211 if (sent.ok) unsent = undefined
212 }
213 if (!pending) return
214 pending.waited += TICK_MS
215 const { turn: forTurn, starts: forStarts, waited } = pending
216 if (ownFor === forTurn || waited > WINDOW_MS) { // Claude Code made its own, or too late
217 pending = undefined
218 return
219 }
220 if (waited < OWN_WAIT_MS) return
221 const wanted = await $.http.fetch(`${await appUrl($)}/api/suggestion/wanted?session=${sessionId}`)
222 if (!wanted.ok || JSON.parse(wanted.text).wanted !== true) return // ask again next tick
223 pending = undefined
224 const reply = await $.model.fork({ prompt: PROMPT })
225 const text = reply.isAnswered ? cleanSuggestion(reply.text) : undefined
226 if (ownFor === forTurn || forTurn !== turn || forStarts !== starts) return // a newer turn
227 const shown = text ? await $.prompt.suggest({ text }) : undefined
228 // "none" tells the app this turn has nothing, so it stops waiting for one
229 const body = JSON.stringify({ sessionId, ...report(text, shown?.isShown === true, 'fork') })
230 const sent = await $.http.fetch(`${await appUrl($)}/api/suggestion`, { method: 'POST', headers: HEADERS, body })
231 if (!sent.ok) unsent = body
232 } catch {
233 // Let Them Talk isn't running, or the fork failed: nothing to show.
234 } finally {
235 busy = false
236 }
237 })()
238 })
239 return started
240 })
241
242 on('prompt.suggest', async ($, e, next) => {
243 const shown = await next(e)
244 // Claude Code's own guess; one this mod (a plugin) proposed is already sent.
245 if (e.origin?.kind === 'plugin' || !e.text.trim()) return shown
246 ownFor = turn
247 let body: string | undefined
248 try {
249 const sessionId = await $.session.id()
250 body = JSON.stringify({ sessionId, ...report(e.text, shown.isShown, 'claude') })
251 const sent = await $.http.fetch(`${await appUrl($)}/api/suggestion`, { method: 'POST', headers: HEADERS, body })
252 if (!sent.ok) unsent = body
253 } catch {
254 unsent = body // Let Them Talk isn't running: the suggestion shows here all the same
255 }
256 return shown
257 })
258
259 on('turn.start', async ($, e, next) => {
260 starts++
261 pending = undefined // the user moved on: a suggestion for the last turn is moot
262 if (!wanted && asked < MODEL_ASKS) {
263 asked++
264 try {
265 const reply = await $.http.fetch(`${await appUrl($)}/api/mod/model?session=${await $.session.id()}`)
266 if (reply.ok) wanted = JSON.parse(reply.text).model || undefined
267 } catch {
268 // Let Them Talk isn't running: the chat's own model
269 }
270 }
271 return next(e)
272 })
273
274 on('turn.step', async function* ($, e, next) {
275 if (e.agentId || !wanted) return yield* next(e)
276 const pick = modelFor(wanted, startedOn, e.model)
277 startedOn = pick.startedOn
278 if (pick.dropped) wanted = undefined
279 return yield* next(pick.model === e.model ? e : { ...e, model: pick.model })
280 })
281
282 // A message this chat's model sends with SendMessage is first handed to the
283 // app, which delivers it on the other side (WSL or Windows) when this chat
284 // has an arrow to a chat there with that name. Then this answers the send as
285 // delivered and nothing else is sent; for any other message, or when the app
286 // can't be reached, SendMessage goes on as it would. A plugin's own sends
287 // pass untouched. The app answers {forwarded: false} to a sender it doesn't
288 // list as a chat, such as its own relay runs, which load this plugin too.
289 on('session.send', async ($, e, next) => {
290 if (e.origin.kind !== 'model') return next(e)
291 let answer: { forwarded: boolean; reason?: string } = { forwarded: false }
292 try {
293 const reply = await $.http.fetch(`${await appUrl($)}/api/xsend`, {
294 method: 'POST', headers: HEADERS, body: JSON.stringify({ sessionId: await $.session.id(), to: e.to, text: e.text }),
295 })
296 answer = forwardAnswer(reply)
297 } catch {
298 // Let Them Talk isn't running (or didn't answer): SendMessage goes on
299 }
300 if (answer.forwarded) return { isDelivered: true as const }
301 if (answer.reason) return { isDelivered: false as const, reason: answer.reason }
302 return next(e)
303 }).catch(($, e, next) => next(e))
304
305 on('turn.complete', async ($, e, next) => {
306 const done = await next(e)
307 // The main loop's answers only: not subagents, interrupts or errors.
308 if (!e.agentId && !e.isAborted && e.reason === 'answer') pending = { turn: ++turn, starts, waited: 0 }
309 return done
310 })
311}
312