@@ -53,9 +53,19 @@ export interface FileSearchTarget {
5353
5454export interface Tab {
5555 id : string ;
56- type : 'home' | 'files' | 'terminal' | 'file' | 'git' | 'chat' | 'preview' | 'browser' ; // preview is migrated on load
56+ type :
57+ | 'home'
58+ | 'files'
59+ | 'terminal'
60+ | 'file'
61+ | 'artifact'
62+ | 'git'
63+ | 'chat'
64+ | 'preview'
65+ | 'browser' ; // preview is migrated on load
5766 label : string ;
5867 filePath ?: string ;
68+ content ?: string ;
5969 edit ?: boolean ;
6070 path ?: string ; // generic path (e.g. for chat)
6171 sessionId ?: string ;
@@ -985,6 +995,28 @@ export function openFileTab(
985995 } ) ) ;
986996}
987997
998+ export function openArtifactTab ( title : string , content : string ) : void {
999+ const workspace = get ( currentWorkspace ) ;
1000+ const state = workspace ?? get ( homeState ) ;
1001+ const group = state . groups . find ( ( item ) => item . id === state . activeGroupId ) ;
1002+ if ( ! group ) return ;
1003+
1004+ const existing = group . tabs . find ( ( tab ) => tab . type === 'artifact' && tab . content === content ) ;
1005+ const tab : Tab = existing ?? { id : nextId ( ) , type : 'artifact' , label : title , content } ;
1006+ const updateGroup = ( group : EditorGroup ) =>
1007+ group . id === state . activeGroupId
1008+ ? { ...group , tabs : existing ? group . tabs : [ ...group . tabs , tab ] , activeTabId : tab . id }
1009+ : group ;
1010+
1011+ if ( workspace ) {
1012+ currentWorkspace . update ( ( current ) =>
1013+ current ? { ...current , groups : current . groups . map ( updateGroup ) } : current
1014+ ) ;
1015+ } else {
1016+ homeState . update ( ( current ) => ( { ...current , groups : current . groups . map ( updateGroup ) } ) ) ;
1017+ }
1018+ }
1019+
9881020export function openUntitledFileTab ( targetGroupId ?: string ) : void {
9891021 // Find the lowest unused number across ALL groups
9901022 const ws = get ( currentWorkspace ) ;
0 commit comments