fix: show session title and workspace in /sessions picker

Read cwd from session.header (not only meta) and title from sessionTitle service or session/title events; list details in the message body and richer inline buttons.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
owo
2026-08-14 18:10:43 +08:00
co-authored by Cursor
parent 4bd3832858
commit c6125807f7
10 changed files with 383 additions and 36 deletions
+20 -3
View File
@@ -44,10 +44,21 @@ function messageUpdate(chatId: number, userId: number, text: string, updateId =
}
}
function makeAgent(id: string, followups: UserMessage[]) {
function makeAgent(id: string, followups: UserMessage[], opts?: {
cwd?: string
title?: string
}) {
const cwd = opts?.cwd ?? `/proj/${id}`
const events = opts?.title
? [{ type: 'session/title', data: { title: opts.title } }]
: []
return {
id: SessionId(id),
session: { meta: { cwd: `/proj/${id}` } },
session: {
header: { cwd },
meta: { cwd },
events,
},
followup(message: UserMessage) {
followups.push(message)
},
@@ -118,7 +129,10 @@ test('/sessions with no live agents shows NO_LIVE', async () => {
test('/sessions lists live agents with bind callbacks', async () => {
const sent: SentMessage[] = []
const followups: UserMessage[] = []
const agent = makeAgent('live-aaa', followups)
const agent = makeAgent('live-aaa', followups, {
cwd: 'D:/gitData/demo-app',
title: '演示会话',
})
const ctx = {
logger: { info() {}, warn() {}, error() {} },
agents: {
@@ -137,6 +151,9 @@ test('/sessions lists live agents with bind callbacks', async () => {
})
await bridge.processUpdate(messageUpdate(10, 1, '/sessions'))
assert.match(sent[0]!.text, /选择要遥控/)
assert.match(sent[0]!.text, /演示会话/)
assert.match(sent[0]!.text, /D:\/gitData\/demo-app/)
assert.match(sent[0]!.replyMarkup!.inline_keyboard![0]![0]!.text, /演示会话/)
assert.ok(sent[0]!.replyMarkup?.inline_keyboard?.[0]?.[0]?.callback_data?.startsWith(BIND_CB_PREFIX))
})