diff --git a/cptr/frontend/src/lib/components/ArtifactViewer.svelte b/cptr/frontend/src/lib/components/ArtifactViewer.svelte
deleted file mode 100644
index 1e160dc..0000000
--- a/cptr/frontend/src/lib/components/ArtifactViewer.svelte
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
diff --git a/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte b/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte
index a78c418..0a8e991 100644
--- a/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte
+++ b/cptr/frontend/src/lib/components/chat/AssistantMessage.svelte
@@ -8,7 +8,7 @@
import MessageTimestamp from './MessageTimestamp.svelte';
import ReasoningCollapsible from './ReasoningCollapsible.svelte';
import ToolCallCollapsible from './ToolCallCollapsible.svelte';
- import { currentWorkspace, openArtifactTab, openFileTab } from '$lib/stores';
+ import { currentWorkspace, openFileTab } from '$lib/stores';
import { ttsConfigured, ttsEnabled } from '$lib/stores/audio';
import { tooltip } from '$lib/tooltip';
import { fileIconName } from '$lib/utils/fileIcon';
@@ -159,7 +159,12 @@
}
function openArtifact(artifact: any) {
- openArtifactTab(artifact.title || 'Artifact', artifact.content || '');
+ const workspace = get(currentWorkspace);
+ const path =
+ workspace && artifact.path
+ ? `${workspace.path.replace(/\/$/, '')}/${artifact.path}`
+ : artifact.path;
+ if (path) openFileTab(path);
}
/** Human-readable label for a tool call */
diff --git a/cptr/frontend/src/lib/stores.ts b/cptr/frontend/src/lib/stores.ts
index ef8f47a..a3fd4c6 100644
--- a/cptr/frontend/src/lib/stores.ts
+++ b/cptr/frontend/src/lib/stores.ts
@@ -53,19 +53,9 @@ export interface FileSearchTarget {
export interface Tab {
id: string;
- type:
- | 'home'
- | 'files'
- | 'terminal'
- | 'file'
- | 'artifact'
- | 'git'
- | 'chat'
- | 'preview'
- | 'browser'; // preview is migrated on load
+ type: 'home' | 'files' | 'terminal' | 'file' | 'git' | 'chat' | 'preview' | 'browser'; // preview is migrated on load
label: string;
filePath?: string;
- content?: string;
edit?: boolean;
path?: string; // generic path (e.g. for chat)
sessionId?: string;
@@ -955,7 +945,10 @@ export function openFileTab(
options: { edit?: boolean; searchTarget?: FileSearchTarget } = {}
): void {
const ws = get(currentWorkspace);
- if (!ws) return;
+ if (!ws) {
+ openHomeFileTab(filePath, targetGroupId, options);
+ return;
+ }
const gid = targetGroupId ?? ws.activeGroupId;
const group = ws.groups.find((g) => g.id === gid);
@@ -995,26 +988,35 @@ export function openFileTab(
}));
}
-export function openArtifactTab(title: string, content: string): void {
- const workspace = get(currentWorkspace);
- const state = workspace ?? get(homeState);
- const group = state.groups.find((item) => item.id === state.activeGroupId);
+function openHomeFileTab(
+ filePath: string,
+ targetGroupId?: string,
+ options: { edit?: boolean; searchTarget?: FileSearchTarget } = {}
+): void {
+ const state = get(homeState);
+ const groupId = targetGroupId ?? state.activeGroupId;
+ const group = state.groups.find((item) => item.id === groupId);
if (!group) return;
- const existing = group.tabs.find((tab) => tab.type === 'artifact' && tab.content === content);
- const tab: Tab = existing ?? { id: nextId(), type: 'artifact', label: title, content };
+ const existing = group.tabs.find((tab) => tab.type === 'file' && tab.filePath === filePath);
+ const tab: Tab = existing ?? {
+ id: nextId(),
+ type: 'file',
+ label: getPathDisplayName(filePath, filePath),
+ filePath,
+ edit: options.edit,
+ searchTarget: options.searchTarget
+ };
const updateGroup = (group: EditorGroup) =>
- group.id === state.activeGroupId
+ group.id === groupId
? { ...group, tabs: existing ? group.tabs : [...group.tabs, tab], activeTabId: tab.id }
: group;
- if (workspace) {
- currentWorkspace.update((current) =>
- current ? { ...current, groups: current.groups.map(updateGroup) } : current
- );
- } else {
- homeState.update((current) => ({ ...current, groups: current.groups.map(updateGroup) }));
- }
+ homeState.update((current) => ({
+ ...current,
+ activeGroupId: groupId,
+ groups: current.groups.map(updateGroup)
+ }));
}
export function openUntitledFileTab(targetGroupId?: string): void {
diff --git a/cptr/frontend/src/routes/+page.svelte b/cptr/frontend/src/routes/+page.svelte
index e8adc46..a631b99 100644
--- a/cptr/frontend/src/routes/+page.svelte
+++ b/cptr/frontend/src/routes/+page.svelte
@@ -43,7 +43,6 @@
import FileEditor from '$lib/components/FileEditor.svelte';
import GitView from '$lib/components/GitView.svelte';
import Terminal from '$lib/components/Terminal.svelte';
- import ArtifactViewer from '$lib/components/ArtifactViewer.svelte';
import BrowserPreview from '$lib/components/BrowserPreview.svelte';
import ChatPanel from '$lib/components/chat/ChatPanel.svelte';
import DirectoryPicker from '$lib/components/DirectoryPicker.svelte';
@@ -1050,9 +1049,14 @@
/>
{/each}
- {#each homePane.tabs.filter((tab) => tab.type === 'artifact') as tab (tab.id)}
+ {#each homePane.tabs.filter((tab) => tab.type === 'file' && tab.filePath) as tab (tab.id)}
{/each}
{#each homePane.tabs.filter((tab) => tab.type === 'terminal' && tab.sessionId) as tab (tab.id)}
@@ -1372,11 +1376,6 @@
/>
{/each}
- {#each group.tabs.filter((tab) => tab.type === 'artifact') as tab (tab.id)}
-
- {/each}
{#each group.tabs.filter((tab) => tab.type === 'chat') as tab (tab.id)}