MCPcopy Index your code
hub / github.com/winfunc/opcode / TabContent

Function TabContent

src/components/TabContent.tsx:400–533  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

398};
399
400export const TabContent: React.FC = () => {
401 const { tabs, activeTabId, createChatTab, createProjectsTab, findTabBySessionId, createClaudeFileTab, createAgentExecutionTab, createCreateAgentTab, createImportAgentTab, closeTab, updateTab } = useTabState();
402
403 // Listen for events to open sessions in tabs
404 useEffect(() => {
405 const handleOpenSessionInTab = (event: CustomEvent) => {
406 const { session } = event.detail;
407
408 // Check if tab already exists for this session
409 const existingTab = findTabBySessionId(session.id);
410 if (existingTab) {
411 // Update existing tab with session data and switch to it
412 updateTab(existingTab.id, {
413 sessionData: session,
414 title: session.project_path.split('/').pop() || 'Session'
415 });
416 window.dispatchEvent(new CustomEvent('switch-to-tab', { detail: { tabId: existingTab.id } }));
417 } else {
418 // Create new tab for this session
419 const projectName = session.project_path.split('/').pop() || 'Session';
420 const newTabId = createChatTab(session.id, projectName, session.project_path);
421 // Update the new tab with session data
422 updateTab(newTabId, {
423 sessionData: session,
424 initialProjectPath: session.project_path
425 });
426 }
427 };
428
429 const handleOpenClaudeFile = (event: CustomEvent) => {
430 const { file } = event.detail;
431 createClaudeFileTab(file.id, file.name || 'CLAUDE.md');
432 };
433
434 const handleOpenAgentExecution = (event: CustomEvent) => {
435 const { agent, tabId, projectPath } = event.detail;
436 createAgentExecutionTab(agent, tabId, projectPath);
437 };
438
439 const handleOpenCreateAgentTab = () => {
440 createCreateAgentTab();
441 };
442
443 const handleOpenImportAgentTab = () => {
444 createImportAgentTab();
445 };
446
447 const handleCloseTab = (event: CustomEvent) => {
448 const { tabId } = event.detail;
449 closeTab(tabId);
450 };
451
452 const handleClaudeSessionSelected = (event: CustomEvent) => {
453 const { session } = event.detail;
454 // Check if there's an existing tab for this session
455 const existingTab = findTabBySessionId(session.id);
456 if (existingTab) {
457 // If tab exists, just switch to it

Callers

nothing calls this directly

Calls 1

useTabStateFunction · 0.90

Tested by

no test coverage detected