/** @jsxImportSource @opentui/solid */ import { createSignal, createEffect, onCleanup, Show } from 'solid-js' import { Plugin } from '@opencode/plugin/tui' import type { HueScale } from '@opencode/theme/tui' import { setupOcm } from './tui-plugin.js' import { showMultiRunLaunchDialog, showMultiRunsDialog } from './tui-multi-run-dialogs.js' import { formatMoveProgress } from './move-progress.js' import type { MoveProgress } from './move-progress.js' import { readRemoteContext, remoteDisplayName } from './remote-context.js' import { readState } from './state.js' const SPINNER_INTERVAL_MS = 80 export default Plugin.define({ id: 'ocm', async setup(context) { const [moveProgress, setMoveProgress] = createSignal(null) const moveIndicator = () => { const [frame, setFrame] = createSignal(0) createEffect(() => { if (!moveProgress()) return const timer = setInterval(() => setFrame((f) => f + 1), SPINNER_INTERVAL_MS) onCleanup(() => clearInterval(timer)) }) return ( {(progress) => {formatMoveProgress(progress(), frame())}} ) } context.ui.slot({ append: 'prompt.footer.status', render: moveIndicator }) const remote = readRemoteContext(process.env) if (remote) { const managerLabel = remoteDisplayName(remote, readState()) const namedHues: Readonly> = context.theme.hue const indicator = () => ( {managerLabel} {remote.repoName && ยท {remote.repoName}} ) context.ui.slot({ append: 'prompt.footer.status', render: indicator }) context.ui.slot({ append: 'home.footer.status', render: indicator }) } return setupOcm(context, setMoveProgress, { remote, dialogs: { multiRunLaunch: (props) => showMultiRunLaunchDialog(context, props), multiRuns: (props) => showMultiRunsDialog(context, props), }, }) }, })