> ## Documentation Index
> Fetch the complete documentation index at: https://docs.textql.com/llms.txt
> Use this file to discover all available pages before exploring further.

# The Cell message

> The cell snapshot type emitted by both chat streams.

Both [watchChat](/api-reference/sdk/streaming/watch-chat) and
[streamChat](/api-reference/sdk/streaming/stream-chat) emit `Cell` snapshots.
A cell is re-sent as it evolves (e.g. token-by-token markdown) — **upsert by
`cell.id`**. Use `complete` and `lifecycle` as described below to determine
when a cell is finished.

## Shape in TypeScript

```typescript theme={null}
import { CellLifecycle, type Cell } from "@textql/sdk/generated/connect/public/chat_pb.js";
import { timestampDate } from "@bufbuild/protobuf/wkt";

function handle(cell: Cell) {
  cell.id;              // string — upsert key
  cell.complete;        // boolean
  cell.generated;       // boolean — true = model-authored
  cell.lifecycle;       // CellLifecycle enum
  cell.execError;       // string | undefined
  timestampDate(cell.timestamp!); // API timestamp → Date

  switch (cell.value.case) {
    case "mdCell":
      cell.value.value.content;          // streamed markdown
      break;
    case "ansCell":
      cell.value.value.content;          // final answer text
      break;
    case "sqlCell":
      cell.value.value.query;
      break;
    // ...one case per tool: pyCell, wsCell, dashboardCell, reportCell,
    // metricsCell, mcpToolCell, tableauCell, powerbiCell, and more
  }
}
```

## Knowing When a Cell Is Finished

```typescript theme={null}
const TERMINAL = new Set([CellLifecycle.EXECUTED, CellLifecycle.HALTED]);

function isFinished(cell: Cell): boolean {
  if (TERMINAL.has(cell.lifecycle)) return true;
  return cell.complete === true;
}
```

Treat `complete: true` as authoritative even when the lifecycle still reads
`CREATED` — text cells never pass through an "executing" phase, so their
lifecycle may never advance.

| `CellLifecycle`        | Meaning                       |
| ---------------------- | ----------------------------- |
| `CREATING` / `CREATED` | authored, not (yet) executing |
| `EXECUTING`            | tool running                  |
| `EXECUTED`             | terminal — success            |
| `HALTED`               | terminal — stopped            |
| `HANDOFF_PENDING`      | paused for human handoff      |
