agentleFS
NazmusSayadNazmusSayad/offsite/.agents/skills/dialog/SKILL.md

dialog

Skill10 starsChanged 11 days agoMITView on GitHub

Builds dialogs, alert dialogs, popovers, hover cards, dropdown menus and context menus in the offsite client so nothing they need runs while they are closed. MUST USE when adding, changing or reviewing any of them, including the component that opens them.

  • In this repositoryOne other file it gives its agents.

The file

Files
SKILL.md

Rule

While closed, a dialog or menu must cost nothing beyond its root and trigger. Everything it needs when open lives in its own content component, rendered inside the content element. Radix (radix-ui, wrapped in apps/client/src/components/ui) does not render the content element while closed, so that component, its hooks and its effects do not exist until the user opens it.

The component that opens it

  • Keeps only the open state and the trigger.
  • Passes the content component only what identifies the subject (for example session, machine, projectId) and callbacks such as onClose or onConfirm.
  • Holds no state, hooks, effects, data loading, derived values, handlers or text that only the open dialog or menu uses.

The content component

  • Owns all of that state, hooks, effects, data loading, derived values, handlers and text.
  • Is rendered as a child of DialogContent, AlertDialogContent, PopoverContent, HoverCardContent, DropdownMenuContent or ContextMenuContent, never around it.
function SessionRow(props: { session: MachineSession }) {
  const [stopping, setStopping] = useState(false)
  return (
    <>
      <button onClick={() => setStopping(true)}>Mark done</button>
      <AlertDialog open={stopping} onOpenChange={setStopping}>
        <AlertDialogContent>
          <StopDialog
            session={props.session}
            onClose={() => setStopping(false)}
          />
        </AlertDialogContent>
      </AlertDialog>
    </>
  )
}

function StopDialog(props: { session: MachineSession; onClose: () => void }) {
  const [stopping, setStopping] = useState(false)
  return (
    <>
      <AlertDialogHeader>
        <AlertDialogTitle>Stop running work?</AlertDialogTitle>
      </AlertDialogHeader>
      <AlertDialogFooter>
        <AlertDialogCancel>Cancel</AlertDialogCancel>
        <AlertDialogAction
          disabled={stopping}
          onClick={async () => {
            setStopping(true)
            await deactivateSession(props.session.machine, props.session.id)
            props.onClose()
          }}
        >
          Stop and Mark Done
        </AlertDialogAction>
      </AlertDialogFooter>
    </>
  )
}

Wrong

  • A component that renders the content element itself and is placed inside the root: <AlertDialog open={stopping}><StopDialog /></AlertDialog> where StopDialog returns <AlertDialogContent>. StopDialog mounts while closed and its hooks run.
  • Hooks, effects or data loading in the opening component that only the open dialog or menu uses.
  • forceMount or keepMounted on any content element.
  • Building the dialog's or menu's items, lists or derived data in the opening component and passing them in.

Lists

Rows, cards and other repeated items must stay light. A row holds one open flag per dialog or menu and nothing else for them.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.