|
1 | 1 | 'use client' |
2 | 2 |
|
3 | 3 | import { useEffect, useRef, useState } from 'react' |
4 | | -import { Badge, Button, Chip, ChipConfirmModal, cn, Tooltip, toast } from '@sim/emcn' |
| 4 | +import { |
| 5 | + Badge, |
| 6 | + Chip, |
| 7 | + ChipConfirmModal, |
| 8 | + CollapsibleCard, |
| 9 | + cn, |
| 10 | + OverflowText, |
| 11 | + Tooltip, |
| 12 | + toast, |
| 13 | +} from '@sim/emcn' |
5 | 14 | import { ArrowLeft, ChevronDown, Plus } from '@sim/emcn/icons' |
6 | 15 | import { createLogger } from '@sim/logger' |
7 | 16 | import { getErrorMessage } from '@sim/utils/errors' |
@@ -535,59 +544,53 @@ export function MCP() { |
535 | 544 | const requiredParams = tool.inputSchema?.required || [] |
536 | 545 |
|
537 | 546 | return ( |
538 | | - <div |
| 547 | + <CollapsibleCard |
539 | 548 | key={tool.name} |
540 | | - className='overflow-hidden rounded-md border border-[var(--border-1)] bg-[var(--surface-3)]' |
541 | | - > |
542 | | - <Button |
543 | | - type='button' |
544 | | - variant='ghost' |
545 | | - onClick={() => hasParams && toggleToolExpanded(tool.name)} |
546 | | - className={cn( |
547 | | - 'flex h-auto w-full items-start justify-between rounded-none px-2.5 py-2 text-left text-sm', |
548 | | - hasParams && 'cursor-pointer hover-hover:bg-[var(--surface-4)]' |
549 | | - )} |
550 | | - disabled={!hasParams} |
551 | | - > |
552 | | - <div className='flex-1'> |
553 | | - <div className='flex h-[16px] items-center gap-1.5'> |
554 | | - <p className='text-[var(--text-primary)] text-sm leading-none'> |
555 | | - {tool.name} |
556 | | - </p> |
557 | | - {issues.length > 0 && ( |
558 | | - <Tooltip.Root> |
559 | | - <Tooltip.Trigger asChild> |
560 | | - <div className='flex items-center'> |
561 | | - <Badge variant={getIssueBadgeVariant(issues[0].issue)} size='sm'> |
562 | | - {getIssueBadgeLabel(issues[0].issue)} |
563 | | - </Badge> |
564 | | - </div> |
565 | | - </Tooltip.Trigger> |
566 | | - <Tooltip.Content> |
567 | | - Update in: {affectedWorkflows.join(', ')} |
568 | | - </Tooltip.Content> |
569 | | - </Tooltip.Root> |
570 | | - )} |
571 | | - </div> |
| 549 | + collapsed={!isExpanded || !hasParams} |
| 550 | + disabled={!hasParams} |
| 551 | + onToggleCollapse={() => toggleToolExpanded(tool.name)} |
| 552 | + title={ |
| 553 | + <> |
| 554 | + <OverflowText |
| 555 | + label={tool.name} |
| 556 | + className='text-[var(--text-primary)]' |
| 557 | + focusTarget='nearest-interactive' |
| 558 | + /> |
572 | 559 | {tool.description && ( |
573 | | - <p className='mt-1 text-[var(--text-tertiary)] text-sm'> |
574 | | - {tool.description} |
575 | | - </p> |
| 560 | + <span className='mt-1 block whitespace-normal'>{tool.description}</span> |
576 | 561 | )} |
577 | | - </div> |
578 | | - {hasParams && ( |
579 | | - <ChevronDown |
580 | | - className={cn( |
581 | | - 'mt-0.5 size-[14px] shrink-0 text-[var(--text-muted)] transition-transform duration-200', |
582 | | - isExpanded && 'rotate-180' |
583 | | - )} |
584 | | - /> |
585 | | - )} |
586 | | - </Button> |
587 | | - |
| 562 | + </> |
| 563 | + } |
| 564 | + badge={ |
| 565 | + <> |
| 566 | + {issues.length > 0 && ( |
| 567 | + <Tooltip.Root> |
| 568 | + <Tooltip.Trigger asChild> |
| 569 | + <span className='flex shrink-0 items-center'> |
| 570 | + <Badge variant={getIssueBadgeVariant(issues[0].issue)} size='sm'> |
| 571 | + {getIssueBadgeLabel(issues[0].issue)} |
| 572 | + </Badge> |
| 573 | + </span> |
| 574 | + </Tooltip.Trigger> |
| 575 | + <Tooltip.Content> |
| 576 | + Update in: {affectedWorkflows.join(', ')} |
| 577 | + </Tooltip.Content> |
| 578 | + </Tooltip.Root> |
| 579 | + )} |
| 580 | + {hasParams && ( |
| 581 | + <ChevronDown |
| 582 | + className={cn( |
| 583 | + 'size-[14px] shrink-0 text-[var(--text-muted)] transition-transform duration-200', |
| 584 | + isExpanded && 'rotate-180' |
| 585 | + )} |
| 586 | + /> |
| 587 | + )} |
| 588 | + </> |
| 589 | + } |
| 590 | + > |
588 | 591 | {isExpanded && hasParams && ( |
589 | | - <div className='border-[var(--border-1)] border-t bg-[var(--surface-2)] px-2.5 py-2'> |
590 | | - <p className='mb-1.5 text-[var(--text-muted)] text-caption uppercase tracking-wide'> |
| 592 | + <> |
| 593 | + <p className='text-[var(--text-muted)] text-caption uppercase tracking-wide'> |
591 | 594 | Parameters |
592 | 595 | </p> |
593 | 596 | <div className='flex flex-col gap-1.5'> |
@@ -631,9 +634,9 @@ export function MCP() { |
631 | 634 | } |
632 | 635 | )} |
633 | 636 | </div> |
634 | | - </div> |
| 637 | + </> |
635 | 638 | )} |
636 | | - </div> |
| 639 | + </CollapsibleCard> |
637 | 640 | ) |
638 | 641 | })} |
639 | 642 | </div> |
|
0 commit comments