Skip to content

🤯 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.

🐛 fix: hide LocalFile actions in topic share page (#12254)

Arvin Xud49aba748e3f
diff --git a/src/features/Conversation/Markdown/plugins/LocalFile/Render/index.tsx b/src/features/Conversation/Markdown/plugins/LocalFile/Render/index.tsx
index 088888a2687..c5f45377386 100644
--- a/src/features/Conversation/Markdown/plugins/LocalFile/Render/index.tsx
+++ b/src/features/Conversation/Markdown/plugins/LocalFile/Render/index.tsx
@@ -3,6 +3,7 @@ import React, { memo } from 'react';
import { LocalFile } from '@/features/LocalFile';
+import { useConversationStore } from '../../../../store';
import { type MarkdownElementProps } from '../../type';
interface LocalFileProps {
@@ -14,6 +15,7 @@ interface LocalFileProps {
const Render = memo<MarkdownElementProps<LocalFileProps>>(({ node }) => {
// Extract properties from node.properties
const { name, path, isDirectory } = node?.properties || {};
+ const isSharePage = useConversationStore((s) => !!s.context.topicShareId);
if (!name || !path) {
// If required properties are missing, render an error or null
@@ -24,7 +26,7 @@ const Render = memo<MarkdownElementProps<LocalFileProps>>(({ node }) => {
// isDirectory may be true (from plugin) or undefined; ensure it is a boolean
const isDir = isDirectory === true;
- return <LocalFile isDirectory={isDir} name={name} path={path} />;
+ return <LocalFile isDirectory={isDir} name={name} path={path} readonly={isSharePage} />;
}, isEqual);
export default Render;
diff --git a/src/features/LocalFile/LocalFile.tsx b/src/features/LocalFile/LocalFile.tsx
index e7961c950fd..ff0995ab581 100644
--- a/src/features/LocalFile/LocalFile.tsx
+++ b/src/features/LocalFile/LocalFile.tsx
@@ -38,9 +38,14 @@ interface LocalFileProps {
isDirectory?: boolean;
name: string;
path?: string;
+ /**
+ * When true, disable interactive actions (Open / Show in Folder).
+ * Used in share pages where local file operations are not available.
+ */
+ readonly?: boolean;
}
-export const LocalFile = ({ name, path, isDirectory = false }: LocalFileProps) => {
+export const LocalFile = ({ name, path, isDirectory = false, readonly = false }: LocalFileProps) => {
const { t } = useTranslation('components');
const handleOpenFile = () => {
@@ -69,8 +74,8 @@ export const LocalFile = ({ name, path, isDirectory = false }: LocalFileProps) =
</Flexbox>
);
- // Directory: no popover, just click to open
- if (isDirectory) {
+ // Directory or readonly mode (e.g. share page): no popover, just display
+ if (isDirectory || readonly) {
return fileContent;
}