|
@@ -1,4 +1,4 @@
|
|
|
-import { For, Show, createEffect, createMemo, on, onCleanup, onMount, untrack } from "solid-js"
|
|
|
|
|
|
|
+import { For, Show, createEffect, createMemo, createSignal, on, onCleanup, onMount, untrack } from "solid-js"
|
|
|
import { createStore } from "solid-js/store"
|
|
import { createStore } from "solid-js/store"
|
|
|
import { Portal } from "solid-js/web"
|
|
import { Portal } from "solid-js/web"
|
|
|
import { ResearchReport } from "./report"
|
|
import { ResearchReport } from "./report"
|
|
@@ -35,6 +35,8 @@ import {
|
|
|
import { createMaterials } from "./materials"
|
|
import { createMaterials } from "./materials"
|
|
|
import { PaasGeneratedFiles } from "./generated-files"
|
|
import { PaasGeneratedFiles } from "./generated-files"
|
|
|
import type { PaasPreviewFile } from "./preview"
|
|
import type { PaasPreviewFile } from "./preview"
|
|
|
|
|
+import { buildProjectInbox, type InboxItem } from "./inbox"
|
|
|
|
|
+import { inboxSeenKey, markInboxSeen, readInboxSeen } from "./inbox-seen"
|
|
|
|
|
|
|
|
export function PaasChat(props: {
|
|
export function PaasChat(props: {
|
|
|
api?: PaasPlatform
|
|
api?: PaasPlatform
|
|
@@ -45,6 +47,7 @@ export function PaasChat(props: {
|
|
|
projectID: string
|
|
projectID: string
|
|
|
workspace?: string
|
|
workspace?: string
|
|
|
agents: Record<string, unknown>[]
|
|
agents: Record<string, unknown>[]
|
|
|
|
|
+ inboxTasks: () => Record<string, unknown>[]
|
|
|
openAgentID: string
|
|
openAgentID: string
|
|
|
onAgentOpened: () => void
|
|
onAgentOpened: () => void
|
|
|
onOpenAgentPacks: () => void
|
|
onOpenAgentPacks: () => void
|
|
@@ -122,6 +125,34 @@ export function PaasChat(props: {
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
const { state, setState, current } = model
|
|
const { state, setState, current } = model
|
|
|
|
|
+ const [seenVersion, setSeenVersion] = createSignal(0)
|
|
|
|
|
+ const seenKey = createMemo(() =>
|
|
|
|
|
+ inboxSeenKey(props.scope || "local", platform.windowID || "main", props.projectID),
|
|
|
|
|
+ )
|
|
|
|
|
+ const seen = createMemo(() => {
|
|
|
|
|
+ seenVersion()
|
|
|
|
|
+ return readInboxSeen(localStorage, seenKey())
|
|
|
|
|
+ })
|
|
|
|
|
+ const inbox = createMemo(() =>
|
|
|
|
|
+ buildProjectInbox({
|
|
|
|
|
+ projectID: props.projectID,
|
|
|
|
|
+ chats: state.chats,
|
|
|
|
|
+ tasks: props.inboxTasks(),
|
|
|
|
|
+ seen: seen(),
|
|
|
|
|
+ }),
|
|
|
|
|
+ )
|
|
|
|
|
+ const openInboxItem = (item: InboxItem) => {
|
|
|
|
|
+ model.activate(item.chatID)
|
|
|
|
|
+ props.onShowChat?.()
|
|
|
|
|
+ // Approvals and failures stay actionable, so only completed results are marked seen.
|
|
|
|
|
+ if (item.kind !== "unread") return
|
|
|
|
|
+ try {
|
|
|
|
|
+ markInboxSeen(localStorage, seenKey(), item.id)
|
|
|
|
|
+ setSeenVersion((value) => value + 1)
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ // Storage can be unavailable in restricted webviews; keep the item until the session ends.
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
const currentAgent = createMemo(() => props.agents.find((agent) => agent.id === current()?.agentID))
|
|
const currentAgent = createMemo(() => props.agents.find((agent) => agent.id === current()?.agentID))
|
|
|
const blank = () => !!current() && !current()!.messages.length && !current()!.threadID
|
|
const blank = () => !!current() && !current()!.messages.length && !current()!.threadID
|
|
|
const routed = createMemo(() =>
|
|
const routed = createMemo(() =>
|