aiellie

Search

Find a component, template or page

GitHub
Components

Work In Menu

A small button that says where work runs, opening a menu of places: local, a new local copy, a worktree or the cloud, with an optional row to connect an account.

Open full screen
fig. 01 · open it full screen from the corner

Installation

npx shadcn@latest add "@aiellie/work-in-menu"

shadcn needs the @aiellie registry in components.json first. npx aiellie add work-in-menu adds it on its first run, then installs the same way.

Work in menu chooses where an agent runs a task: on this machine, in a fresh local copy, in a git worktree or in the cloud. The trigger shows the choice with its icon. It starts from those four, and takes a list of your own to rename, reorder or replace them.

Getting started

  1. Hold the choice

    value is the id of the option chosen.

    components/task-composer.tsx
    "use client"
    
    import * as React from "react"
    
    import { WorkInMenu } from "@/components/aiellie/work-in-menu"
    
    export function TaskWorkIn() {
      const [workIn, setWorkIn] = React.useState("local")
    
      return <WorkInMenu value={workIn} onValueChange={setWorkIn} />
    }
  2. Offer to connect an account

    onConnect adds a row under the options, for linking an account that a cloud option needs. Without it the row is left out.

    <WorkInMenu
      value={workIn}
      onValueChange={setWorkIn}
      onConnect={() => router.push("/settings/connections")}
      connectLabel="Connect a cloud account"
    />

Anatomy

<button data-slot="work-in-menu"> {/* render, a small ghost Button by default */}
  <svg /> {/* the chosen option's icon */}
  <span class="sr-only">{label}: </span>
  {selected.name}
</button>

<div data-slot="menu-content">
  <div data-slot="menu-radio-group">
    <div data-slot="menu-radio-item" /> {/* one per option */}
  </div>
  <div data-slot="menu-separator" /> {/* only with onConnect */}
  <div data-slot="menu-item" /> {/* the connect row */}
</div>

Choosing an option closes the menu. While value matches no option the trigger shows a laptop and the label. WORK_IN_OPTIONS is exported, so a list of your own can start from it.

Examples

Your own options

Pass options with an icon each, and a label that fits them.

Extend the defaults

import { WORK_IN_OPTIONS } from "@/components/aiellie/work-in-menu"

const options = [...WORK_IN_OPTIONS, { id: "ssh", name: "Remote", icon: ServerStack01Icon }]

API reference

WorkInMenu

PropTypeDefaultDescription
valuestringrequiredThe id of the option chosen.
onValueChange(value: string) => voidrequiredCalled with the id chosen.
optionsWorkInOption[]WORK_IN_OPTIONSThe places to choose from, each { id, name, icon }.
onConnect() => voidShows a row under the options that links an account. Left out, the row is too.
connectLabelstring"Connect Claude Code on the web"What the connect row says.
labelstring"Work in"What is being chosen, read out ahead of the option's name.
renderReactElement<Button variant="ghost" size="sm" />The trigger's element.
side / alignMenuContent placementWhere the menu opens.

WORK_IN_OPTIONS

idname
localLocal
new-localNew local
worktreeWorktree
cloudCloud