Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 8 additions & 35 deletions packages/treebeard/src/components/LaunchButtons.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useEffect, useState } from 'react'
import { ActionIcon, Group, Tooltip } from '@mantine/core'
import { IconGhost, IconPrison } from '@tabler/icons-react'
import { IconCopy, IconGhost } from '@tabler/icons-react'
import { IdeIcon } from './IdeIcon'
import { IDE_REGISTRY } from '../shared/ide-registry'
import { rpc } from '../rpc'
Expand All @@ -13,30 +12,6 @@ interface LaunchButtonsProps {

export function LaunchButtons({ worktreePath, defaultIde }: LaunchButtonsProps) {
const ide = IDE_REGISTRY[defaultIde]
const [pippinPath, setPippinPath] = useState<string | null>(null)

useEffect(() => {
let cancelled = false

const loadPippinPath = async () => {
try {
const result = await rpc().request['system:pippinPath']({})
if (!cancelled) {
setPippinPath(result)
}
} catch {
if (!cancelled) {
setPippinPath(null)
}
}
}

void loadPippinPath()

return () => {
cancelled = true
}
}, [])

const handleIde = async () => {
await rpc().request['launch:ide']({ ideId: defaultIde, worktreePath })
Expand All @@ -46,8 +21,8 @@ export function LaunchButtons({ worktreePath, defaultIde }: LaunchButtonsProps)
await rpc().request['launch:ghostty']({ worktreePath })
}

const handlePippinShell = async () => {
await rpc().request['launch:pippinShell']({ worktreePath })
const handleCopyPath = () => {
void navigator.clipboard.writeText(worktreePath)
}

return (
Expand All @@ -62,13 +37,11 @@ export function LaunchButtons({ worktreePath, defaultIde }: LaunchButtonsProps)
<IconGhost size={16} />
</ActionIcon>
</Tooltip>
{pippinPath && (
<Tooltip label="Open Pippin shell">
<ActionIcon variant="subtle" color="grape" size="sm" onClick={handlePippinShell}>
<IconPrison size={16} />
</ActionIcon>
</Tooltip>
)}
<Tooltip label="Copy path">
<ActionIcon variant="subtle" color="gray" size="sm" onClick={handleCopyPath}>
<IconCopy size={16} />
</ActionIcon>
</Tooltip>
</Group>
)
}
Loading