# Session expired

The sign-in ran out while the app was open. It blocks the page (nothing behind it would work) but keeps it: signing in again returns you to the same place. Say what was kept only when the app really kept it.

- Registry name: `session-expired` (`@candor/session-expired`)
- Tier: Pro. Installing it needs a Pro, Premium or Team licence key: the person runs `npx candor-ui key <key>` themselves; never ask for the key in chat or write it to a file.
- Docs: https://candor.themethodic.com/docs/session-expired

## Install

```bash
npx candor-ui add session-expired
```

Run `npx candor-ui@latest init` once first (https://candor.themethodic.com/get-started.md). Without the CLI: `npx shadcn@latest add @candor/session-expired`.
It brings in: button, dialog, locale.
npm packages: lucide-react@^1.67.0.

## Example

```tsx
"use client"

import * as React from "react"
import { SessionExpiredDialog } from "@/components/session-expired"
import { Button } from "@/components/ui/button"

export default function Example() {
  const [open, setOpen] = React.useState(false)
  const [signingIn, setSigningIn] = React.useState(false)
  const signIn = () => {
    setSigningIn(true)
    // Your sign-in flow goes here; this one just succeeds after a moment.
    window.setTimeout(() => {
      setSigningIn(false)
      setOpen(false)
    }, 1200)
  }
  return (
    <>
      <Button variant="outline" onClick={() => setOpen(true)}>
        End the session
      </Button>
      <SessionExpiredDialog
        open={open}
        email="sam@acme.example"
        kept="Your unsent message is kept."
        signingIn={signingIn}
        onSignIn={signIn}
        onSignOut={() => setOpen(false)}
      />
    </>
  )
}
```

## <SessionExpiredDialog>

Props:

- `open: boolean`: Whether the dialog is showing. It can't be dismissed; only signing in or out closes it.
- `email: string`: Who was signed in, so a different person doesn't carry on by mistake.
- `kept?: string | undefined`: What the app kept, e.g. "Your unsent message is kept." Omit if nothing is.
- `signingIn?: boolean | undefined` (default `false`): A sign-in is under way; the button waits and can't be pressed again. Defaults to false.
- `failed?: string | undefined`: Why the last sign-in attempt failed.
- `onSignIn: () => void`: Called when the person chooses to sign in again (or try again after a failure).
- `onSignOut?: (() => void) | undefined`: Shows "Not you? Sign out"; called when it's pressed.

## Strings (`sessionExpired`)

The fixed words, English by default. Override any of them under `sessionExpired` in `<LocaleProvider strings={{ sessionExpired: { … } }}>`; the table is exported as `sessionExpiredStrings`.

- `title`: Your session has ended
- `signInAgainAs`: Sign in again as {email} to carry on.
- `waiting`: Waiting for sign-in…
- `tryAgain`: Try again
- `signInAgain`: Sign in again
- `notYou`: Not you? Sign out

## Rules for using Candor UI

- Components take plain typed data. Never pass model output as HTML or render it as a link; messages are typed blocks.
- A control that can't be used says why: wrap it in `<Locked reason="…">`, don't just disable it.
- Don't show a value you don't have: leave it out (it renders as —) rather than guess. An estimate is labelled as one.
- Nothing is pre-selected in a decision a person makes, and the agent is named from your app's data, never from model output.
- Your app's words go in `LocaleProvider` (fixed strings) and `TermsProvider` (nouns); entity kinds and agent roles in `EntityKindsProvider` and `AgentRolesProvider`.
