✨ feat(vscode): 会话 tab 可交接对话给同事

This commit is contained in:
cruldra committed 2026-08-27 15:14:42 +08:00
1 parent 5ee8226167
commit 77037924ef
20 files changed
+938 -26

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import type { GiteaLabel } from './api'
import { isMailboxIssue, MAILBOX_BODY, MAILBOX_LABEL, MAILBOX_TITLE } from '../cc/sessionHandoff'
import { createIssue, createRepoLabel, listIssuesByFilter, listRepoLabels } from './api'
export async function findMailboxIssue(opts: {
host: string
token: string
owner: string
repo: string
}): Promise<number | undefined> {
const labels = await listRepoLabels(opts)
if (!labels.some(l => l.name === MAILBOX_LABEL))
return undefined
const issues = await listIssuesByFilter({ ...opts, labels: MAILBOX_LABEL })
return issues.find(i => isMailboxIssue(i))?.number
}
export async function ensureMailboxIssue(opts: {
host: string
token: string
owner: string
repo: string
}): Promise<number> {
const existing = await findMailboxIssue(opts)
if (existing !== undefined)
return existing
const labels = await listRepoLabels(opts)
let label: GiteaLabel | undefined = labels.find(l => l.name === MAILBOX_LABEL)
if (!label)
label = await createRepoLabel({ ...opts, name: MAILBOX_LABEL, color: '586069', description: 'Superwork session mailbox' })
const created = await createIssue({
...opts,
title: MAILBOX_TITLE,
body: MAILBOX_BODY,
labels: [label.id],
})
return created.number
}