Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/1797127235_lumen.json
T

1 line
5.6 KiB
JSON

{"repo": "1797127235/lumen", "files": {"channels/cli/cmd/tui/component/dialog-retry-action.tsx": {"d0d9e419d79c83986a9971e342620dfb35886041": {"t": 1785596383.6518416, "n": 5252, "h": "98726b24714c4c69", "c": "import { RGBA, TextAttributes } from \"@opentui/core\"\nimport open from \"open\"\nimport { createSignal } from \"solid-js\"\nimport { selectedForeground, useTheme } from \"@tui/context/theme\"\nimport { useDialog, type DialogContext } from \"@tui/ui/dialog\"\nimport { Link } from \"@tui/ui/link\"\nimport { BgPulse } from \"./bg-pulse\"\nimport { useBindings } from \"../keymap\"\n\nconst GO_URL = \"https://opencode.ai/go\"\nconst PAD_X = 3\nconst PAD_TOP_OUTER = 1\nconst FOREGROUND_ALPHA = 186\n\nexport type DialogRetryActionProps = {\n title: string\n message: string\n label: string\n link?: string\n onClose?: (dontShowAgain?: boolean) => void\n}\n\nfunction runAction(props: DialogRetryActionProps, dialog: ReturnType<typeof useDialog>) {\n if (props.link) open(props.link).catch(() => {})\n props.onClose?.()\n dialog.clear()\n}\n\nfunction dismiss(props: DialogRetryActionProps, dialog: ReturnType<typeof useDialog>) {\n props.onClose?.(true)\n dialog.clear()\n}\n\nfunction panelOverlay(color: RGBA) {\n const [r, g, b] = color.toInts()\n return RGBA.fromInts(r, g, b, FOREGROUND_ALPHA)\n}\n\nexport function DialogRetryAction(props: DialogRetryActionProps) {\n const dialog = useDialog()\n const { theme } = useTheme()\n const fg = selectedForeground(theme)\n const showGoTreatment = () => props.link === GO_URL\n const textBg = () => (showGoTreatment() ? panelOverlay(theme.backgroundPanel) : undefined)\n const [selected, setSelected] = createSignal<\"dismiss\" | \"action\">(\"action\")\n\n useBindings(() => ({\n bindings: [\n {\n key: \"left\",\n desc: \"Previous retry option\",\n group: \"Dialog\",\n cmd: () => setSelected((value) => (value === \"action\" ? \"dismiss\" : \"action\")),\n },\n {\n key: \"right\",\n desc: \"Next retry option\",\n group: \"Dialog\",\n cmd: () => setSelected((value) => (value === \"action\" ? \"dismiss\" : \"action\")),\n },\n {\n key: \"tab\",\n desc: \"Next retry option\",\n group: \"Dialog\",\n cmd: () => setSelected((value) => (value === \"action\" ? \"dismiss\" : \"action\")),\n },\n {\n key: \"return\",\n desc: \"Confirm retry option\",\n group: \"Dialog\",\n cmd: () => {\n if (selected() === \"action\") runAction(props, dialog)\n else dismiss(props, dialog)\n },\n },\n ],\n }))\n\n return (\n <box>\n {showGoTreatment() ? (\n <box position=\"absolute\" top={-PAD_TOP_OUTER} left={0} right={0} bottom={0} zIndex={0}>\n <BgPulse />\n </box>\n ) : null}\n <box zIndex={1} paddingLeft={PAD_X} paddingRight={PAD_X} paddingBottom={1} gap={1}>\n <box flexDirection=\"row\" justifyContent=\"space-between\">\n <text attributes={TextAttributes.BOLD} fg={theme.text} bg={textBg()}>\n {props.title}\n </text>\n <text fg={theme.textMuted} bg={textBg()} onMouseUp={() => dialog.clear()}>\n esc\n </text>\n </box>\n <box gap={0}>\n <text fg={theme.textMuted} bg={textBg()}>\n {props.message}\n </text>\n </box>\n {props.link ? (\n showGoTreatment() ? (\n <box alignItems=\"center\" justifyContent=\"flex-end\" height={7} paddingBottom={1}>\n <Link href={props.link} fg={theme.primary} bg={textBg()} wrapMode=\"none\" />\n </box>\n ) : (\n <box width=\"100%\" flexDirection=\"row\" justifyContent=\"center\" paddingBottom={1}>\n <Link href={props.link} fg={theme.primary} wrapMode=\"none\" />\n </box>\n )\n ) : (\n <box paddingBottom={1} />\n )}\n <box flexDirection=\"row\" justifyContent=\"space-between\">\n <box\n paddingLeft={2}\n paddingRight={2}\n backgroundColor={selected() === \"dismiss\" ? theme.primary : RGBA.fromInts(0, 0, 0, 0)}\n onMouseOver={() => setSelected(\"dismiss\")}\n onMouseUp={() => dismiss(props, dialog)}\n >\n <text\n fg={selected() === \"dismiss\" ? fg : theme.textMuted}\n bg={selected() === \"dismiss\" ? undefined : textBg()}\n attributes={selected() === \"dismiss\" ? TextAttributes.BOLD : undefined}\n >\n don't show again\n </text>\n </box>\n <box\n paddingLeft={2}\n paddingRight={2}\n backgroundColor={selected() === \"action\" ? theme.primary : RGBA.fromInts(0, 0, 0, 0)}\n onMouseOver={() => setSelected(\"action\")}\n onMouseUp={() => runAction(props, dialog)}\n >\n <text\n fg={selected() === \"action\" ? fg : theme.text}\n bg={selected() === \"action\" ? undefined : textBg()}\n attributes={selected() === \"action\" ? TextAttributes.BOLD : undefined}\n >\n {props.label}\n </text>\n </box>\n </box>\n </box>\n </box>\n )\n}\n\nDialogRetryAction.show = (\n dialog: DialogContext,\n props: Pick<DialogRetryActionProps, \"title\" | \"message\" | \"label\" | \"link\">,\n) => {\n return new Promise<boolean>((resolve) => {\n dialog.replace(\n () => <DialogRetryAction {...props} onClose={(dontShow) => resolve(dontShow ?? false)} />,\n () => resolve(false),\n )\n })\n}\n"}}}}