sanity-studio-listeners
БесплатноБез исполняемых скриптовНе проверенKeep Sanity Studio customizations (custom tools, inputs, document views, structure and plugins) from opening a real-time listener per document, which fills…
от sanity-io★ 203 звезды на GitHubОб этом скилле
Studio listeners
Studio keeps data live with listeners: long-lived requests that stream changes from the Sanity API. A browser runs at most 100 requests at a time on its connection to the API, and every Studio tab shares that connection (on HTTP/1.1, browsers open only 6 connections per host). A listener holds its slot for as long as it is open, and a Studio tab normally has 6 to 12 open.
Code that opens a listener for every item it renders multiplies by items, then by tabs. Once the slots run out, every request in every tab waits: the newest tab hangs on its spinner, documents and previews stop loading, and a tab that does load can show missing validation errors. The goal is that your code adds a constant number of listeners, never one per item.
Studio already keeps one listener open that follows every document in the dataset. Read documents, validation and permissions through it, and open a listener of your own only when it can't serve the query.
Workflow
Find listeners opened per item. Look in components rendered once per card, row, list item, search result or preview for:
useValidationStatus(oruseDocumentPairPermissions(withoutlistener: 'global'. By default they load the document the way the editor does, which opens a listener for it.documentStore.listenQuery(,listenQuery(,client.listen(,client.observable.listen(. Every call opens its own listener, even for a query another component already runs.useListeningQuery(fromsanity-plugin-utils, and plugins built on it. Each call opens a listener. As of 2.0.23, when the listener fails, its error handler throws "You provided an invalid object where a stream was expected" and the hook stops updating.
Also look for the same query run by several components (a settings document read by the structure, a tool and a badge).
Check the Studio version.
{listener: 'global'}needssanity6.24.0 or later. On an older version, propose the upgrade first (see thesanity-studio-upgradeskill).Replace each one by what the item needs:
Per item you need Use Listeners added Validation status useValidationStatus(id, type, {listener: 'global'})0 A permission check useDocumentPairPermissions({id, type, permission, listener: 'global'})0 Live values of a document useDocumentPreviewStore().unstable_observeDocument(id)(orunstable_observeDocuments([...ids]))0 Which documents match a filter you can't know by id One documentStore.listenQueryfor the whole screen, results passed down1 Full code for each: references/patterns.md.
Render less. Every per-item cost is paid for every rendered item, on screen or not. Paginate long lists and virtualize long boards.
Handle errors. See the error rules below.
Verify. Count the tab's listeners with the screen open (below). Up to about 12 is fine, and the count must not grow when the list gets longer. For screens that matter, add the listener budget test from references/patterns.md.
Rules for 'global' mode
- It reflects saved changes. A change is seen once it has been saved and is visible to
queries, a moment after the keystroke. That is right for lists, boards and dashboards. Keep the
default (
'document') only in components rendered inside the document form, next to the editor. - The id picks the version. A published id validates the published document. If editors work
in drafts, pass
drafts.<id>when a draft exists, or errors in unpublished changes won't show ("Validating what editors see" in the patterns). - Wrap lists in an error boundary. The hooks retry a failed load a few times, then throw while rendering. One failure should show a message, not crash the tool.
unstable_observeDocumentfollows one exact id and emitsundefinedwhen the document doesn't exist, so startuseObservablefromnullto tell loading from missing. To show the draft when there is one, observe[getDraftId(id), getPublishedId(id)]together and usedraft ?? published.
Rules for a listener of your own
Some queries can't be followed by id: a board of every document in a status, a filtered list,
search results. Only a listener with the query's filter knows when to fetch again. Use
documentStore.listenQuery, and treat every call as spending one of the browser's 100 slots in
every tab where the screen is open:
- Only when the table above has nothing that fits.
- Once
Установить sanity-studio-listeners в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл sanity-studio-listeners?
Keep Sanity Studio customizations (custom tools, inputs, document views, structure and plugins) from opening a real-time listener per document, which fills the browser's shared connection to the Sanity API and makes Studio hang when editors have several tabs open. Use when writing or reviewing Studio code that shows live data, validation or permissions for many documents (lists, boards, tables, review queues, dashboards); when code calls useValidationStatus, useDocumentPairPermissions, documentStore.listenQuery, listenQuery, client.listen or useListeningQuery from sanity-plugin-utils; or when editors report Studio stuck on its loading spinner or "Trying to connect…", "Could not establish EventSource connection", or that closing other Studio tabs fixes it.
Как установить скилл sanity-studio-listeners?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл sanity-studio-listeners запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic