2026-10-14 00:11:00 +08:00
import { useRef , useState , type ReactNode } from "react" ;
import { createPortal } from "react-dom" ;
2026-10-20 16:23:33 +08:00
import { Trans , useTranslation } from "react-i18next" ;
2026-10-14 00:11:00 +08:00
import { CapabilityMentionToken } from "@/components/CliAppMentionText" ;
import type { CapabilityMentionSegment } from "@/lib/composer-mention-text" ;
import { DeleteConfirm } from "@/components/DeleteConfirm" ;
import { FileActions } from "@/components/FileActions" ;
import { InlineTokenHighlight , INLINE_TOKEN_HIGHLIGHT_COLOR } from "@/components/InlineTokenHighlight" ;
import { MessageLinksMenu , useMessageWebLinks } from "@/components/MessageLinksMenu" ;
2026-10-18 01:38:47 +08:00
import { RenameDialog } from "@/components/RenameDialog" ;
2026-10-14 00:11:00 +08:00
import { SessionHandleLabel } from "@/components/SessionHandleLabel" ;
import { SlashCommandText } from "@/components/SlashCommandText" ;
import { StartupShell } from "@/components/StartupShell" ;
import { UserMessageText } from "@/components/UserMessageText" ;
import { WebLink } from "@/components/WebLink" ;
import * as ProductIcons from "@/components/icons/product-icons" ;
import { HostCompatibilityDialog } from "@/components/remote/HostCompatibilityDialog" ;
import { HostConnectionStatus } from "@/components/remote/HostConnectionStatus" ;
import type { HostConnectionState } from "@/components/remote/remote-context" ;
import { Button } from "@/components/ui/button" ;
import { Input } from "@/components/ui/input" ;
import { Textarea } from "@/components/ui/textarea" ;
import { PaneWorkbench , type WorkbenchPane } from "@/components/workbench/PaneWorkbench" ;
import type { HostCompatibility , RemoteProfile } from "@/lib/remote-instances" ;
import type { CliAppInfo , McpPresetInfo , SessionAutomationJob , SessionMention , WorkbenchLayout } from "@/lib/types" ;
import { cn } from "@/lib/utils" ;
import { Sample , StatePicker , type ComponentExample } from "./example" ;
2026-10-20 16:23:33 +08:00
import { useGalleryTranslation } from "./i18n" ;
2026-10-14 00:11:00 +08:00
const cliApp : CliAppInfo = {
name : "nanobot" , display_name : "Nanobot" , category : "assistant" , description : "Local assistant" ,
requires : "Python" , source : "local" , entry_point : "nanobot" , install_supported : true ,
installed : true , available : true , status : "installed" , skill_installed : true ,
logo_url : "/brand/nanobot_icon_512.png" , brand_color : "var(--inline-token-highlight)" ,
};
const mcpPreset : McpPresetInfo = {
name : "files" , display_name : "Workspace files" , category : "files" , description : "Workspace files" ,
docs_url : "" , transport : "stdio" , requires : "" , note : "" , install_supported : true ,
installed : true , configured : true , available : true , status : "configured" , required_fields : [],
connection_summary : "Local files" ,
};
const sessionMention : SessionMention = {
id : "gallery-session" , name : "design" , session_key : "webui:gallery-design" , title : "组件设计" ,
};
function RenamePreview() {
2026-10-18 01:38:47 +08:00
const { t } = useTranslation ();
2026-10-20 16:23:33 +08:00
const { t : g } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ open , setOpen ] = useState ( false );
const [ title , setTitle ] = useState ( "组件设计" );
return < div className = "space-y-4" >
< p className = "text-sm" >{ title }</ p >
2026-10-20 16:23:33 +08:00
< Button variant = "outline" onClick = {() => setOpen ( true )}>{ t ( "workbench.renameGroupTitle" )}</ Button >
2026-10-18 01:38:47 +08:00
< RenameDialog open = { open } title = { title }
dialogTitle = { t ( "workbench.renameGroupTitle" )}
description = { t ( "workbench.renameGroupDescription" )}
placeholder = { t ( "workbench.renameGroupPlaceholder" )}
onCancel = {() => setOpen ( false )}
2026-10-14 00:11:00 +08:00
onConfirm = {( next ) => { setTitle ( next ); setOpen ( false ); }} />
2026-10-20 16:23:33 +08:00
< p role = "status" className = "text-xs text-muted-foreground" >{ g ( "previews.rename.hint" )}</ p >
2026-10-14 00:11:00 +08:00
</ div >;
}
const automations : SessionAutomationJob [] = [
{ id : "gallery-daily" , name : "每日项目摘要" , enabled : true , schedule : { kind : "cron" , expr : "0 9 * * *" , tz : "Asia/Shanghai" }, payload : { message : "Summarize project updates" }, state : { next_run_at_ms : Date.UTC ( 2026 , 9 , 14 , 1 ) } },
{ id : "gallery-hourly" , name : "每小时检查" , enabled : false , schedule : { kind : "every" , every_ms : 3_600_000 }, payload : { message : "Check updates" }, state : {} },
{ id : "gallery-trigger" , name : "发布后检查" , enabled : true , schedule : { kind : "local" }, payload : { message : "Check the release" , kind : "local_trigger" }, state : {} },
{ id : "gallery-once" , name : "一次性提醒" , enabled : true , schedule : { kind : "at" , at_ms : Date.UTC ( 2026 , 9 , 15 , 2 ) }, payload : { message : "Review the result" }, state : { next_run_at_ms : Date.UTC ( 2026 , 9 , 15 , 2 ) } },
{ id : "gallery-weekly" , name : "每周回顾" , enabled : true , schedule : { kind : "every" , every_ms : 604_800_000 }, payload : { message : "Review the week" }, state : {} },
];
function DeletePreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ scenario , setScenario ] = useState < "single" | "multiple" | "automations" > ( "single" );
const [ open , setOpen ] = useState ( false );
const [ deleted , setDeleted ] = useState ( false );
return <>
2026-10-20 16:23:33 +08:00
< StatePicker label = { t ( "previews.delete.scenario" )} value = { scenario } options = {[ "single" , "multiple" , "automations" ]}
2026-10-14 00:11:00 +08:00
onChange = {( next ) => { setScenario ( next ); setDeleted ( false ); }} />
2026-10-20 16:23:33 +08:00
< Button variant = "outline" onClick = {() => { setDeleted ( false ); setOpen ( true ); }}>{ t ( "previews.delete.open" )}</ Button >
2026-10-14 00:11:00 +08:00
< DeleteConfirm open = { open } title = "组件设计" count = { scenario === "multiple" ? 3 : 1 }
automations = { scenario === "automations" ? automations : []} onCancel = {() => setOpen ( false )}
onConfirm = {() => { setDeleted ( true ); setOpen ( false ); }} />
2026-10-20 16:23:33 +08:00
< p role = "status" className = "mt-4 text-xs text-muted-foreground" >{ t ( deleted ? "previews.delete.confirmed" : "previews.delete.hint" )}</ p >
2026-10-14 00:11:00 +08:00
</>;
}
function InlineTokensPreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ command , setCommand ] = useState ( "/status" );
const [ handle , setHandle ] = useState ( "gallery-session" );
return < div className = "space-y-5" >
2026-10-20 16:23:33 +08:00
< Sample label = { t ( "previews.inlineTokens.command" )}>< Input aria-label = { t ( "previews.inlineTokens.command" )} value = { command } onChange = {( event ) => setCommand ( event . target . value )} />
< p className = "text-sm" >< Trans t = { t } i18nKey = "previews.inlineTokens.run" components = {{ command : < SlashCommandText command = { command } /> }} /></ p ></ Sample >
< Sample label = { t ( "previews.inlineTokens.handle" )}>< Input aria-label = { t ( "previews.inlineTokens.handle" )} value = { handle } onChange = {( event ) => setHandle ( event . target . value )} />
< p className = "text-sm" >< Trans t = { t } i18nKey = "previews.inlineTokens.continue" components = {{ session : < SessionHandleLabel id = { handle }> @design </ SessionHandleLabel > }} /></ p ></ Sample >
< Sample label = { t ( "previews.inlineTokens.highlight" )}>< p className = "text-sm" >< Trans t = { t } i18nKey = "previews.inlineTokens.review" components = {{ skill : < InlineTokenHighlight color = { INLINE_TOKEN_HIGHLIGHT_COLOR } title = { t ( "previews.inlineTokens.skill" , { name : "review" })}> review </ InlineTokenHighlight > }} /></ p ></ Sample >
2026-10-14 00:11:00 +08:00
</ div >;
}
function SessionLinksPreview ({ children } : { children : ReactNode }) {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ selected , setSelected ] = useState ( false );
return < div className = "space-y-4" onClick = {( event ) => {
if ( ! ( event . target instanceof Element )) return ;
const link = event . target . closest < HTMLAnchorElement >( 'a[href^="#/chat/"]' );
if ( ! link ) return ;
event . preventDefault ();
setSelected ( true );
}}>
{ children }
2026-10-20 16:23:33 +08:00
< p role = "status" className = "text-xs text-muted-foreground" >{ selected ? t ( "previews.sessionLinks.selected" , { name : sessionMention.title }) : t ( "previews.sessionLinks.hint" )}</ p >
2026-10-14 00:11:00 +08:00
</ div >;
}
function UserTextPreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ text , setText ] = useState ( "用 $review 检查 @nanobot 的修改,参考 @design 和 @files。" );
return < SessionLinksPreview >
2026-10-20 16:23:33 +08:00
< label className = "grid gap-2 text-xs text-muted-foreground" >{ t ( "previews.userText.message" )}
2026-10-14 00:11:00 +08:00
< Textarea value = { text } onChange = {( event ) => setText ( event . target . value )} />
</ label >
< p className = "whitespace-pre-wrap text-sm leading-7" >< UserMessageText text = { text } cliApps = {[ cliApp ]}
mcpPresets = {[ mcpPreset ]} sessionMentions = {[ sessionMention ]} /></ p >
</ SessionLinksPreview >;
}
function CapabilityTokensPreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ variant , setVariant ] = useState < "message" | "composer" > ( "message" );
const segments : Array < Exclude < CapabilityMentionSegment , { kind : "text" }>> = [
{ kind : "cli" , text : "@nanobot" , app : cliApp },
{ kind : "mcp" , text : "@files" , preset : mcpPreset },
{ kind : "session" , text : "@design" , mention : sessionMention },
];
return < SessionLinksPreview >
2026-10-20 16:23:33 +08:00
< StatePicker label = { t ( "previews.capabilityTokens.position" )} value = { variant } options = {[ "message" , "composer" ]} onChange = { setVariant } />
2026-10-14 00:11:00 +08:00
< div className = "flex flex-wrap gap-6 text-sm leading-7" >{ segments . map (( segment ) =>
< CapabilityMentionToken key = { segment . kind } segment = { segment } variant = { variant } />)}</ div >
</ SessionLinksPreview >;
}
function ProductIconsPreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ size , setSize ] = useState < "16" | "20" | "24" > ( "20" );
const [ selected , setSelected ] = useState ( "ConversationIcon" );
return <>
2026-10-20 16:23:33 +08:00
< StatePicker label = { t ( "previews.productIcons.size" )} value = { size } options = {[ "16" , "20" , "24" ]} onChange = { setSize } />
2026-10-14 00:11:00 +08:00
< div className = "grid grid-cols-2 gap-2 sm:grid-cols-4 lg:grid-cols-6" >{ Object . entries ( ProductIcons ). map (([ name , Icon ]) =>
< button key = { name } type = "button" aria-pressed = { selected === name } onClick = {() => setSelected ( name )}
className = { cn ( "flex min-w-0 flex-col items-center gap-2 rounded-control p-3 text-muted-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" , selected === name && "bg-muted text-foreground" )}>
< Icon size = { Number ( size )} />< span className = "max-w-full break-all text-center text-[10px] leading-4" >{ name . replace ( /Icon$/ , "" )}</ span >
</ button >)}</ div >
2026-10-20 16:23:33 +08:00
< p role = "status" className = "mt-4 text-xs text-muted-foreground" >{ t ( "previews.productIcons.selected" , { name : selected })}</ p >
2026-10-14 00:11:00 +08:00
</>;
}
function StartupPreview() {
return < div className = "gallery-startup-preview h-80 overflow-hidden rounded-panel border" >< StartupShell embedded /></ div >;
}
function FileActionsPreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ scope , setScope ] = useState < "workspace" | "outside" | "unresolved" > ( "workspace" );
const path = "src/app.tsx" ;
return <>
2026-10-20 16:23:33 +08:00
< StatePicker label = { t ( "previews.fileActions.scope" )} value = { scope } options = {[ "workspace" , "outside" , "unresolved" ]} onChange = { setScope } />
2026-10-14 00:11:00 +08:00
< FileActions path = { path } metadata = { scope === "unresolved" ? undefined : {
path : scope === "workspace" ? "D:/workspace/nanobot/src/app.tsx" : "D:/documents/report.tsx" ,
relative_path : scope === "workspace" ? path : null ,
}}>< Button variant = "outline" >{ path }</ Button ></ FileActions >
2026-10-20 16:23:33 +08:00
< p className = "mt-4 text-xs text-muted-foreground" >{ t ( "previews.fileActions.hint" )}</ p >
2026-10-14 00:11:00 +08:00
</>;
}
function WebLinksPreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ open , setOpen ] = useState ( false );
const [ display , setDisplay ] = useState < "compact" | "expanded" > ( "compact" );
const message = useRef < HTMLDivElement >( null );
const links = useMessageWebLinks ( message , open );
return < div className = "space-y-4" >
2026-10-20 16:23:33 +08:00
< StatePicker label = { t ( "previews.webLinks.width" )} value = { display } options = {[ "compact" , "expanded" ]} onChange = { setDisplay } />
2026-10-14 00:11:00 +08:00
< div ref = { message } className = "text-sm leading-7" >< p data - assistant - selectable >
2026-10-20 16:23:33 +08:00
< Trans t = { t } i18nKey = "previews.webLinks.message" components = {{
gallery : < WebLink href = { ` ${ window . location . origin } /gallery.html` } className = "underline underline-offset-4" />,
brand : < WebLink href = { ` ${ window . location . origin } /brand/nanobot_icon_512.png` } className = "underline underline-offset-4" />,
}} />
2026-10-14 00:11:00 +08:00
</ p ></ div >
2026-10-20 16:23:33 +08:00
< Button variant = "outline" onClick = {() => setOpen (( value ) => ! value )}>{ t ( open ? "previews.webLinks.close" : "previews.webLinks.open" )}</ Button >
2026-10-14 00:11:00 +08:00
{ open && links . length > 0 ? < div className = "rounded-control border p-1" >
< MessageLinksMenu links = { links } onBack = {() => setOpen ( false )} onClose = {() => setOpen ( false )} expanded = { display === "expanded" } />
</ div > : null }
2026-10-20 16:23:33 +08:00
< p className = "text-xs text-muted-foreground" >{ t ( "previews.webLinks.hint" )}</ p >
2026-10-14 00:11:00 +08:00
</ div >;
}
const initialPanes : WorkbenchPane [] = [
{ key : "pane-1" , title : "组件设计" }, { key : "pane-2" , title : "实现" }, { key : "pane-3" , title : "验证" },
];
function WorkbenchPreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ panes , setPanes ] = useState ( initialPanes );
const [ active , setActive ] = useState ( "pane-1" );
const [ layout , setLayout ] = useState < WorkbenchLayout >( "columns" );
const [ ratios , setRatios ] = useState < number [] >([]);
return <>
2026-10-20 16:23:33 +08:00
< StatePicker label = { t ( "previews.workbench.layout" )} value = { layout } options = {[ "columns" , "rows" , "grid" , "bsp" , "main-stack" ]}
2026-10-14 00:11:00 +08:00
onChange = {( next ) => { setLayout ( next ); setRatios ([]); }} />
< div className = "h-[28rem] overflow-hidden rounded-panel border" >
< PaneWorkbench panes = { panes } activePaneKey = { active } layout = { layout } showLayoutControl
2026-10-20 16:23:33 +08:00
addPaneDisabled = { panes . length >= 4 } addPaneDisabledLabel = { t ( "previews.workbench.limit" )}
2026-10-14 00:11:00 +08:00
onActivatePane = { setActive } onLayoutChange = {( next ) => { setLayout ( next ); setRatios ([]); }}
onAddPane = {() => {
const next = { key : `pane- ${ panes . length + 1 } ` , title : "补充笔记" };
setPanes ([... panes , next ]); setActive ( next . key );
}}
onPaneOrderChange = {( keys ) => setPanes ( keys . flatMap (( key ) => panes . filter (( pane ) => pane . key === key )))}
splitRatios = { ratios } onSplitRatiosChange = { setRatios }
renderPane = {( pane , context ) => {
const header = < div className = "pointer-events-auto flex h-10 items-center justify-between gap-2 px-3 text-xs" >
< span >{ pane . title }</ span >{ context . headerActions }
</ div >;
return < div className = "flex min-w-0 flex-1 flex-col gap-3 p-3 pb-8" >
{ context . active && context . headerPortalTarget ? createPortal ( header , context . headerPortalTarget ) : context . active ? header : < p className = "h-10 content-center text-xs text-muted-foreground" >{ pane . title }</ p >}
2026-10-20 16:23:33 +08:00
< label className = "grid gap-2 text-xs text-muted-foreground" >{ t ( "previews.workbench.notes" , { title : pane.title })}
2026-10-14 00:11:00 +08:00
< Textarea defaultValue = { `在 ${ pane . title } 窗格中编辑笔记。` } /></ label >
2026-10-20 16:23:33 +08:00
< p className = "text-xs text-muted-foreground" >{ t ( context . active ? "previews.workbench.active" : "previews.workbench.activate" )}</ p >
2026-10-14 00:11:00 +08:00
</ div >;
}} />
</ div >
2026-10-20 16:23:33 +08:00
< p role = "status" className = "mt-4 text-xs text-muted-foreground" >{ t ( "previews.workbench.hint" , { title : panes.find (( pane ) => pane . key === active ) ? . title })}</ p >
2026-10-14 00:11:00 +08:00
</>;
}
function ConnectionPreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ state , setState ] = useState < HostConnectionState >( "open" );
return <>
2026-10-20 16:23:33 +08:00
< StatePicker label = { t ( "previews.hostConnection.state" )} value = { state } options = {[ "open" , "closed" , "connecting" , "error" ]} onChange = { setState } />
< div className = "flex flex-wrap gap-8" >< Sample label = { t ( "previews.hostConnection.withText" )}>< HostConnectionStatus state = { state } /></ Sample >
< Sample label = { t ( "previews.hostConnection.compact" )}>< HostConnectionStatus state = { state } compact /></ Sample ></ div >
2026-10-14 00:11:00 +08:00
</>;
}
function CompatibilityPreview() {
2026-10-20 16:23:33 +08:00
const { t } = useGalleryTranslation ();
2026-10-14 00:11:00 +08:00
const [ status , setStatus ] = useState < HostCompatibility [ "status" ] | "unchecked" >( "compatible" );
const [ open , setOpen ] = useState ( false );
const profile : RemoteProfile = {
id : "gallery-host" , name : "开发主机" , host : "dev.example" , port : 22 , ssh_config : "" , identity_file : "" ,
config_path : "~/.nanobot/config.json" , runtime_user : "developer" , connected : false ,
compatibility : status === "unchecked" ? undefined : {
status , client_version : "0.3.0" , host_version : status === "update_host" ? "0.2.0" : status === "update_client" ? "0.4.0" : "0.3.0" ,
},
};
return <>
2026-10-20 16:23:33 +08:00
< StatePicker label = { t ( "previews.compatibility.state" )} value = { status } options = {[ "compatible" , "update_host" , "update_client" , "unknown" , "unchecked" ]} onChange = { setStatus } />
< Button variant = "outline" onClick = {() => setOpen ( true )}>{ t ( "previews.compatibility.open" )}</ Button >
2026-10-14 00:11:00 +08:00
< HostCompatibilityDialog profile = { open ? profile : undefined } clientVersion = "0.3.0" onClose = {() => setOpen ( false )} />
</>;
}
const components = "webui/src/components/" ;
export const shellExamples : ComponentExample [] = [
2026-10-20 16:23:33 +08:00
{ title : "previews.rename.title" , files : [ "RenameDialog" ], Preview : RenamePreview ,
description : "previews.rename.description" , options : "previews.rename.options" ,
2026-10-18 01:38:47 +08:00
code : '<RenameDialog open={open} title={title} dialogTitle="Rename group" description="Give this group a name." placeholder="Group name" onCancel={close} onConfirm={rename} />' },
2026-10-20 16:23:33 +08:00
{ title : "previews.delete.title" , files : [ "DeleteConfirm" ], Preview : DeletePreview ,
description : "previews.delete.description" , options : "previews.delete.options" ,
2026-10-14 00:11:00 +08:00
code : '<DeleteConfirm open={open} title="组件设计" count={1} automations={jobs} onCancel={close} onConfirm={remove} />' },
2026-10-20 16:23:33 +08:00
{ title : "previews.inlineTokens.title" , files : [ "SlashCommandText" , "InlineTokenHighlight" , "SessionHandleLabel" ], Preview : InlineTokensPreview ,
description : "previews.inlineTokens.description" , options : "previews.inlineTokens.options" ,
2026-10-14 00:11:00 +08:00
code : '<SlashCommandText command="/status" />\n<SessionHandleLabel id={session.id}>@design</SessionHandleLabel>\n<InlineTokenHighlight color="var(--inline-token-highlight)">review</InlineTokenHighlight>' },
2026-10-20 16:23:33 +08:00
{ title : "previews.userText.title" , files : [ "UserMessageText" ], Preview : UserTextPreview ,
description : "previews.userText.description" , options : "previews.userText.options" ,
2026-10-14 00:11:00 +08:00
code : '<UserMessageText text={text} cliApps={apps} mcpPresets={presets} sessionMentions={sessions} />' },
2026-10-20 16:23:33 +08:00
{ title : "previews.capabilityTokens.title" , files : [ "CliAppMentionText" ], Preview : CapabilityTokensPreview ,
description : "previews.capabilityTokens.description" , options : "previews.capabilityTokens.options" ,
2026-10-14 00:11:00 +08:00
code : '<CapabilityMentionToken segment={{ kind: "cli", text: "@nanobot", app }} variant="message" />' },
2026-10-20 16:23:33 +08:00
{ title : "previews.productIcons.title" , files : [ "icons/product-icons" ], Preview : ProductIconsPreview ,
description : "previews.productIcons.description" , options : "previews.productIcons.options" ,
2026-10-14 00:11:00 +08:00
code : '<ConversationIcon size={20} />\n<SettingsIcon className="text-muted-foreground" />' },
2026-10-20 16:23:33 +08:00
{ title : "previews.startup.title" , files : [ "StartupShell" ], Preview : StartupPreview ,
description : "previews.startup.description" , options : "previews.startup.options" ,
2026-10-14 00:11:00 +08:00
code : '<StartupShell embedded />' },
2026-10-20 16:23:33 +08:00
{ title : "previews.fileActions.title" , files : [ "FileActions" ], Preview : FileActionsPreview ,
description : "previews.fileActions.description" , options : "previews.fileActions.options" ,
2026-10-14 00:11:00 +08:00
code : '<FileActions path="src/app.tsx" metadata={{ path: "D:/workspace/src/app.tsx", relative_path: "src/app.tsx" }}><Button>app.tsx</Button></FileActions>' },
2026-10-20 16:23:33 +08:00
{ title : "previews.webLinks.title" , files : [ "WebLink" , "MessageLinksMenu" ], Preview : WebLinksPreview ,
description : "previews.webLinks.description" , options : "previews.webLinks.options" ,
2026-10-14 00:11:00 +08:00
code : '<WebLink href={url}>组件画廊</WebLink>\nconst links = useMessageWebLinks(messageRef, open);\n<MessageLinksMenu links={links} onBack={close} onClose={close} expanded />' },
2026-10-20 16:23:33 +08:00
{ title : "previews.workbench.title" , files : [ "workbench/PaneWorkbench" ], Preview : WorkbenchPreview ,
description : "previews.workbench.description" , options : "previews.workbench.options" ,
2026-10-14 00:11:00 +08:00
code : '<PaneWorkbench panes={panes} activePaneKey={active} layout={layout} showLayoutControl onActivatePane={setActive} onAddPane={addPane} onLayoutChange={setLayout} onPaneOrderChange={reorder} renderPane={renderPane} />' },
2026-10-20 16:23:33 +08:00
{ title : "previews.hostConnection.title" , files : [ "remote/HostConnectionStatus" ], Preview : ConnectionPreview ,
description : "previews.hostConnection.description" , options : "previews.hostConnection.options" ,
2026-10-14 00:11:00 +08:00
code : '<HostConnectionStatus state="connecting" />\n<HostConnectionStatus state="open" compact />' },
2026-10-20 16:23:33 +08:00
{ title : "previews.compatibility.title" , files : [ "remote/HostCompatibilityDialog" ], Preview : CompatibilityPreview ,
description : "previews.compatibility.description" , options : "previews.compatibility.options" ,
2026-10-14 00:11:00 +08:00
code : '<HostCompatibilityDialog profile={selectedProfile} clientVersion="0.3.0" onClose={close} />' },
]. map (( example ) => ({ ... example , files : example.files.map (( file ) => ` ${ components }${ file } .tsx` ) }));