feat(core): global form support (#35959)
This commit is contained in:
parent
79415f625a
commit
b44a981eef
17 changed files with 493 additions and 93 deletions
|
|
@ -6,11 +6,17 @@ const id = "internal:notifications"
|
|||
|
||||
type SessionError = Extract<V2Event, { type: "session.error" }>["data"]["error"]
|
||||
|
||||
function notify(api: TuiPluginApi, sessionID: string | undefined, message: string, sound: TuiAttentionSoundName) {
|
||||
function notify(
|
||||
api: TuiPluginApi,
|
||||
sessionID: string | undefined,
|
||||
message: string,
|
||||
sound: TuiAttentionSoundName,
|
||||
title?: string,
|
||||
) {
|
||||
const session = sessionID ? api.state.session.get(sessionID) : undefined
|
||||
const isSubagent = session?.parentID !== undefined
|
||||
void api.attention.notify({
|
||||
title: session?.title,
|
||||
title: title ?? session?.title,
|
||||
message,
|
||||
notification: isSubagent ? false : { when: "blurred" },
|
||||
sound: { name: sound, when: "always" },
|
||||
|
|
@ -34,10 +40,15 @@ const tui: TuiPlugin = async (api) => {
|
|||
const permissions = new Set<string>()
|
||||
|
||||
api.event.on("form.created", (event) => {
|
||||
if (event.data.form.sessionID === "global") return
|
||||
if (forms.has(event.data.form.id)) return
|
||||
forms.add(event.data.form.id)
|
||||
notify(api, event.data.form.sessionID, "Input needs response", "question")
|
||||
notify(
|
||||
api,
|
||||
event.data.form.sessionID,
|
||||
"Input needs response",
|
||||
"question",
|
||||
event.data.form.title,
|
||||
)
|
||||
})
|
||||
|
||||
api.event.on("form.replied", (event) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue