feat(report): add 'report' tab type and openSessionReport store action
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
465115ee5c
commit
0e3e20c990
3 changed files with 25 additions and 2 deletions
|
|
@ -8,7 +8,7 @@ import { useCallback, useState } from 'react';
|
|||
import { useSortable } from '@dnd-kit/sortable';
|
||||
import { CSS } from '@dnd-kit/utilities';
|
||||
import { useStore } from '@renderer/store';
|
||||
import { Bell, FileText, LayoutDashboard, Pin, Search, Settings, X } from 'lucide-react';
|
||||
import { Activity, Bell, FileText, LayoutDashboard, Pin, Search, Settings, X } from 'lucide-react';
|
||||
import { useShallow } from 'zustand/react/shallow';
|
||||
|
||||
import type { Tab } from '@renderer/types/tabs';
|
||||
|
|
@ -30,6 +30,7 @@ const TAB_ICONS = {
|
|||
notifications: Bell,
|
||||
settings: Settings,
|
||||
session: FileText,
|
||||
report: Activity,
|
||||
} as const;
|
||||
|
||||
export const SortableTab = ({
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ export interface TabSlice {
|
|||
closeTab: (tabId: string) => void;
|
||||
setActiveTab: (tabId: string) => void;
|
||||
openDashboard: () => void;
|
||||
openSessionReport: (sourceTabId: string) => void;
|
||||
getActiveTab: () => Tab | null;
|
||||
isSessionOpen: (sessionId: string) => boolean;
|
||||
enqueueTabNavigation: (tabId: string, request: TabNavigationRequest) => void;
|
||||
|
|
@ -380,6 +381,27 @@ export const createTabSlice: StateCreator<AppState, [], [], TabSlice> = (set, ge
|
|||
set(syncFromLayout(newLayout));
|
||||
},
|
||||
|
||||
// Open a session report tab based on a source session tab
|
||||
openSessionReport: (sourceTabId: string) => {
|
||||
const state = get();
|
||||
const allTabs = getAllTabs(state.paneLayout);
|
||||
const sourceTab = allTabs.find((t) => t.id === sourceTabId);
|
||||
if (sourceTab?.type !== 'session') return;
|
||||
|
||||
const tabData = state.tabSessionData[sourceTabId];
|
||||
const firstMsg = tabData?.sessionDetail?.session.firstMessage;
|
||||
const label = firstMsg
|
||||
? `Report: ${firstMsg.slice(0, 30)}${firstMsg.length > 30 ? '…' : ''}`
|
||||
: 'Session Report';
|
||||
|
||||
state.openTab({
|
||||
type: 'report',
|
||||
label,
|
||||
projectId: sourceTab.projectId,
|
||||
sessionId: sourceTab.sessionId,
|
||||
});
|
||||
},
|
||||
|
||||
// Get the currently active tab (from the focused pane)
|
||||
getActiveTab: () => {
|
||||
const state = get();
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ export interface Tab {
|
|||
id: string;
|
||||
|
||||
/** Type of content displayed in this tab */
|
||||
type: 'session' | 'dashboard' | 'notifications' | 'settings';
|
||||
type: 'session' | 'dashboard' | 'notifications' | 'settings' | 'report';
|
||||
|
||||
/** Session ID (required when type === 'session') */
|
||||
sessionId?: string;
|
||||
|
|
|
|||
Loading…
Reference in a new issue