🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
✨ feat(channel): show a direct Channel's reply activity on its list row (#22580)
Arvin Xub1d233f2b767
diff --git a/packages/database/src/repositories/channel/__tests__/identity.test.ts b/packages/database/src/repositories/channel/__tests__/identity.test.tsindex 2f529d416f0..131b81fd652 100644--- a/packages/database/src/repositories/channel/__tests__/identity.test.ts+++ b/packages/database/src/repositories/channel/__tests__/identity.test.ts@@ -72,6 +72,39 @@ describe('direct Channel identity', () => {});});+ // A list row only knew a reply was in progress once its conversation was opened.+ it('lists the main-conversation replies still pending', async () => {+ const agent = await createAgent();+ const repository = new ChannelRepository(db, fixture.ownerId, fixture.workspaceId);+ const { channel } = await repository.create({ agentId: agent.id, title: 'Direct' });+ const replyJobs = async () =>+ (await repository.list()).find((item) => item.id === channel.id)?.replyJobs;+ expect(await replyJobs()).toEqual([]);++ const message = await repository.send(channel.id, sendInput);+ const [job] = await jobsOf(db, message.id);+ expect(await replyJobs()).toEqual([+ {+ blockedCode: null,+ id: job.id,+ memberId: job.memberId,+ publicationRevoked: false,+ status: 'queued',+ threadId: null,+ writerHeld: false,+ },+ ]);++ await execution.claim(channel.id, job.id, lease);+ expect(await replyJobs()).toMatchObject([{ id: job.id, status: 'running', writerHeld: true }]);++ await execution.accepted(channel.id, job.id);+ await execution.saveDraft(channel.id, job.id, 'Answer');+ await execution.publish(channel.id, job.id);+ await execution.releaseWriter(channel.id, job.id);+ expect(await replyJobs()).toEqual([]);+ });+it.each([null, fixture.workspaceId])('creates a private user/Agent conversation in scope %s',async (workspaceId) => {diff --git a/packages/database/src/repositories/channel/index.ts b/packages/database/src/repositories/channel/index.tsindex 05bb7f638b6..6dc4e6d88f4 100644--- a/packages/database/src/repositories/channel/index.ts+++ b/packages/database/src/repositories/channel/index.ts@@ -1,4 +1,9 @@-import type { ChannelMemberConfig, ChannelMemberRole, ChannelVisibility } from '@lobechat/types';+import type {+ ChannelMemberConfig,+ ChannelMemberRole,+ ChannelReplyJob,+ ChannelVisibility,+} from '@lobechat/types';import { and, desc, eq, inArray, isNull, or, sql } from 'drizzle-orm';import { TrashModel } from '../../models/trash';@@ -411,6 +416,7 @@ export class ChannelRepository {ChannelItem & {canDelete: boolean;lastMessage: { content: string; createdAt: Date } | null;+ replyJobs: ChannelReplyJob[];unreadCount: number;}>@@ -450,10 +456,51 @@ export class ChannelRepository {latest.map(({ channelId, ...message }) => [channelId, message] as const),);+ // Main-conversation replies the list row shows as in progress: ones that can still publish,+ // and stopped ones whose writer has not exited yet.+ const pending = rows.length+ ? await this.db+ .select({+ blockedCode: channelJobs.blockedCode,+ channelId: channelJobs.channelId,+ id: channelJobs.id,+ memberId: channelJobs.memberId,+ publicationRevoked: channelJobs.publicationRevoked,+ status: channelJobs.status,+ threadId: channelJobs.threadId,+ writerHeld: channelJobs.writerHeld,+ })+ .from(channelJobs)+ .where(+ and(+ inArray(+ channelJobs.channelId,+ rows.map(({ channel }) => channel.id),+ ),+ isNull(channelJobs.threadId),+ or(+ and(+ eq(channelJobs.publicationRevoked, false),+ inArray(channelJobs.status, ['queued', 'running']),+ ),+ and(eq(channelJobs.publicationRevoked, true), eq(channelJobs.writerHeld, true)),+ ),+ ),+ )+ .orderBy(desc(channelJobs.createdAt))+ : [];+ const replyJobsOf = new Map<string, ChannelReplyJob[]>();+ for (const { channelId, ...job } of pending) {+ const jobs = replyJobsOf.get(channelId) ?? [];+ jobs.push(job);+ replyJobsOf.set(channelId, jobs);+ }+return rows.map(({ channel, lastReadSequence, role }) => ({...channel,canDelete: hasRole(role, 'admin'),lastMessage: lastMessageOf.get(channel.id) ?? null,+ replyJobs: replyJobsOf.get(channel.id) ?? [],unreadCount: Math.max(0, channel.sequence - (lastReadSequence ?? 0)),}));};diff --git a/packages/types/src/channel.ts b/packages/types/src/channel.tsindex ff524144dda..59af797b84b 100644--- a/packages/types/src/channel.ts+++ b/packages/types/src/channel.ts@@ -301,6 +301,11 @@ export interface ChannelListItem {lastMessage?: { content: string; createdAt: Date } | null;/** The project the channel is grouped under; null for a standalone channel. */projectId: string | null;+ /**+ * Main-conversation replies still pending (queued, running, or stopping), so a list row can+ * show them without loading the conversation; set by the Channel list.+ */+ replyJobs?: ChannelReplyJob[];sequence: number;status: ChannelStatus;title: string;@@ -370,6 +375,12 @@ export interface ChannelPublicJob {writerHeld: boolean;}+/** A pending reply in the fields its status is derived from. */+export type ChannelReplyJob = Pick<+ ChannelPublicJob,+ 'blockedCode' | 'id' | 'memberId' | 'publicationRevoked' | 'status' | 'threadId' | 'writerHeld'+>;+export interface ChannelPublicThread {followerMemberIds: string[];id: string;diff --git a/src/features/Channels/jobStatus.test.ts b/src/features/Channels/jobStatus.test.tsindex df920bd3f4d..d53616c5ee3 100644--- a/src/features/Channels/jobStatus.test.ts+++ b/src/features/Channels/jobStatus.test.ts@@ -4,9 +4,11 @@ import { describe, expect, it } from 'vitest';import {channelJobStatus,channelJobTone,+ directAvatarState,directReplyStatus,memberCurrentJob,replyActivityJobs,+ replyAvatarState,unresolvedFailures,} from './jobStatus';@@ -174,3 +176,68 @@ describe('directReplyStatus', () => {expect(directReplyStatus(detail([job({ status: 'completed' })]))).toBeNull();});});++describe('directAvatarState', () => {+ const job = (patch: Partial<ChannelPublicJob> = {}) =>+ ({+ id: 'job_1',+ memberId: 'mem_cook',+ publicationRevoked: false,+ status: 'running',+ threadId: null,+ writerHeld: false,+ ...patch,+ }) as ChannelPublicJob;+ const detail = (jobs: ChannelPublicJob[], messages: unknown[] = []) =>+ ({ channel: { agentId: 'agt_cook', id: 'chn_cook' }, jobs, members: [], messages }) as never;++ it('works while the Agent writes its reply', () => {+ expect(directAvatarState(detail([job()]))).toBe('working');+ });++ it('thinks while a message is routed or the reply is prepared', () => {+ expect(directAvatarState(detail([], [{ routingStatus: 'pending' }]))).toBe('thinking');+ expect(directAvatarState(detail([job({ blockedCode: undefined, status: 'queued' })]))).toBe(+ 'thinking',+ );+ });++ it('waits when the reply is blocked or stopping', () => {+ expect(+ directAvatarState(detail([job({ blockedCode: 'device_offline', status: 'queued' })])),+ ).toBe('waiting');+ expect(+ directAvatarState(+ detail([job({ publicationRevoked: true, status: 'cancelled', writerHeld: true })]),+ ),+ ).toBe('waiting');+ });++ it('stays idle once the conversation settles', () => {+ expect(directAvatarState(detail([job({ status: 'completed' })]))).toBeUndefined();+ expect(directAvatarState(detail([job({ threadId: 'thr_1' })]))).toBeUndefined();+ });+});++describe('replyAvatarState', () => {+ const job = (patch: Partial<ChannelPublicJob> = {}) =>+ ({+ blockedCode: null,+ id: 'job_1',+ memberId: 'mem_cook',+ publicationRevoked: false,+ status: 'running',+ threadId: null,+ writerHeld: true,+ ...patch,+ }) as ChannelPublicJob;++ it('prefers the running reply over a queued one of the same Agent', () => {+ expect(replyAvatarState([job({ id: 'next', status: 'queued' }), job()])).toBe('working');+ });++ it('ignores settled replies and stays idle without any', () => {+ expect(replyAvatarState([job({ status: 'failed', writerHeld: false })])).toBeUndefined();+ expect(replyAvatarState([])).toBeUndefined();+ });+});diff --git a/src/features/Channels/jobStatus.ts b/src/features/Channels/jobStatus.tsindex 7ff872eb6b3..9b7a82c6dde 100644--- a/src/features/Channels/jobStatus.ts+++ b/src/features/Channels/jobStatus.ts@@ -1,6 +1,7 @@-import type { ChannelDetail, ChannelPublicJob } from '@lobechat/types';+import type { ChannelDetail, ChannelReplyJob } from '@lobechat/types';+import type { AgentAvatarState } from '@lobehub/ui';-export const channelJobStatus = (job: ChannelPublicJob) =>+export const channelJobStatus = (job: ChannelReplyJob) =>job.publicationRevoked && job.writerHeld? 'status.stopping': job.status === 'queued'@@ -12,7 +13,7 @@ export const channelJobStatus = (job: ChannelPublicJob) =>/** Colour family of a status: working blue, attention amber, error red, settled grey. */export type ChannelStatusTone = 'attention' | 'done' | 'error' | 'quiet' | 'working';-export const channelJobTone = (job: ChannelPublicJob): ChannelStatusTone => {+export const channelJobTone = (job: ChannelReplyJob): ChannelStatusTone => {if (job.status === 'failed') return 'error';if (job.publicationRevoked) return job.writerHeld ? 'attention' : 'quiet';if (job.status === 'queued') return job.blockedCode ? 'attention' : 'working';@@ -22,18 +23,18 @@ export const channelJobTone = (job: ChannelPublicJob): ChannelStatusTone => {};/** Still able to publish a reply, so the user can stop it. */-export const isChannelJobActive = (job: ChannelPublicJob) =>+export const isChannelJobActive = (job: ChannelReplyJob) =>!job.publicationRevoked && (job.status === 'queued' || job.status === 'running');/** Work the conversation is still waiting on: shown above the composer, not on messages. */-export const replyActivityJobs = (jobs: ChannelPublicJob[]) =>+export const replyActivityJobs = <T extends ChannelReplyJob>(jobs: T[]) =>jobs.filter((job) => isChannelJobActive(job) || (job.publicationRevoked && job.writerHeld));/*** Each member's newest job when it failed. A later reply, stop or retry by the same member* settles the failure, so the header does not stay red forever. Jobs arrive newest first.*/-export const unresolvedFailures = (jobs: ChannelPublicJob[]) => {+export const unresolvedFailures = <T extends ChannelReplyJob>(jobs: T[]) => {const seen = new Set<string>();return jobs.filter((job) => {if (seen.has(job.memberId)) return false;@@ -43,7 +44,7 @@ export const unresolvedFailures = (jobs: ChannelPublicJob[]) => {};/** What a member is busy with now: a running reply first, then the next queued one. */-export const memberCurrentJob = (jobs: ChannelPublicJob[], memberId: string) => {+export const memberCurrentJob = <T extends ChannelReplyJob>(jobs: T[], memberId: string) => {const own = jobs.filter((job) => job.memberId === memberId);return (own.find((job) => isChannelJobActive(job) && job.status === 'running') ??@@ -72,3 +73,25 @@ export const directReplyStatus = (detail: ChannelDetail) => {if (!job) return receiving ? { jobs } : null;return channelJobTone(job) === 'working' ? { jobs } : { jobs, waiting: job };};++/**+ * How a direct conversation's Agent avatar acts out its pending replies: `working` while it+ * writes, `thinking` while a message is routed or the reply is prepared, `waiting` when blocked+ * or stopping. Undefined when nothing is pending, so the avatar stays idle.+ */+export const replyAvatarState = (+ jobs: ChannelReplyJob[],+ receiving = false,+): AgentAvatarState | undefined => {+ const pending = replyActivityJobs(jobs);+ const job = pending[0] && memberCurrentJob(pending, pending[0].memberId);+ if (!job) return receiving ? 'thinking' : undefined;+ if (channelJobTone(job) !== 'working') return 'waiting';+ return job.status === 'running' ? 'working' : 'thinking';+};++/** The avatar state of a loaded direct conversation; see `replyAvatarState`. */+export const directAvatarState = (detail: ChannelDetail) => {+ const { jobs, receiving } = conversationReplies(detail, null);+ return replyAvatarState(jobs, receiving);+};diff --git a/src/features/MessageList/AgentConversation.test.tsx b/src/features/MessageList/AgentConversation.test.tsxindex 470d06c5c9c..292b8c8125f 100644--- a/src/features/MessageList/AgentConversation.test.tsx+++ b/src/features/MessageList/AgentConversation.test.tsx@@ -5,12 +5,28 @@ import { render, screen } from '@testing-library/react';import { createElement } from 'react';import { describe, expect, it, vi } from 'vitest';+import { useChannelStore } from '@/store/channel';+import AgentConversation from './AgentConversation';vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));vi.mock('@/components/AgentAvatar', () => ({- default: ({ agentId, avatar }: { agentId: string; avatar?: string }) =>- createElement('span', { 'data-testid': 'agent-avatar' }, `${agentId}:${avatar ?? 'generated'}`),+ default: ({+ agentId,+ animated,+ avatar,+ state,+ }: {+ agentId: string;+ animated?: boolean;+ avatar?: string;+ state?: string;+ }) =>+ createElement(+ 'span',+ { 'data-animated': String(!!animated), 'data-state': state, 'data-testid': 'agent-avatar' },+ `${agentId}:${avatar ?? 'generated'}`,+ ),}));vi.mock('@/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu', () => ({// An Agent's own menu ends with its Delete; the row must not clash with it.@@ -41,10 +57,10 @@ vi.mock('./useAgentConversationLink', () => ({useAgentConversationLink: (_: string, url: string) => ({ url }),}));vi.mock('./ConversationRow', () => ({- default: ({ avatar, contextMenuItems, title }: any) =>+ default: ({ avatar, contextMenuItems, running, title }: any) =>createElement('div',- {},+ { 'data-running': String(!!running), 'data-testid': 'row' },title,avatar as never,createElement(@@ -108,3 +124,85 @@ describe('AgentConversation avatar', () => {expect(screen.getByTestId('menu')).not.toHaveTextContent('channel-');});});++describe('AgentConversation reply activity', () => {+ const showReply = (job: Record<string, unknown>) =>+ useChannelStore.setState({+ detailMap: {+ 'cht_cook:main:latest': {+ channel: { agentId: 'agt_cook', id: 'cht_cook' },+ jobs: [+ {+ id: 'job_1',+ memberId: 'mem_cook',+ publicationRevoked: false,+ threadId: null,+ writerHeld: false,+ ...job,+ },+ ],+ members: [],+ messages: [],+ },+ } as never,+ });++ // The header said "typing" while the row and its avatar stayed idle: the row only read chat+ // operations, and a direct Channel replies through Channel jobs.+ it('animates the avatar while the direct Channel replies, keeping the row preview', () => {+ showReply({ status: 'running' });+ render(+ createElement(AgentConversation, { active: true, conversation: conversation(undefined, {}) }),+ );++ expect(screen.getByTestId('agent-avatar')).toHaveAttribute('data-state', 'working');+ expect(screen.getByTestId('agent-avatar')).toHaveAttribute('data-animated', 'true');+ expect(screen.getByTestId('row')).toHaveAttribute('data-running', 'false');+ });++ it('shows a blocked reply as waiting', () => {+ showReply({ blockedCode: 'device_offline', status: 'queued' });+ render(+ createElement(AgentConversation, { active: true, conversation: conversation(undefined, {}) }),+ );++ expect(screen.getByTestId('agent-avatar')).toHaveAttribute('data-state', 'waiting');+ expect(screen.getByTestId('row')).toHaveAttribute('data-running', 'false');+ });++ it('stays idle once the reply settles', () => {+ showReply({ status: 'completed' });+ render(+ createElement(AgentConversation, { active: true, conversation: conversation(undefined, {}) }),+ );++ expect(screen.getByTestId('agent-avatar')).not.toHaveAttribute('data-state');+ expect(screen.getByTestId('agent-avatar')).toHaveAttribute('data-animated', 'false');+ });++ // A row whose conversation is not open used to stay idle; it now reads the list's jobs.+ it('reads a background row’s reply from the list instead of a cached view', () => {+ showReply({ status: 'completed' });+ render(+ createElement(AgentConversation, {+ active: false,+ conversation: conversation(undefined, {+ replyJobs: [+ {+ blockedCode: null,+ id: 'job_2',+ memberId: 'mem_cook',+ publicationRevoked: false,+ status: 'running',+ threadId: null,+ writerHeld: true,+ },+ ],+ } as never),+ }),+ );++ expect(screen.getByTestId('agent-avatar')).toHaveAttribute('data-state', 'working');+ expect(screen.getByTestId('row')).toHaveAttribute('data-running', 'false');+ });+});diff --git a/src/features/MessageList/AgentConversation.tsx b/src/features/MessageList/AgentConversation.tsxindex 88271129187..a0f6981a264 100644--- a/src/features/MessageList/AgentConversation.tsx+++ b/src/features/MessageList/AgentConversation.tsx@@ -6,11 +6,13 @@ import { memo, useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';import AgentAvatar from '@/components/AgentAvatar';+import { directAvatarState, replyAvatarState } from '@/features/Channels/jobStatus';import { useChannelMenu } from '@/features/Channels/useChannelMenu';import { useAgentDropdownMenu } from '@/features/HomeSidebar/Body/Agent/List/AgentItem/useDropdownMenu';import { usePreservedAgentUrl } from '@/features/HomeSidebar/Body/Agent/List/usePreservedAgentUrl';import { useAgentModal } from '@/features/HomeSidebar/Body/Agent/ModalProvider';import { usePrefetchAgent } from '@/hooks/usePrefetchAgent';+import { channelSelectors, useChannelStore } from '@/store/channel';import { useChatStore } from '@/store/chat';import { operationSelectors } from '@/store/chat/selectors';@@ -47,11 +49,22 @@ const AgentConversation = memo<AgentConversationProps>(({ active, conversation }const { t } = useTranslation('chat');const { openCreateGroupModal } = useAgentModal();const prefetchAgent = usePrefetchAgent();- const running = useChatStore(operationSelectors.isAgentVisiblyRunning(id));+ const chatRunning = useChatStore(operationSelectors.isAgentVisiblyRunning(id));const agentUrl = usePreservedAgentUrl(id);const { onClick, url } = useAgentConversationLink(id, agentUrl);const channelMenu = useChannelMenu();const directChannel = conversation.channel;+ // A direct Channel replies through Channel jobs, not chat operations. The open conversation's+ // view is polled while it works, so it is fresher than the list; any other cached view may be+ // stale, so other rows read the jobs the list carries.+ const replyState = useChannelStore((s) => {+ if (!directChannel) return;+ const detail = active+ ? channelSelectors.detail({ channelId: directChannel.id, threadId: null })(s)+ : undefined;+ return detail ? directAvatarState(detail) : replyAvatarState(directChannel.replyJobs ?? []);+ });+ const avatarState = replyState ?? (chatRunning ? 'working' : undefined);const title = agentDisplayName(item, t('untitledAgent'));const avatarSrc = typeof avatar === 'string' ? avatar : undefined;@@ -94,7 +107,7 @@ const AgentConversation = memo<AgentConversationProps>(({ active, conversation }activeAt={activeAt}contextMenuItems={menuItems}preview={preview}- running={running}+ running={chatRunning}title={title}unread={conversation.unread ?? item.unreadCount}url={url}@@ -103,10 +116,12 @@ const AgentConversation = memo<AgentConversationProps>(({ active, conversation }// image or emoji, else the character generated from its id.<AgentAvataragentId={id}+ animated={!!avatarState}avatar={avatarSrc}background={backgroundColor || undefined}name={title}size={AVATAR_SIZE}+ state={avatarState}/>}onClick={onClick}diff --git a/src/store/channel/action.polling.test.ts b/src/store/channel/action.polling.test.tsindex f8afa7940d2..6f40db036d7 100644--- a/src/store/channel/action.polling.test.ts+++ b/src/store/channel/action.polling.test.ts@@ -213,4 +213,34 @@ describe('Channel in-progress refresh without gateway notifications', () => {await tick(5000);expect(channelService.detail).not.toHaveBeenCalled();});++ // A row showed a background reply as working for up to a minute after it ended.+ it('refreshes the list quickly while a listed reply is in progress, then slows down', async () => {+ const listed = (replyJobs: ChannelPublicJob[]) => [{ ...response.channel, replyJobs }];+ vi.mocked(channelService.list).mockResolvedValue(listed([job()]));+ renderHook(() => channelActions.useFetchList(), { wrapper });+ await tick(0);++ vi.mocked(channelService.list).mockResolvedValue(listed([]));+ await tick(CHANNEL_ACTIVE_REFRESH_MS);+ expect(useChannelStore.getState().listMap.all?.[0].replyJobs).toEqual([]);++ const calls = vi.mocked(channelService.list).mock.calls.length;+ await tick(5000);+ expect(channelService.list).toHaveBeenCalledTimes(calls);+ });++ it('does not fast-poll the list for a reply blocked on a device', async () => {+ vi.mocked(channelService.list).mockResolvedValue([+ {+ ...response.channel,+ replyJobs: [job({ blockedCode: 'device_offline', status: 'queued', writerHeld: false })],+ },+ ]);+ renderHook(() => channelActions.useFetchList(), { wrapper });+ await tick(0);+ const calls = vi.mocked(channelService.list).mock.calls.length;+ await tick(5000);+ expect(channelService.list).toHaveBeenCalledTimes(calls);+ });});diff --git a/src/store/channel/action.ts b/src/store/channel/action.tsindex 290f7f0e7a4..4f3268a1a98 100644--- a/src/store/channel/action.ts+++ b/src/store/channel/action.ts@@ -28,7 +28,8 @@ import { initialState, useChannelStore } from './store';/*** Gateway push is not delivered yet, so polling is the only refresh: views with work in- * progress refresh every few seconds, idle views and the list once a minute.+ * progress (and the list while a listed reply is) refresh every few seconds, idle ones once a+ * minute.*/export const CHANNEL_ACTIVE_REFRESH_MS = 3000;export const CHANNEL_IDLE_REFRESH_MS = 60_000;@@ -47,7 +48,13 @@ class ChannelActionImpl {useClientDataSWR(channelKeys.userCandidates(channelId, search), () =>channelService.userCandidates(channelId, search),);- useFetchList = () => this.#private.list.useSync({}, { refreshInterval: CHANNEL_IDLE_REFRESH_MS });+ useFetchList = () => {+ const pending = useChannelStore(channelSelectors.listHasPendingWork);+ return this.#private.list.useSync(+ {},+ { refreshInterval: pending ? CHANNEL_ACTIVE_REFRESH_MS : CHANNEL_IDLE_REFRESH_MS },+ );+ };useFetchDetail = (params: ChannelViewParams | null) => {// Subscribe to the replica, not just SWR's last response: sending a message// updates this view imperatively and must shorten an already scheduled idle poll.diff --git a/src/store/channel/selectors.ts b/src/store/channel/selectors.tsindex 11442f08d61..80ecc6d563e 100644--- a/src/store/channel/selectors.ts+++ b/src/store/channel/selectors.ts@@ -1,4 +1,4 @@-import type { ChannelJobBlockCode } from '@lobechat/types';+import type { ChannelJobBlockCode, ChannelReplyJob } from '@lobechat/types';import type { ChannelViewParams } from '@/services/channel';@@ -17,6 +17,13 @@ const EXTERNAL_BLOCKS = new Set<ChannelJobBlockCode>(['workspace_changed',]);+/** Still progressing on its own, so a view showing it must refresh soon. */+const isProgressing = (job: ChannelReplyJob) =>+ job.writerHeld ||+ (!job.publicationRevoked &&+ ((job.status === 'queued' && !(job.blockedCode && EXTERNAL_BLOCKS.has(job.blockedCode))) ||+ job.status === 'running'));+export const channelSelectors = {detail: (params: ChannelViewParams) => (state: ChannelState) =>state.detailMap[channelViewKey(params)],@@ -30,13 +37,7 @@ export const channelSelectors = {return (detail.messages.some((message) => message.routingStatus === 'pending') ||detail.jobs.some(- (job) =>- (job.threadId ?? null) === (params?.threadId ?? null) &&- (job.writerHeld ||- (!job.publicationRevoked &&- ((job.status === 'queued' &&- !(job.blockedCode && EXTERNAL_BLOCKS.has(job.blockedCode))) ||- job.status === 'running'))),+ (job) => (job.threadId ?? null) === (params?.threadId ?? null) && isProgressing(job),));},@@ -44,6 +45,9 @@ export const channelSelectors = {directByAgent: (agentId: string) => (state: ChannelState) =>state.listMap.all?.find((channel) => channel.agentId === agentId && !channel.projectId),list: (state: ChannelState) => state.listMap.all,+ /** A listed conversation has a reply in progress, which its row shows until it settles. */+ listHasPendingWork: (state: ChannelState) =>+ !!state.listMap.all?.some((channel) => channel.replyJobs?.some(isProgressing)),/** This tab's messages for one conversation that its loaded pages do not hold yet. */outgoing: (channelId: string, threadId?: string | null) => (state: ChannelState) =>state.outbox[channelOutboxKey(channelId, threadId)] ?? NO_OUTGOING,