Skip to content

Ticket queue

A help desk lists its support tickets. A segmented status choice, a sort toggle and a search box change the query, and the host answers with the matching tickets in order. A second page looks up a requester by email, then their account.

  • Choose Open: after a short pause only open tickets remain. Choose Pending, then Closed before the list comes back: the list shows the closed tickets, and Actions shows the pending fetch as superseded.
  • Choose Pending, then press Show oldest first before the list comes back: the list shows pending tickets, oldest first.
  • Reset, then press Show oldest first while the tickets first load: it is rejected as busy, and the toggle and the order stay newest first. Choose Closed once the list shows: the closed tickets come back oldest first, because the refused choice was still requested.
  • Type refund in Search and press Enter. Pick Pending: no pending ticket mentions a refund, so the “no matches” text shows.
  • Open Look up a requester. Change the email to sam@northwind.example and press Enter: Finding the requester…, then Loading their account…, then Northwind Freight.
  • Now change it to dana@lumen.example and press Enter twice quickly. Actions shows the first requester fetch as superseded and only one account fetch, for Lumen Studio: the superseded lookup never fetched an account.

tickets is a collection whose fetch takes the status and sort order as enum inputs and the search as free text. The host filters, searches and sorts; the document only renders what comes back:

{
"tickets": {
"type": "helpdesk.ticket",
"cardinality": "many",
"identity": "id",
"fields": {
"id": {
"kind": "string",
"required": true
},
"subject": {
"kind": "string",
"required": true
},
"status": {
"kind": "string",
"required": true,
"enum": [
"open",
"pending",
"closed"
]
},
"priority": {
"kind": "string",
"required": true,
"enum": [
"normal",
"urgent"
]
},
"updatedOn": {
"kind": "string",
"required": true
}
},
"capabilities": {
"fetch": {
"inputs": {
"status": {
"kind": "string",
"required": true,
"enum": [
"all",
"open",
"pending",
"closed"
]
},
"sort": {
"kind": "string",
"required": true,
"enum": [
"newest",
"oldest"
]
},
"search": {
"kind": "string",
"required": false,
"maxLength": 60
}
}
}
},
"sample": [
{
"id": "t_sample_1",
"subject": "Refund for a double charge",
"status": "open",
"priority": "urgent",
"updatedOn": "2026-09-24"
},
{
"id": "t_sample_2",
"subject": "Export to CSV",
"status": "pending",
"priority": "normal",
"updatedOn": "2026-09-20"
}
]
}
}

A choice, a sort toggle and a search box refetch

Section titled “A choice, a sort toggle and a search box refetch”

The status Choice is bound to the requested query, so choosing writes the status before commit fetches with the whole requested query and copies it to the applied query, which the sort toggle reads. The search Input edits the requested query and fetches on commit:

{
"status-choice": {
"type": "Choice",
"props": {
"label": "Status",
"display": "segmented",
"options": [
{
"value": "all",
"label": "All"
},
{
"value": "open",
"label": "Open"
},
{
"value": "pending",
"label": "Pending"
},
{
"value": "closed",
"label": "Closed"
}
],
"required": false,
"helpText": null,
"value": {
"$bindState": "/query/requested/status"
}
},
"children": [],
"on": {
"commit": [
{
"action": "fetch",
"params": {
"object": "tickets",
"inputs": {
"status": {
"$state": "/query/requested/status"
},
"sort": {
"$state": "/query/requested/sort"
},
"search": {
"$state": "/query/requested/search"
}
}
}
},
{
"action": "setState",
"params": {
"statePath": "/query/applied",
"value": {
"$state": "/query/requested"
}
}
}
]
}
},
"search": {
"type": "Input",
"props": {
"label": "Search",
"placeholder": "Subject words, like refund",
"inputType": "text",
"required": false,
"helpText": "Press Enter, or leave the field, to search. The host decides what matches.",
"maxLength": 60,
"value": {
"$bindState": "/query/requested/search"
},
"error": {
"$state": "/meta/objects/tickets/operations/fetch/error/fieldErrors/search"
}
},
"children": [],
"on": {
"commit": [
{
"action": "fetch",
"params": {
"object": "tickets",
"inputs": {
"status": {
"$state": "/query/requested/status"
},
"sort": {
"$state": "/query/requested/sort"
},
"search": {
"$state": "/query/requested/search"
}
}
}
},
{
"action": "setState",
"params": {
"statePath": "/query/applied",
"value": {
"$state": "/query/requested"
}
}
}
]
}
}
}

A newer press or commit replaces a fetch an earlier one started that is still loading, and since every fetch reads all requested choices, rapid presses on different controls combine. The startup fetch is never replaced: a press while it loads is rejected as busy before its copy runs, so the toggle keeps showing the last accepted choice, and the next request includes the refused choice. A failed fetch applies its query and hides the list while it stays failed and the error text says what went wrong. The search box sets maxLength: 60, the fetch’s own limit on search, so a person cannot type or paste a longer search; the search Input’s error stays as a backstop for a value that reaches the fetch some other way. While a retry loads, the previous rows can show until the new answer arrives.

The email Input’s commit runs two fetches in order. The second reads the first one’s answer, so it waits for the requester fetch to finish:

{
"lookup-email": {
"type": "Input",
"props": {
"label": "Requester email",
"placeholder": "dana@lumen.example",
"inputType": "email",
"required": false,
"helpText": "Press Enter to find the requester, then their account.",
"value": {
"$bindState": "/lookupEmail"
},
"error": {
"$state": "/meta/objects/requester/operations/fetch/error/fieldErrors/email"
}
},
"children": [],
"on": {
"commit": [
{
"action": "fetch",
"params": {
"object": "requester",
"inputs": {
"email": {
"$state": "/lookupEmail"
}
}
}
},
{
"action": "fetch",
"params": {
"object": "account",
"inputs": {
"accountId": {
"$state": "/objects/requester/data/accountId"
}
}
}
}
]
}
}
}

When a second commit replaces the first requester fetch, that fetch rejects as superseded, which stops the rest of its event: the old requester’s account is never fetched. A requester fetch that fails (no requester uses the email) does not reject, so the account fetch still runs, with the previous requester’s account id; the account card and its loading text also require the requester fetch to have succeeded, so a failed lookup never shows a stale account. An empty address, which Mica refuses before asking the host, shows its reason under the email field, in the Input’s error.

See Filter and sort a list for the rules behind each part.

Complete document — examples/documents/ticket-queue.json
examples/documents/ticket-queue.json
{
"envelopeVersion": 1,
"ui": {
"root": "app",
"elements": {
"app": {
"type": "PageStack",
"props": {
"name": "Ticket queue"
},
"children": [
"page-queue",
"page-lookup"
]
},
"page-queue": {
"type": "Page",
"props": {
"title": "Queue",
"background": "mist"
},
"children": [
"heading",
"search",
"status-choice",
"sort-row",
"loading",
"load-error",
"no-matches",
"ticket-list",
"to-lookup"
]
},
"heading": {
"type": "Heading",
"props": {
"content": "Support queue",
"level": "1",
"align": "left",
"accent": true
},
"children": []
},
"search": {
"type": "Input",
"props": {
"label": "Search",
"placeholder": "Subject words, like refund",
"inputType": "text",
"required": false,
"helpText": "Press Enter, or leave the field, to search. The host decides what matches.",
"maxLength": 60,
"value": {
"$bindState": "/query/requested/search"
},
"error": {
"$state": "/meta/objects/tickets/operations/fetch/error/fieldErrors/search"
}
},
"children": [],
"on": {
"commit": [
{
"action": "fetch",
"params": {
"object": "tickets",
"inputs": {
"status": {
"$state": "/query/requested/status"
},
"sort": {
"$state": "/query/requested/sort"
},
"search": {
"$state": "/query/requested/search"
}
}
}
},
{
"action": "setState",
"params": {
"statePath": "/query/applied",
"value": {
"$state": "/query/requested"
}
}
}
]
}
},
"sort-row": {
"type": "Stack",
"props": {
"direction": "horizontal",
"gap": "sm",
"align": "center",
"justify": "start",
"wrap": true,
"padding": "none",
"surface": null
},
"children": [
"sort-newest",
"sort-oldest"
]
},
"sort-newest": {
"type": "Button",
"props": {
"label": "Show oldest first",
"variant": "outline",
"size": "md",
"disabled": false,
"fullWidth": false
},
"children": [],
"on": {
"press": [
{
"action": "setState",
"params": {
"statePath": "/query/requested/sort",
"value": "oldest"
}
},
{
"action": "fetch",
"params": {
"object": "tickets",
"inputs": {
"status": {
"$state": "/query/requested/status"
},
"sort": {
"$state": "/query/requested/sort"
},
"search": {
"$state": "/query/requested/search"
}
}
}
},
{
"action": "setState",
"params": {
"statePath": "/query/applied",
"value": {
"$state": "/query/requested"
}
}
}
]
},
"visible": {
"$state": "/query/applied/sort",
"eq": "newest"
}
},
"sort-oldest": {
"type": "Button",
"props": {
"label": "Show newest first",
"variant": "outline",
"size": "md",
"disabled": false,
"fullWidth": false
},
"children": [],
"on": {
"press": [
{
"action": "setState",
"params": {
"statePath": "/query/requested/sort",
"value": "newest"
}
},
{
"action": "fetch",
"params": {
"object": "tickets",
"inputs": {
"status": {
"$state": "/query/requested/status"
},
"sort": {
"$state": "/query/requested/sort"
},
"search": {
"$state": "/query/requested/search"
}
}
}
},
{
"action": "setState",
"params": {
"statePath": "/query/applied",
"value": {
"$state": "/query/requested"
}
}
}
]
},
"visible": {
"$state": "/query/applied/sort",
"eq": "oldest"
}
},
"loading": {
"type": "Text",
"props": {
"content": "Loading tickets…",
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$state": "/meta/objects/tickets/operations/fetch/phase",
"eq": "loading"
}
},
"load-error": {
"type": "Text",
"props": {
"content": {
"$state": "/meta/objects/tickets/operations/fetch/error/message"
},
"size": "md",
"tone": "accent",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$state": "/meta/objects/tickets/operations/fetch/phase",
"eq": "error"
}
},
"no-matches": {
"type": "Text",
"props": {
"content": "No tickets match. Try another status or search.",
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": [],
"visible": [
{
"$state": "/meta/objects/tickets/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/meta/objects/tickets/count",
"eq": 0
}
]
},
"ticket-list": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "sm",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "none",
"surface": null
},
"children": [
"ticket-card"
],
"visible": {
"$state": "/meta/objects/tickets/operations/fetch/phase",
"neq": "error"
},
"repeat": {
"statePath": "/objects/tickets/data",
"key": "id"
}
},
"ticket-card": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "sm",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "md",
"surface": "soft"
},
"children": [
"ticket-subject",
"ticket-status",
"ticket-updated",
"ticket-urgent"
]
},
"ticket-subject": {
"type": "Heading",
"props": {
"content": {
"$item": "subject"
},
"level": "3",
"align": "left",
"accent": false
},
"children": []
},
"ticket-status": {
"type": "Text",
"props": {
"content": {
"$item": "status"
},
"size": "md",
"tone": "default",
"align": "left",
"italic": false
},
"children": []
},
"ticket-updated": {
"type": "Text",
"props": {
"content": {
"$item": "updatedOn"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"ticket-urgent": {
"type": "Text",
"props": {
"content": "Urgent",
"size": "md",
"tone": "accent",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$item": "priority",
"eq": "urgent"
}
},
"to-lookup": {
"type": "Button",
"props": {
"label": "Look up a requester",
"variant": "outline",
"size": "md",
"disabled": false,
"fullWidth": false
},
"children": [],
"on": {
"press": {
"action": "goToPage",
"params": {
"page": "page-lookup"
}
}
}
},
"page-lookup": {
"type": "Page",
"props": {
"title": "Requester",
"background": "mist"
},
"children": [
"lookup-heading",
"lookup-email",
"lookup-loading",
"lookup-error",
"account-loading",
"account-card",
"to-queue"
]
},
"lookup-heading": {
"type": "Heading",
"props": {
"content": "Find a requester",
"level": "1",
"align": "left",
"accent": true
},
"children": []
},
"lookup-email": {
"type": "Input",
"props": {
"label": "Requester email",
"placeholder": "dana@lumen.example",
"inputType": "email",
"required": false,
"helpText": "Press Enter to find the requester, then their account.",
"value": {
"$bindState": "/lookupEmail"
},
"error": {
"$state": "/meta/objects/requester/operations/fetch/error/fieldErrors/email"
}
},
"children": [],
"on": {
"commit": [
{
"action": "fetch",
"params": {
"object": "requester",
"inputs": {
"email": {
"$state": "/lookupEmail"
}
}
}
},
{
"action": "fetch",
"params": {
"object": "account",
"inputs": {
"accountId": {
"$state": "/objects/requester/data/accountId"
}
}
}
}
]
}
},
"lookup-loading": {
"type": "Text",
"props": {
"content": "Finding the requester…",
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$state": "/meta/objects/requester/operations/fetch/phase",
"eq": "loading"
}
},
"lookup-error": {
"type": "Text",
"props": {
"content": {
"$state": "/meta/objects/requester/operations/fetch/error/message"
},
"size": "md",
"tone": "accent",
"align": "left",
"italic": false
},
"children": [],
"visible": {
"$state": "/meta/objects/requester/operations/fetch/phase",
"eq": "error"
}
},
"account-loading": {
"type": "Text",
"props": {
"content": "Loading their account…",
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": [],
"visible": [
{
"$state": "/meta/objects/requester/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/meta/objects/account/operations/fetch/phase",
"eq": "loading"
}
]
},
"account-card": {
"type": "Stack",
"props": {
"direction": "vertical",
"gap": "sm",
"align": "stretch",
"justify": "start",
"wrap": false,
"padding": "md",
"surface": "soft"
},
"children": [
"account-name",
"account-plan",
"account-requester"
],
"visible": [
{
"$state": "/meta/objects/requester/operations/fetch/phase",
"eq": "success"
},
{
"$state": "/meta/objects/account/operations/fetch/phase",
"eq": "success"
}
]
},
"account-name": {
"type": "Heading",
"props": {
"content": {
"$state": "/objects/account/data/name"
},
"level": "2",
"align": "left",
"accent": false
},
"children": []
},
"account-plan": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/account/data/plan"
},
"size": "md",
"tone": "default",
"align": "left",
"italic": false
},
"children": []
},
"account-requester": {
"type": "Text",
"props": {
"content": {
"$state": "/objects/requester/data/name"
},
"size": "md",
"tone": "muted",
"align": "left",
"italic": false
},
"children": []
},
"to-queue": {
"type": "Button",
"props": {
"label": "Back to the queue",
"variant": "outline",
"size": "md",
"disabled": false,
"fullWidth": false
},
"children": [],
"on": {
"press": {
"action": "goToPage",
"params": {
"page": "page-queue"
}
}
}
},
"status-choice": {
"type": "Choice",
"props": {
"label": "Status",
"display": "segmented",
"options": [
{
"value": "all",
"label": "All"
},
{
"value": "open",
"label": "Open"
},
{
"value": "pending",
"label": "Pending"
},
{
"value": "closed",
"label": "Closed"
}
],
"required": false,
"helpText": null,
"value": {
"$bindState": "/query/requested/status"
}
},
"children": [],
"on": {
"commit": [
{
"action": "fetch",
"params": {
"object": "tickets",
"inputs": {
"status": {
"$state": "/query/requested/status"
},
"sort": {
"$state": "/query/requested/sort"
},
"search": {
"$state": "/query/requested/search"
}
}
}
},
{
"action": "setState",
"params": {
"statePath": "/query/applied",
"value": {
"$state": "/query/requested"
}
}
}
]
}
}
},
"state": {
"query": {
"requested": {
"status": "all",
"sort": "newest",
"search": ""
},
"applied": {
"status": "all",
"sort": "newest",
"search": ""
}
},
"lookupEmail": "dana@lumen.example"
}
},
"meta": {
"pack": {
"id": "mica.core",
"version": "1.0.0"
}
},
"objects": {
"tickets": {
"type": "helpdesk.ticket",
"cardinality": "many",
"identity": "id",
"fields": {
"id": {
"kind": "string",
"required": true
},
"subject": {
"kind": "string",
"required": true
},
"status": {
"kind": "string",
"required": true,
"enum": [
"open",
"pending",
"closed"
]
},
"priority": {
"kind": "string",
"required": true,
"enum": [
"normal",
"urgent"
]
},
"updatedOn": {
"kind": "string",
"required": true
}
},
"capabilities": {
"fetch": {
"inputs": {
"status": {
"kind": "string",
"required": true,
"enum": [
"all",
"open",
"pending",
"closed"
]
},
"sort": {
"kind": "string",
"required": true,
"enum": [
"newest",
"oldest"
]
},
"search": {
"kind": "string",
"required": false,
"maxLength": 60
}
}
}
},
"sample": [
{
"id": "t_sample_1",
"subject": "Refund for a double charge",
"status": "open",
"priority": "urgent",
"updatedOn": "2026-09-24"
},
{
"id": "t_sample_2",
"subject": "Export to CSV",
"status": "pending",
"priority": "normal",
"updatedOn": "2026-09-20"
}
]
},
"requester": {
"type": "helpdesk.requester",
"cardinality": "one",
"identity": "id",
"fields": {
"id": {
"kind": "string",
"required": true
},
"name": {
"kind": "string",
"required": true
},
"accountId": {
"kind": "string",
"required": true
}
},
"capabilities": {
"fetch": {
"inputs": {
"email": {
"kind": "string",
"required": true,
"format": "email"
}
}
}
},
"sample": {
"id": "req_sample",
"name": "Sample Requester",
"accountId": "acc_sample"
}
},
"account": {
"type": "crm.account",
"cardinality": "one",
"identity": "id",
"fields": {
"id": {
"kind": "string",
"required": true
},
"name": {
"kind": "string",
"required": true
},
"plan": {
"kind": "string",
"required": true,
"enum": [
"starter",
"growth",
"scale"
]
}
},
"capabilities": {
"fetch": {
"inputs": {
"accountId": {
"kind": "string",
"required": true
}
}
}
},
"sample": {
"id": "acc_sample",
"name": "Sample Account",
"plan": "growth"
}
}
},
"lifecycle": {
"startup": [
{
"action": "fetch",
"params": {
"object": "tickets",
"inputs": {
"status": {
"$state": "/query/requested/status"
},
"sort": {
"$state": "/query/requested/sort"
},
"search": {
"$state": "/query/requested/search"
}
}
}
}
]
}
}