From dd2cf5adda4e580a44203a2d6035434b1d8646eb Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Sun, 9 Aug 2026 15:18:43 +0800 Subject: [PATCH] fix: hide document feature for guests + enforce public tool whitelist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TopNav: '文档' link only shows when loggedIn - AgentToolbar: document button v-if="loggedIn" - getAgentToolsForChatByAgentId: filter tools by agentPublicToolSlugs whitelist for guest users (previously only skipped adminOnly tools, exposing document and other non-public tools to unauthenticated users) Co-authored-by: CodeFree --- app/components/TopNav.vue | 19 +- app/components/agent/AgentChatArea.vue | 9 + app/components/agent/AgentSidebar.vue | 4 - app/components/agent/AgentToolbar.vue | 4 +- app/pages/chat/[agentSlug]/index.vue | 1 + docs/handover/2026-08-09-agent-document-tool.md | 306 ++++++++++++++++++++++++ packages/drizzle-pkg/db.sqlite | Bin 708608 -> 1019904 bytes server/service/agent-tool/index.ts | 13 +- 8 files changed, 341 insertions(+), 15 deletions(-) create mode 100644 docs/handover/2026-08-09-agent-document-tool.md diff --git a/app/components/TopNav.vue b/app/components/TopNav.vue index 43a80ad..fa40f98 100644 --- a/app/components/TopNav.vue +++ b/app/components/TopNav.vue @@ -8,13 +8,18 @@ const route = useRoute() const { loggedIn, user, clear, initialized } = useAuthSession() const { config: globalConfig } = useGlobalConfig() -const links: any = [ - { to: "/ideas", label: "创意" }, - { to: "/projects", label: "项目" }, - { to: "/articles", label: "文章" }, - { to: "/agent-documents", label: "文档" }, - { to: "/collect", label: "收藏" }, -] +const links: any = computed(() => { + const base = [ + { to: "/ideas", label: "创意" }, + { to: "/projects", label: "项目" }, + { to: "/articles", label: "文章" }, + ] + if (loggedIn.value) { + base.push({ to: "/agent-documents", label: "文档" }) + } + base.push({ to: "/collect", label: "收藏" }) + return base +}) let lastScrollY = 0 const HIDE_OFFSET = 520 diff --git a/app/components/agent/AgentChatArea.vue b/app/components/agent/AgentChatArea.vue index 02d0a89..c8137ef 100644 --- a/app/components/agent/AgentChatArea.vue +++ b/app/components/agent/AgentChatArea.vue @@ -24,6 +24,7 @@ const props = defineProps<{ sidebarCollapsed: boolean; errorMessage: string; systemPrompt?: string; + sessionId?: string | null; }>(); const emit = defineEmits<{ @@ -76,6 +77,14 @@ watch( } }, ); + +watch( + () => props.sessionId, + () => { + editingMessageId.value = null; + inputRef.value?.setText(""); + }, +);