🤯 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
🐛 fix(artboard): reload the open board in place when an agent outside the chat bumps its revision (#23605)
Inneibece188334c5
diff --git a/locales/en-US/project.json b/locales/en-US/project.jsonindex 7efa29399a2..dd8b57576c0 100644--- a/locales/en-US/project.json+++ b/locales/en-US/project.json@@ -135,8 +135,6 @@"artboard.share.unpublishFailed": "Couldn’t stop sharing. Try again.","artboard.share.unpublished": "Sharing stopped","artboard.share.update": "Update share",- "artboard.stale.refresh": "Refresh",- "artboard.stale.title": "This board has a newer version","artboard.submit.action": "Submit to agent","artboard.submit.allPicked": "{{picked}} picked","artboard.submit.commentMessage_one": "Left {{count}} comment on the artboard.",diff --git a/locales/zh-CN/project.json b/locales/zh-CN/project.jsonindex 8bad495a7d8..78b7097d2da 100644--- a/locales/zh-CN/project.json+++ b/locales/zh-CN/project.json@@ -135,8 +135,6 @@"artboard.share.unpublishFailed": "停止分享失败,请重试","artboard.share.unpublished": "已停止分享","artboard.share.update": "更新分享",- "artboard.stale.refresh": "刷新",- "artboard.stale.title": "画板已有新版本","artboard.submit.action": "提交给 agent","artboard.submit.allPicked": "已选 {{picked}} 个","artboard.submit.commentMessage_one": "在画板上留了 {{count}} 条评论。",diff --git a/packages/locales/src/default/project.ts b/packages/locales/src/default/project.tsindex 4d2fb6524d7..2865621399e 100644--- a/packages/locales/src/default/project.ts+++ b/packages/locales/src/default/project.ts@@ -627,8 +627,6 @@ export default {'artboard.fullscreen.placeholder': 'The board is open full screen','artboard.header.exitFullscreen': 'Back to panel','artboard.header.fullscreen': 'Full screen',- 'artboard.stale.refresh': 'Refresh',- 'artboard.stale.title': 'This board has a newer version','artboard.gallery.openConversation': 'Open conversation','artboard.finalize.pending.goChoose': 'Go to the choice','artboard.finalize.pending.goAnswer': 'Answer',diff --git a/src/features/Artboard/Board/StaleBanner.tsx b/src/features/Artboard/Board/StaleBanner.tsxdeleted file mode 100644index 116f3eca471..00000000000--- a/src/features/Artboard/Board/StaleBanner.tsx+++ /dev/null@@ -1,62 +0,0 @@-import { Button, Flexbox, Icon, Text } from '@lobehub/ui';-import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';-import * as stylex from '@stylexjs/stylex';-import { RefreshCwIcon } from 'lucide-react';-import { useState } from 'react';-import { useTranslation } from 'react-i18next';--import { useBoard } from '../BoardContext';-import { refreshStaleArtboard } from '../data/revisionWatch';-import { useArtboardStore } from '../store';--const styles = stylex.create({- bar: {- backgroundColor: cssVar.colorInfoBg,- borderBlockEndColor: cssVar.colorInfoBorder,- borderBlockEndStyle: 'solid',- borderBlockEndWidth: 1,- flex: 'none',- paddingBlock: 4,- paddingInline: 12,- },-});--const StaleBanner = () => {- const { t } = useTranslation('project');- const board = useBoard();- const stale = useArtboardStore((s) => s.staleRevision);- const [loading, setLoading] = useState(false);- if (stale === null) return null;-- const refresh = async () => {- setLoading(true);- try {- await refreshStaleArtboard(board.artboard.id);- } finally {- setLoading(false);- }- };-- return (- <Flexbox- horizontal- align="center"- gap={8}- justify="space-between"- {...stylex.props(styles.bar)}- >- <Text style={{ fontSize: 13 }}>{t('artboard.stale.title')}</Text>- <Button- icon={<Icon icon={RefreshCwIcon} />}- loading={loading}- size={'small'}- type={'link'}- onClick={refresh}- >- {t('artboard.stale.refresh')}- </Button>- </Flexbox>- );-};--export default StaleBanner;diff --git a/src/features/Artboard/Board/index.tsx b/src/features/Artboard/Board/index.tsxindex a338eaa3f54..05ca3d692a0 100644--- a/src/features/Artboard/Board/index.tsx+++ b/src/features/Artboard/Board/index.tsx@@ -18,7 +18,6 @@ import VerifyPanel from '../Verify';import CheckTable from '../Verify/CheckTable';import Header from './Header';import Outline from './Outline';-import StaleBanner from './StaleBanner';import { BoardEmpty, BoardError, BoardLoading } from './States';import SubmitBar from './SubmitBar';@@ -131,7 +130,6 @@ const BoardLayout = ({ onClose, onExitFullscreen }: BoardLayoutProps) => {return (<Flexbox data-artboard-root flex={1} height={'100%'} ref={rootRef} style={{ minWidth: 0 }}><Header narrow={narrow} onClose={onClose} onExitFullscreen={onExitFullscreen} />- <StaleBanner /><div {...stylex.props(styles.body)}><Stage narrow={narrow} />{mode === 'verify' && (diff --git a/src/features/Artboard/data/revisionWatch.test.ts b/src/features/Artboard/data/revisionWatch.test.tsindex bb92a18c490..2a3cfabb96a 100644--- a/src/features/Artboard/data/revisionWatch.test.ts+++ b/src/features/Artboard/data/revisionWatch.test.ts@@ -1,7 +1,7 @@import { afterEach, describe, expect, it, vi } from 'vitest';-import { artboardActions, useArtboardStore } from '../store';-import { checkArtboardRevision, refreshStaleArtboard } from './revisionWatch';+import { artboardActions } from '../store';+import { checkArtboardRevision } from './revisionWatch';const { getRevision, mutate } = vi.hoisted(() => ({ getRevision: vi.fn(), mutate: vi.fn() }));vi.mock('@/libs/swr', () => ({ mutate, useClientDataSWR: vi.fn() }));@@ -15,14 +15,13 @@ describe('artboard revision watch', () => {vi.clearAllMocks();});- it('flags the open board stale when the server has a newer revision', async () => {+ it('reloads the open board in place when the server has a newer revision', async () => {artboardActions.bindBoard('art_1');getRevision.mockResolvedValue({ revision: 5, updatedAt: new Date('2026-11-18T11:00:00Z') });await checkArtboardRevision('art_1', shown);- expect(useArtboardStore.getState().staleRevision).toBe(5);- expect(mutate).not.toHaveBeenCalled();+ expect(mutate).toHaveBeenCalledWith(['artboard', 'art_1']);});it('stays quiet when the board already shows the latest revision', async () => {@@ -31,7 +30,6 @@ describe('artboard revision watch', () => {await checkArtboardRevision('art_1', shown);- expect(useArtboardStore.getState().staleRevision).toBeNull();expect(mutate).not.toHaveBeenCalled();});@@ -41,7 +39,6 @@ describe('artboard revision watch', () => {await checkArtboardRevision('art_1', shown);- expect(useArtboardStore.getState().staleRevision).toBeNull();expect(mutate).toHaveBeenCalledWith(['artboard', 'art_1']);});@@ -54,18 +51,6 @@ describe('artboard revision watch', () => {await checkArtboardRevision('art_1', shown);- expect(useArtboardStore.getState().staleRevision).toBeNull();expect(mutate).not.toHaveBeenCalled();});-- it('reloads the board and clears the banner on refresh', async () => {- artboardActions.bindBoard('art_1');- getRevision.mockResolvedValue({ revision: 5, updatedAt: new Date('2026-11-18T11:00:00Z') });- await checkArtboardRevision('art_1', shown);-- await refreshStaleArtboard('art_1');-- expect(mutate).toHaveBeenCalled();- expect(useArtboardStore.getState().staleRevision).toBeNull();- });});diff --git a/src/features/Artboard/data/revisionWatch.ts b/src/features/Artboard/data/revisionWatch.tsindex 459871abd07..43f82e858c6 100644--- a/src/features/Artboard/data/revisionWatch.ts+++ b/src/features/Artboard/data/revisionWatch.ts@@ -2,7 +2,7 @@ import type { ArtboardItem } from '@lobechat/types';import { artboardService } from '@/services/artboard';-import { artboardActions, useArtboardStore } from '../store';+import { useArtboardStore } from '../store';import { mutateArtboard } from './useArtboard';export const checkArtboardRevision = async (@@ -11,18 +11,7 @@ export const checkArtboardRevision = async () => {const latest = await artboardService.getRevision(id);if (useArtboardStore.getState().boardId !== id) return;- if (latest.revision > shown.revision) {- artboardActions.setStaleRevision(latest.revision);- return;- }- artboardActions.setStaleRevision(null);- // Same structure, newer row: only files changed (a CLI push, another tab). Nothing on screen- // can conflict with a file, so reload in place instead of asking.- if (new Date(latest.updatedAt).getTime() > new Date(shown.updatedAt).getTime())- await mutateArtboard(id);-};--export const refreshStaleArtboard = async (id: string) => {- await mutateArtboard(id);- artboardActions.setStaleRevision(null);+ const newerRevision = latest.revision > shown.revision;+ const newerFiles = new Date(latest.updatedAt).getTime() > new Date(shown.updatedAt).getTime();+ if (newerRevision || newerFiles) await mutateArtboard(id);};diff --git a/src/features/Artboard/data/useArtboardRevisionWatch.ts b/src/features/Artboard/data/useArtboardRevisionWatch.tsindex ffe38798d77..5bf69246871 100644--- a/src/features/Artboard/data/useArtboardRevisionWatch.ts+++ b/src/features/Artboard/data/useArtboardRevisionWatch.ts@@ -1,7 +1,6 @@import type { ArtboardItem } from '@lobechat/types';import { useEffect, useRef } from 'react';-import { artboardActions, useArtboardStore } from '../store';import { useAgentRunningInTopic } from './agentRunning';import { checkArtboardRevision } from './revisionWatch';@@ -13,14 +12,9 @@ export const useArtboardRevisionWatch = () => {const { id, revision, topicId, updatedAt } = artboard;const running = useAgentRunningInTopic(topicId);- const stale = useArtboardStore((s) => s.staleRevision);const shown = useRef({ revision, updatedAt });shown.current = { revision, updatedAt };- useEffect(() => {- if (stale !== null && revision >= stale) artboardActions.setStaleRevision(null);- }, [revision, stale]);-useEffect(() => {const check = () => void checkArtboardRevision(id, shown.current).catch(() => {});window.addEventListener('focus', check);diff --git a/src/features/Artboard/store/action.ts b/src/features/Artboard/store/action.tsindex fe7caabd93d..2d6c1556a4d 100644--- a/src/features/Artboard/store/action.ts+++ b/src/features/Artboard/store/action.ts@@ -108,9 +108,6 @@ export class ArtboardActionImpl {setFullscreen = (fullscreen: boolean) => this.#set({ fullscreen }, false, n('fullscreen'));- setStaleRevision = (staleRevision: number | null) =>- this.#set({ staleRevision }, false, n('staleRevision'));-setNarrow = (narrow: boolean) => {if (narrow === this.#narrow) return;this.#narrow = narrow;diff --git a/src/features/Artboard/store/initialState.ts b/src/features/Artboard/store/initialState.tsindex 9388d622286..31969f6dc86 100644--- a/src/features/Artboard/store/initialState.ts+++ b/src/features/Artboard/store/initialState.ts@@ -20,7 +20,6 @@ export interface ArtboardState {pageByBoard: Record<string, string>;pageId: string | null;selected: string | null;- staleRevision: number | null;tool: BoardTool;verifyOpen: boolean;verifyView: VerifyView;@@ -40,7 +39,6 @@ export const initialState: ArtboardState = {pageByBoard: {},pageId: null,selected: null,- staleRevision: null,tool: 'select',verifyOpen: true,verifyView: 'board',