Skip to content

feat: use lit-store internally instead of reyling on vanilla store dependency#6267

Open
fredericbahr wants to merge 1 commit into
TanStack:betafrom
fredericbahr:feat-lit-store-integration
Open

feat: use lit-store internally instead of reyling on vanilla store dependency#6267
fredericbahr wants to merge 1 commit into
TanStack:betafrom
fredericbahr:feat-lit-store-integration

Conversation

@fredericbahr

@fredericbahr fredericbahr commented May 16, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • Chores

    • Updated @tanstack/lit-store dependency to v0.13.2.
  • New Features

    • Added a new lowercase table.subscribe API and subscribe directive for fine-grained template subscriptions.
    • Added a table.setData convenience method.
  • Documentation

    • Updated Lit docs and examples to demonstrate table.subscribe, single persistent table instantiation, and state-driven updates.
  • Behavior

    • Templates now re-evaluate only when selected state slices change, reducing unnecessary renders.

@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Bump lit-table to @tanstack/lit-store@^0.13.2, add a typed Lit subscribe AsyncDirective, expose subscribe and setData on tables instead of an inline Subscribe implementation, and update docs/examples to use table.subscribe and persistent table instances.

Changes

Store package migration and selector refactoring

Layer / File(s) Summary
Dependency and import migration to @tanstack/lit-store
packages/lit-table/package.json, packages/lit-table/src/TableController.ts, packages/lit-table/src/reactivity.ts, packages/lit-table/src/index.ts
Package dependency updated to @tanstack/lit-store@^0.13.2; batch/createAtom and store-related types now import from @tanstack/lit-store; package entry re-exports subscribe directive.
Subscribe AsyncDirective implementation
packages/lit-table/src/subscribe-directive.ts
Adds SubscribeDirective (extends AsyncDirective) and a typed subscribe wrapper with overloads for identity and selector-based subscriptions; bridges Lit directive lifecycle to TanStackStoreSelector and returns noChange when appropriate.
TableController API and wiring
packages/lit-table/src/TableController.ts
TableController now returns table instances augmented with the exported subscribe directive and a setData(data) helper; removed the old exported SubscribeSource type and the inline Subscribe implementation; updated public LitTable typing and imports.
Docs and examples: use table.subscribe and persistent table instance
docs/framework/lit/guide/table-state.md, docs/framework/lit/lit-table.md, packages/lit-table/skills/..., examples/lit/basic-subscribe/*
Documentation updated to use table.subscribe (lowercase) with stable selector examples; PeopleTable example changed to use a persistent private table with updated() calling setOption/setData; new basic-subscribe example and supporting files added demonstrating fine-grained subscriptions and example data generation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • TanStack/table#6289: touches packages/lit-table/src/reactivity.ts and reactivity bindings similar to this change.

Suggested reviewers

  • schiller-manuel
  • KevinVandy

Poem

🐰 I nibble code in moonlit rows,
New stores and subscribes help it grow,
Small hops of change, docs set right,
Tables steady through the night —
I twitch my nose and watch updates flow.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes the main change: migrating from vanilla @tanstack/store to @tanstack/lit-store internally, which is reflected throughout the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fredericbahr fredericbahr changed the title feat: use lit-store internally instead of reyling on vanilla store dependency Draft: feat: use lit-store internally instead of reyling on vanilla store dependency May 16, 2026
@fredericbahr fredericbahr marked this pull request as draft May 16, 2026 17:34
@fredericbahr fredericbahr changed the title Draft: feat: use lit-store internally instead of reyling on vanilla store dependency feat: use lit-store internally instead of reyling on vanilla store dependency May 16, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/lit-table/src/TableController.ts`:
- Around line 217-218: Cache and reuse selector instances per source/selector
pair to avoid creating a new TanStackStoreSelector on every Subscribe call: add
a private two-level cache field (e.g., _selectorCache: WeakMap<any, Map<any,
TanStackStoreSelector<unknown>>> ) on TableController, update
_getOrCreateSelector(source, selector) to look up and return an existing
instance from _selectorCache[source].get(selector) or create, store, and return
a new one; ensure keys use the raw selector object/function (handle undefined
selectors consistently). Also update hostDisconnected (or appropriate teardown)
to remove the source entry from _selectorCache so entries can be
garbage-collected when a source is gone.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a4fff87a-9368-42bf-8177-7772f2a4b78d

📥 Commits

Reviewing files that changed from the base of the PR and between 05f3ed1 and 275b166.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/lit-table/package.json
  • packages/lit-table/src/TableController.ts
  • packages/lit-table/src/reactivity.ts

Comment on lines +217 to +218
const storeSelector: TanStackStoreSelector<unknown> =
this._getOrCreateSelector(source, props.selector)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Locate TanStackStoreSelector implementation =="
selector_files="$(fd -i 'TanStackStoreSelector.*\.ts$' || true)"
if [ -z "${selector_files}" ]; then
  echo "No TanStackStoreSelector source file found in-repo (may be external package)."
else
  while IFS= read -r f; do
    echo "---- $f ----"
    rg -n -C3 'class\s+TanStackStoreSelector|addController\(|subscribe\(|unsubscribe\(' "$f"
  done <<< "${selector_files}"
fi

echo
echo "== Inspect creation sites in TableController =="
rg -n -C3 '_getOrCreateSelector|new TanStackStoreSelector|storeSelector\.value' packages/lit-table/src/TableController.ts

Repository: TanStack/table

Length of output: 1193


🏁 Script executed:

cat -n packages/lit-table/src/TableController.ts | head -n 320 | tail -n 100

Repository: TanStack/table

Length of output: 3667


🏁 Script executed:

rg -n 'import.*TanStackStoreSelector|from.*TanStackStoreSelector' packages/lit-table/src/TableController.ts

Repository: TanStack/table

Length of output: 120


Cache selector instances; new instance created on every Subscribe call.

Line 279 creates a fresh TanStackStoreSelector on each Subscribe invocation. The TODO comment on line 269 acknowledges this concern. In render-heavy usage, this accumulates controller and subscription instances without cleanup, since hostDisconnected only cleans up the main store subscriptions, not these selector instances.

Implement a two-level cache using WeakMap<source, Map<selector, instance>> to reuse instances per (source, selector) pair. The WeakMap ensures the cache is garbage-collected when sources are no longer referenced.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/lit-table/src/TableController.ts` around lines 217 - 218, Cache and
reuse selector instances per source/selector pair to avoid creating a new
TanStackStoreSelector on every Subscribe call: add a private two-level cache
field (e.g., _selectorCache: WeakMap<any, Map<any,
TanStackStoreSelector<unknown>>> ) on TableController, update
_getOrCreateSelector(source, selector) to look up and return an existing
instance from _selectorCache[source].get(selector) or create, store, and return
a new one; ensure keys use the raw selector object/function (handle undefined
selectors consistently). Also update hostDisconnected (or appropriate teardown)
to remove the source entry from _selectorCache so entries can be
garbage-collected when a source is gone.

@KevinVandy

Copy link
Copy Markdown
Member

@fredericbahr how essential is this PR for this table one? TanStack/store#329

@fredericbahr

Copy link
Copy Markdown
Author

@KevinVandy for an alignment with other implementation and readability i believe it is essential.
If (for some reason) its not preferred to merge the MR in Tanstack/store, I could implement some logic for retrieving the selected state manually again from the selector function

@fredericbahr fredericbahr force-pushed the feat-lit-store-integration branch from 275b166 to 7afe941 Compare June 5, 2026 18:27
@fredericbahr fredericbahr changed the base branch from alpha to beta June 5, 2026 18:29
@fredericbahr fredericbahr force-pushed the feat-lit-store-integration branch 2 times, most recently from 3fdd8c3 to 3e5b3ee Compare June 8, 2026 19:32
@fredericbahr

fredericbahr commented Jun 8, 2026

Copy link
Copy Markdown
Author

@KevinVandy looking more closely into the Subscribe pattern in other adapters I believe that an async directive is the right pattern to be used in lit to enable fine-grained reactivity outside lits update lifecylce, so the template only updates when the atom/store is updated.

In order to push this change forward, i actually need TanStack/store#329. Maybe we can discuss the main reason this is not wanted within Tanstack/store so i can have a clear picture to work around it or come up with a different solution.

Tomorrow i try to add an example for the subscribe directive so the solution can be evaluated and tested within a running example.

@fredericbahr fredericbahr force-pushed the feat-lit-store-integration branch from 3e5b3ee to 9105b12 Compare June 9, 2026 19:18
@fredericbahr fredericbahr marked this pull request as ready for review June 9, 2026 19:19
…rective

An async Lit directe `subscribe` is implemented to allow for fine-grained reactivity and rerendering of templates.
To support this, `@tanstack/lit-store` is integrated.
@fredericbahr fredericbahr force-pushed the feat-lit-store-integration branch from 9105b12 to ff325a0 Compare June 9, 2026 19:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/framework/lit/lit-table.md`:
- Line 54: The call to this.table.setOption is using the wrong method name;
change it to this.table.setOptions to match the API (update the call site where
setOption is used and ensure any similar occurrences use setOptions); verify the
callback signature (prev => ({ ... })) still matches the setOptions method on
the table instance (e.g., Table.setOptions) and run tests to ensure no other
references to setOption remain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6cf06d52-f892-4a49-b2e5-b8cee56b08da

📥 Commits

Reviewing files that changed from the base of the PR and between 275b166 and 9105b12.

📒 Files selected for processing (2)
  • docs/framework/lit/guide/table-state.md
  • docs/framework/lit/lit-table.md


protected updated(changedProperties: Map<string, unknown>) {
if (changedProperties.has('data')) {
this.table.setOption((prev) => ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Fix method name: setOptionsetOptions.

The method name should be setOptions (plural), not setOption (singular). This typo would cause a runtime error.

📝 Proposed fix
-      this.table.setOption((prev) => ({
+      this.table.setOptions((prev) => ({
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
this.table.setOption((prev) => ({
this.table.setOptions((prev) => ({
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/framework/lit/lit-table.md` at line 54, The call to this.table.setOption
is using the wrong method name; change it to this.table.setOptions to match the
API (update the call site where setOption is used and ensure any similar
occurrences use setOptions); verify the callback signature (prev => ({ ... }))
still matches the setOptions method on the table instance (e.g.,
Table.setOptions) and run tests to ensure no other references to setOption
remain.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (1)
examples/lit/basic-subscribe/src/main.ts (1)

328-334: ⚡ Quick win

Gate full-state JSON rendering behind a debug flag.

Serializing full state on every update is expensive in this demo, especially with the 200k-row stress path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/lit/basic-subscribe/src/main.ts` around lines 328 - 334, The demo
currently serializes the entire table state on every update via
this.table.subscribe(this.table.store, (state) => state, (state) => html`
<pre>${JSON.stringify(state, null, 2)}</pre> `), which is expensive; gate that
full-state subscription and JSON.stringify behind a debug flag (e.g.,
this.showFullTableState or enableDebugFullState) so the subscribe block only
runs when the flag is true, default the flag to false, and update the template
to render either the full preformatted JSON when the flag is enabled or a
lightweight placeholder/empty node when disabled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/lit/basic-subscribe/README.md`:
- Around line 3-10: The README is outdated: it mentions SubscribeController and
createAtom from `@tanstack/store` but the example actually uses
table.subscribe(...) and imports createAtom from `@tanstack/lit-store`; update the
README to remove/replace references to SubscribeController, change the
createAtom source to `@tanstack/lit-store`, and note that the example demonstrates
using table.subscribe(...) for fine-grained subscriptions (reference symbols:
SubscribeController, createAtom, table.subscribe, `@tanstack/lit-store`,
`@tanstack/store`).

In `@examples/lit/basic-subscribe/src/main.ts`:
- Around line 129-132: The example's updated lifecycle currently replaces
this.table.setOptions with a non-existing this.table.setData; revert to updating
the table via this.table.setOptions inside the updated(changedProperties) method
(check for changedProperties.has('_data') and call this.table.setOptions(prev =>
({ ...prev, data: this._data }))) rather than introducing or calling
table.setData, since setData is only a type field and has no runtime
implementation in the adapter/core.

In `@examples/lit/basic-subscribe/vite.config.js`:
- Around line 8-11: The vite config hardcodes __DEV__ = true and
'process.env.NODE_ENV' = 'development', causing production builds to include dev
constants; update the exported config to be mode-aware (use the defineConfig
callback or read the mode argument) and set __DEV__ and 'process.env.NODE_ENV'
based on the mode (e.g., __DEV__ true only for development, and
process.env.NODE_ENV set to the actual mode string) so values change for
production builds; adjust the values object where __DEV__ and
'process.env.NODE_ENV' are defined in vite.config.js accordingly.

In `@packages/lit-table/skills/lit/compose-with-tanstack-virtual/SKILL.md`:
- Around line 212-213: The doc incorrectly cites TableController as the source
of the AsyncDirective behavior for subscribe; update the attribution in SKILL.md
to point to the actual implementation in
packages/lit-table/src/subscribe-directive.ts (referencing SubscribeDirective
and the exported const subscribe) and note that TableController only
imports/forwards the directive rather than implementing it.

In `@packages/lit-table/src/subscribe-directive.ts`:
- Around line 103-138: The update logic ignores changes to the template
callback—when the template function changes but source and selector are
referentially equal the directive returns noChange; fix this by tracking the
current template (e.g. add this.latestTemplate or reuse this.resolvedTemplate)
and include a templateChanged check in the shouldReinitialize condition inside
update(), update this.resolvedTemplate when it changes, and ensure you call
this.controller.hostUpdate() and return the new template result
(this.resolvedTemplate?.(this.controller.value)) when the template function is
different so the directive re-renders with the new closure/outer values.

In `@packages/lit-table/src/TableController.ts`:
- Around line 76-79: The declared setData signature on LitTable is
incorrect/missing at runtime: update or remove it so the public API matches
actual behavior; either remove setData from the LitTable interface in
TableController or implement setData to update the underlying TableOptions data
by replacing the readonly data array (type it as setData: (data:
ReadonlyArray<TData>) => void) and ensure TableController.table() exposes that
method (or forwards to a helper that calls this._table.setOptions({ data })) so
callers can safely call table.setData(...).

---

Nitpick comments:
In `@examples/lit/basic-subscribe/src/main.ts`:
- Around line 328-334: The demo currently serializes the entire table state on
every update via this.table.subscribe(this.table.store, (state) => state,
(state) => html` <pre>${JSON.stringify(state, null, 2)}</pre> `), which is
expensive; gate that full-state subscription and JSON.stringify behind a debug
flag (e.g., this.showFullTableState or enableDebugFullState) so the subscribe
block only runs when the flag is true, default the flag to false, and update the
template to render either the full preformatted JSON when the flag is enabled or
a lightweight placeholder/empty node when disabled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e7936c5c-b8bf-4a1b-9b49-b4d0ac2c05b1

📥 Commits

Reviewing files that changed from the base of the PR and between 9105b12 and ff325a0.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • docs/framework/lit/guide/table-state.md
  • docs/framework/lit/lit-table.md
  • examples/lit/basic-subscribe/README.md
  • examples/lit/basic-subscribe/index.html
  • examples/lit/basic-subscribe/package.json
  • examples/lit/basic-subscribe/src/main.ts
  • examples/lit/basic-subscribe/src/makeData.ts
  • examples/lit/basic-subscribe/tsconfig.json
  • examples/lit/basic-subscribe/vite.config.js
  • packages/lit-table/package.json
  • packages/lit-table/skills/lit/compose-with-tanstack-virtual/SKILL.md
  • packages/lit-table/src/TableController.ts
  • packages/lit-table/src/index.ts
  • packages/lit-table/src/reactivity.ts
  • packages/lit-table/src/subscribe-directive.ts
✅ Files skipped from review due to trivial changes (3)
  • examples/lit/basic-subscribe/index.html
  • examples/lit/basic-subscribe/package.json
  • docs/framework/lit/guide/table-state.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/lit-table/package.json
  • packages/lit-table/src/reactivity.ts
  • docs/framework/lit/lit-table.md

Comment on lines +3 to +10
This example demonstrates fine-grained state subscriptions using `SubscribeController` for optimized rendering in Lit.

**Key Features:**

- **Fine-grained subscriptions**: Each part of the table subscribes only to the state it needs
- **SubscribeController**: A new Lit ReactiveController that handles store/atom subscriptions declaratively
- **External atoms**: State management via `createAtom` from `@tanstack/store` for full control
- **Performance optimized**: Only affected UI elements re-render when their subscribed state changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n "SubscribeController|`@tanstack/store`|table.subscribe|`@tanstack/lit-store`" \
  examples/lit/basic-subscribe/README.md \
  examples/lit/basic-subscribe/src/main.ts

Repository: TanStack/table

Length of output: 1393


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Search for SubscribeController / `@tanstack/store` in example =="
rg -n "SubscribeController|`@tanstack/store`" examples/lit/basic-subscribe || true

echo
echo "== Search for table.subscribe / `@tanstack/lit-store` in example =="
rg -n "table\.subscribe|`@tanstack/lit-store`" examples/lit/basic-subscribe || true

echo
echo "== Show README lines 1-40 =="
sed -n '1,40p' examples/lit/basic-subscribe/README.md

Repository: TanStack/table

Length of output: 2567


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== package.json deps =="
cat examples/lit/basic-subscribe/package.json | sed -n '1,80p'

echo
echo "== main.ts import and table.subscribe usage (around top) =="
sed -n '1,120p' examples/lit/basic-subscribe/src/main.ts

echo
echo "== main.ts table.subscribe call signature (around first occurrence) =="
sed -n '160,260p' examples/lit/basic-subscribe/src/main.ts

Repository: TanStack/table

Length of output: 7469


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== package.json deps =="
cat examples/lit/basic-subscribe/package.json | sed -n '1,80p'

echo
echo "== main.ts import and table.subscribe usage (around top) =="
sed -n '1,120p' examples/lit/basic-subscribe/src/main.ts

echo
echo "== main.ts table.subscribe call signature (around first occurrence) =="
sed -n '160,260p' examples/lit/basic-subscribe/src/main.ts

Repository: TanStack/table

Length of output: 7469


Fix outdated README API names in basic-subscribe example

The README claims the example uses SubscribeController and createAtom from @tanstack/store, but the implementation uses table.subscribe(...) and imports createAtom from @tanstack/lit-store.

Suggested doc fix
-This example demonstrates fine-grained state subscriptions using `SubscribeController` for optimized rendering in Lit.
+This example demonstrates fine-grained state subscriptions using `table.subscribe(...)` for optimized rendering in Lit.

 - **Fine-grained subscriptions**: Each part of the table subscribes only to the state it needs
-- **SubscribeController**: A new Lit ReactiveController that handles store/atom subscriptions declaratively
-- **External atoms**: State management via `createAtom` from `@tanstack/store` for full control
+- **`table.subscribe` directive**: A Lit async directive for declarative store/atom subscriptions
+- **External atoms**: State management via `createAtom` from `@tanstack/lit-store` for full control
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/lit/basic-subscribe/README.md` around lines 3 - 10, The README is
outdated: it mentions SubscribeController and createAtom from `@tanstack/store`
but the example actually uses table.subscribe(...) and imports createAtom from
`@tanstack/lit-store`; update the README to remove/replace references to
SubscribeController, change the createAtom source to `@tanstack/lit-store`, and
note that the example demonstrates using table.subscribe(...) for fine-grained
subscriptions (reference symbols: SubscribeController, createAtom,
table.subscribe, `@tanstack/lit-store`, `@tanstack/store`).

Comment on lines +129 to +132
protected updated(changedProperties: Map<string, unknown>) {
if (changedProperties.has('_data')) {
this.table.setOptions((prev) => ({ ...prev, data: this._data }))
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n "setData" packages/lit-table/src/TableController.ts examples/lit/basic-subscribe/src/main.ts

Repository: TanStack/table

Length of output: 136


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Read the example snippet around the referenced lines
echo "---- examples/lit/basic-subscribe/src/main.ts (120-145) ----"
nl -ba examples/lit/basic-subscribe/src/main.ts | sed -n '120,150p'

# 2) Inspect TableController.ts around setData and surrounding API shape
echo "---- packages/lit-table/src/TableController.ts (1-140) ----"
nl -ba packages/lit-table/src/TableController.ts | sed -n '1,160p'

# 3) Find how setOptions is used in lit-table
echo "---- rg setOptions in packages/lit-table ----"
rg -n "setOptions\(" packages/lit-table/src

# 4) Find how setData is used in lit-table and examples
echo "---- rg setData in packages/lit-table/src and examples ----"
rg -n "setData\(" packages/lit-table/src examples

Repository: TanStack/table

Length of output: 180


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- examples/lit/basic-subscribe/src/main.ts (120-145) ----"
cat -n examples/lit/basic-subscribe/src/main.ts | sed -n '120,150p'

echo "---- packages/lit-table/src/TableController.ts (60-140) ----"
cat -n packages/lit-table/src/TableController.ts | sed -n '60,160p'

echo "---- rg setOptions( usage in packages/lit-table/src ----"
rg -n "setOptions\\(" packages/lit-table/src

echo "---- rg setOptions data handling in packages/lit-table/src ----"
rg -n "data\\s*:" packages/lit-table/src/TableController.ts packages/lit-table/src -S

echo "---- rg setOptions implementation in TableController.ts ----"
rg -n "setOptions\\s*\\(" packages/lit-table/src/TableController.ts

echo "---- rg setData implementation in TableController.ts ----"
rg -n "setData\\s*\\(" packages/lit-table/src/TableController.ts

Repository: TanStack/table

Length of output: 5767


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- TableController.ts (150-260) ----"
sed -n '150,260p' packages/lit-table/src/TableController.ts | cat -n

echo "---- rg 'setData' with context in TableController.ts ----"
rg -n "setData" packages/lit-table/src/TableController.ts -C 3

echo "---- rg 'setData' across lit-table/src (limited output) ----"
rg -n "setData" packages/lit-table/src | head -n 50

Repository: TanStack/table

Length of output: 3096


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- Files in packages/lit-table/src (top-level only) ----"
ls -1 packages/lit-table/src

echo "---- Search for LitTable type/interface ----"
rg -n "interface\s+LitTable|type\s+LitTable|export\s+type\s+LitTable|export\s+interface\s+LitTable" packages/lit-table/src

echo "---- Search for setOptions definitions ----"
rg -n "setOptions\s*:" packages/lit-table/src
rg -n "setOptions\s*\(" packages/lit-table/src | head -n 50

echo "---- Repo-wide: occurrences of setData API surface ----"
rg -n "setData\s*:" . | head -n 50
rg -n "setData\s*\(" packages | head -n 50

echo "---- Repo-wide: occurrences of setOptions API surface ----"
rg -n "setOptions\s*:" packages | head -n 50

Repository: TanStack/table

Length of output: 406


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- TableController.ts (1-120) ----"
sed -n '1,120p' packages/lit-table/src/TableController.ts | cat -n

echo "---- rg setOptions in repo (first 50 matches) ----"
rg -n "setOptions\s*[:(]" packages . | head -n 50

echo "---- rg setData in repo (first 50 matches) ----"
rg -n "setData\s*[:(]" packages . | head -n 50

echo "---- rg for underlying Table API definition (table core) by searching 'setData' keywords in packages/**/src ----"
rg -n "interface\s+Table<|class\s+Table|export\s+interface\s+Table<|export\s+type\s+Table<" packages | head -n 50

Repository: TanStack/table

Length of output: 16362


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Look for setData in table-core Table type definition
echo "---- packages/table-core/src/types/Table.ts around setData ----"
rg -n "setData" packages/table-core/src/types/Table.ts
sed -n '1,140p' packages/table-core/src/types/Table.ts | cat -n

# Also search table-core src for setData definition
echo "---- rg setData in packages/table-core/src (limited) ----"
rg -n "setData" packages/table-core/src | head -n 50

# Search for setOptions data update guidance maybe in docs/comments
echo "---- rg for 'setOptions' and 'data' in table-core/src (limited) ----"
rg -n "setOptions\\(.*data|data.*setOptions|setOptions.*data" packages/table-core/src | head -n 50

Repository: TanStack/table

Length of output: 122


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- packages/table-core/src/types/Table.ts (search setData) ----"
rg -n "setData" packages/table-core/src/types/Table.ts
echo "---- Table.ts (1-220) ----"
sed -n '1,220p' packages/table-core/src/types/Table.ts | cat -n

echo "---- rg setData in packages/table-core/src (head 50) ----"
rg -n "setData" packages/table-core/src | head -n 50

echo "---- rg setOptions with data mentions (head 50) ----"
rg -n "setOptions\\(.*data|data.*setOptions|setOptions.*data" packages/table-core/src | head -n 50

echo "---- rg 'setOptions' doc comments in Table.ts (head 50) ----"
rg -n "setOptions" packages/table-core/src/types/Table.ts | head -n 50

Repository: TanStack/table

Length of output: 124


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- packages/table-core/src/types/Table.ts (search setData) ----"
rg -n "setData" packages/table-core/src/types/Table.ts
echo "---- Table.ts (1-220) ----"
sed -n '1,220p' packages/table-core/src/types/Table.ts | cat -n

echo "---- rg setData in packages/table-core/src (head 50) ----"
rg -n "setData" packages/table-core/src | head -n 50

echo "---- rg setOptions with data mentions (head 50) ----"
rg -n "setOptions\\(.*data|data.*setOptions|setOptions.*data" packages/table-core/src | head -n 50

echo "---- rg setOptions in packages/table-core/src/types/Table.ts (head 50) ----"
rg -n "setOptions" packages/table-core/src/types/Table.ts | head -n 50

Repository: TanStack/table

Length of output: 124


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- packages/table-core/src/types/Table.ts (search setData) ----"
rg -n "setData" packages/table-core/src/types/Table.ts

echo "---- packages/table-core/src/types/Table.ts (1-220) ----"
sed -n '1,220p' packages/table-core/src/types/Table.ts | cat -n

echo "---- rg setData in packages/table-core/src (head 50) ----"
rg -n "setData" packages/table-core/src | head -n 50

echo "---- rg setOptions with data mentions (head 50) ----"
rg -n "setOptions\\(.*data|data.*setOptions|setOptions.*data" packages/table-core/src | head -n 50

echo "---- rg setOptions in packages/table-core/src/types/Table.ts (head 50) ----"
rg -n "setOptions" packages/table-core/src/types/Table.ts | head -n 50

Repository: TanStack/table

Length of output: 124


🏁 Script executed:

#!/bin/bash
set -uo pipefail

echo "---- list examples/lit ----"
ls -1 examples/lit || true

echo "---- rg for '.setData' usage in examples/lit ----"
rg -n "\\.setData\\b" examples/lit || true

echo "---- rg for 'table_setData' / 'setData' in packages/table-core/src ----"
rg -n "table_setData|setData" packages/table-core/src || true

echo "---- find constructTable implementation in repo ----"
rg -n "constructTable" packages/table-core/src packages/lit-table/src | head -n 50 || true

echo "---- locate createTable / core table factory in table-core ----"
rg -n "export\\s+(function|const)\\s+constructTable|class\\s+Table|createTable" packages/table-core/src | head -n 50 || true

echo "---- search for runtime generation of convenience methods (setOptions/setData) ----"
rg -n "convenience.*set|setOptions|setData" packages/table-core/src | head -n 80 || true

echo "---- inspect lit-table controller skill doc for data updates ----"
sed -n '1,140p' packages/lit-table/skills/lit/lit-table-controller/SKILL.md | cat -n

Repository: TanStack/table

Length of output: 11194


🏁 Script executed:

#!/bin/bash
set -uo pipefail

echo "---- rg setData in packages/table-core/src (all) ----"
rg -n "setData" packages/table-core/src || true

echo "---- rg table\\.setData usage in packages/lit-table and examples (first 50) ----"
rg -n "\\.setData\\b" packages/lit-table examples || true

echo "---- rg 'setData' in packages/lit-table/skills and docs (first 100) ----"
rg -n "setData" packages/lit-table/skills docs examples/lit || true

Repository: TanStack/table

Length of output: 1055


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- coreTablesFeature.types.ts around setOptions ----"
sed -n '180,260p' packages/table-core/src/core/table/coreTablesFeature.types.ts | cat -n

echo "---- rg setData in coreTablesFeature.* ----"
rg -n "setData" packages/table-core/src/core/table/coreTablesFeature.types.ts packages/table-core/src/core/table/coreTablesFeature.ts packages/table-core/src/core/table/coreTablesFeature.utils.ts || true

echo "---- coreTablesFeature.ts ----"
sed -n '1,120p' packages/table-core/src/core/table/coreTablesFeature.ts | cat -n

echo "---- coreTablesFeature.utils.ts around table_setOptions ----"
sed -n '80,160p' packages/table-core/src/core/table/coreTablesFeature.utils.ts | cat -n

Repository: TanStack/table

Length of output: 4385


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- rg setData in docs/framework/lit ----"
rg -n "setData" docs/framework/lit || true

echo "---- rg table\\.setData in docs/framework/lit ----"
rg -n "table\\.setData" docs/framework/lit || true

echo "---- show docs/framework/lit/lit-table.md (if exists) around mentions ----"
ls -1 docs/framework/lit || true
rg -n "setOptions|data" docs/framework/lit/lit-table.md docs/framework/lit/guide/table-state.md 2>/dev/null || true

echo "---- show lit-table.md snippet around data updates (best effort) ----"
if [ -f docs/framework/lit/lit-table.md ]; then
  sed -n '1,220p' docs/framework/lit/lit-table.md | cat -n
fi

echo "---- show guide/table-state.md snippet (best effort) ----"
if [ -f docs/framework/lit/guide/table-state.md ]; then
  sed -n '1,240p' docs/framework/lit/guide/table-state.md | cat -n
fi

Repository: TanStack/table

Length of output: 17616


Don’t switch to table.setData; keep updating data via table.setOptions in this Lit example.
@tanstack/lit-table updates the table by merging options through setOptions; setData was only found as a type field and there’s no runtime setData implementation in the adapter/core, so changing the example would risk a broken method call.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/lit/basic-subscribe/src/main.ts` around lines 129 - 132, The
example's updated lifecycle currently replaces this.table.setOptions with a
non-existing this.table.setData; revert to updating the table via
this.table.setOptions inside the updated(changedProperties) method (check for
changedProperties.has('_data') and call this.table.setOptions(prev => ({
...prev, data: this._data }))) rather than introducing or calling table.setData,
since setData is only a type field and has no runtime implementation in the
adapter/core.

Comment on lines +8 to +11
values: {
__DEV__: JSON.stringify(true),
'process.env.NODE_ENV': JSON.stringify('development'),
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

cat -n examples/lit/basic-subscribe/package.json
cat -n examples/lit/basic-subscribe/vite.config.js
rg -n -C2 --type=md 'basic-subscribe'

Repository: TanStack/table

Length of output: 21329


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find where this Lit example is referenced in CI/docs/build scripts
rg -n --hidden --glob '!.git/*' 'examples/lit/basic-subscribe' .

rg -n --hidden --glob '!.git/*' 'basic-subscribe' .github workflows *.yml *.yaml package.json **/package.json 2>/dev/null || true

# Look for Vite build invocations in workflows/docs
rg -n --hidden --glob '!.git/*' 'vite build' .github .

# Check for any explicit Vite --mode usage
rg -n --hidden --glob '!.git/*' 'vite (build|dev|preview).*(--mode| -m )' .github . || true

Repository: TanStack/table

Length of output: 15718


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n --hidden --glob '!.git/*' 'examples/lit/basic-subscribe' .github . scripts docs packages 2>/dev/null || true
rg -n --hidden --glob '!.git/*' '(basic-subscribe|basic-subscribe\.|lit/basic-subscribe)' .github . scripts docs packages 2>/dev/null || true

# Look for bulk building of lit examples
rg -n --hidden --glob '!.git/*' 'examples/lit/' .github . scripts docs packages 2>/dev/null || true
rg -n --hidden --glob '!.git/*' 'vite build' .github . scripts docs packages 2>/dev/null || true

# Look specifically for mode flags / node env injection
rg -n --hidden --glob '!.git/*' 'vite (build|dev|preview).*--mode|--mode ' .github . scripts docs packages 2>/dev/null || true
rg -n --hidden --glob '!.git/*' '(NODE_ENV|mode)\s*[:=]' .github . scripts docs packages 2>/dev/null || true

Repository: TanStack/table

Length of output: 45674


🏁 Script executed:

#!/bin/bash
set -euo pipefail
ls -R .github || true
ls -R .github/workflows || true

# Search CI workflows for building examples/lit or Vite mode flags
rg -n --hidden --glob '!.git/*' 'examples/lit/basic-subscribe|examples/lit/|lit/basic-subscribe|basic-subscribe' .github/workflows .github 2>/dev/null || true
rg -n --hidden --glob '!.git/*' 'vite build|vite dev|vite preview|--mode|NODE_ENV' .github/workflows .github 2>/dev/null || true

# Search for any scripts that build all examples/lit
rg -n --hidden --glob '!.git/*' 'examples/lit/|vite build' scripts . 2>/dev/null || true

Repository: TanStack/table

Length of output: 20678


🏁 Script executed:

#!/bin/bash
set -euo pipefail

for f in .github/workflows/*.yml .github/workflows/*.yaml; do
  echo "---- $f ----"
  rg -n 'examples/lit|lit/basic-subscribe|basic-subscribe|vite build|--mode|NODE_ENV' "$f" || true
done

Repository: TanStack/table

Length of output: 375


🏁 Script executed:

#!/bin/bash
set -euo pipefail

ls -1
echo "---- root package.json ----"
cat -n package.json 2>/dev/null || true
echo "---- rg for lit/basic-subscribe and vite builds (excluding lock/_artifacts) ----"
rg -n --hidden --glob '!.git/*' \
  --glob '!pnpm-lock.yaml' --glob '!_artifacts/**' \
  'examples/lit/basic-subscribe|examples/lit/|lit/basic-subscribe|basic-subscribe' \
  . || true

rg -n --hidden --glob '!.git/*' \
  --glob '!pnpm-lock.yaml' --glob '!_artifacts/**' \
  'vite build|vite dev|vite preview|--mode\s+production|--mode\s+development|NODE_ENV\s*=' \
  . || true

rg -n --hidden --glob '!.git/*' \
  --glob '!pnpm-lock.yaml' --glob '!_artifacts/**' \
  '"docs"|"build docs"|docusaurus|typedoc|next build|astro build|sveltekit build|mkdocs' \
  package.json .github scripts docs . || true

Repository: TanStack/table

Length of output: 47771


Make Vite replace values mode-aware (production bundles currently get dev constants).

examples/lit/basic-subscribe/vite.config.js hardcodes __DEV__ = true and 'process.env.NODE_ENV' = 'development', so vite build outputs dev semantics even when Vite runs in production mode.

💡 Suggested fix
-export default defineConfig({
+export default defineConfig(({ mode }) => ({
   plugins: [
     rollupReplace({
       preventAssignment: true,
       values: {
-        __DEV__: JSON.stringify(true),
-        'process.env.NODE_ENV': JSON.stringify('development'),
+        __DEV__: JSON.stringify(mode !== 'production'),
+        'process.env.NODE_ENV': JSON.stringify(mode),
       },
     }),
   ],
-})
+}))
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/lit/basic-subscribe/vite.config.js` around lines 8 - 11, The vite
config hardcodes __DEV__ = true and 'process.env.NODE_ENV' = 'development',
causing production builds to include dev constants; update the exported config
to be mode-aware (use the defineConfig callback or read the mode argument) and
set __DEV__ and 'process.env.NODE_ENV' based on the mode (e.g., __DEV__ true
only for development, and process.env.NODE_ENV set to the actual mode string) so
values change for production builds; adjust the values object where __DEV__ and
'process.env.NODE_ENV' are defined in vite.config.js accordingly.

Comment on lines +212 to 213
`subscribe` is an [async Lit directive](https://lit.dev/docs/api/custom-directives/#AsyncDirective) that enables fine-grained reactivity by updating only when the selected part of the store or atom changes. Rather than triggering a full re-render whenever the table state updates, you can use `subscribe` to watch specific slices of state and update only the affected parts of the template. This reduces unnecessary renders and improves performance for large tables or complex UI hierarchies.
Source: `packages/lit-table/src/TableController.ts`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n "class SubscribeDirective|export const subscribe" packages/lit-table/src/subscribe-directive.ts
rg -n "subscribe: typeof subscribe" packages/lit-table/src/TableController.ts

Repository: TanStack/table

Length of output: 215


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the exact SKILL.md citation area
sed -n '190,230p' packages/lit-table/skills/lit/compose-with-tanstack-virtual/SKILL.md

# Inspect the subscribe-related parts of TableController.ts
sed -n '1,120p' packages/lit-table/src/TableController.ts
sed -n '120,260p' packages/lit-table/src/TableController.ts

# Inspect subscribe-directive.ts where SubscribeDirective/subscribe are defined
sed -n '1,260p' packages/lit-table/src/subscribe-directive.ts

Repository: TanStack/table

Length of output: 15190


Fix source attribution for subscribe’s AsyncDirective behavior.

SKILL.md describes subscribe as an AsyncDirective with fine-grained reactivity, but that implementation is in packages/lit-table/src/subscribe-directive.ts (SubscribeDirective / export const subscribe). packages/lit-table/src/TableController.ts only imports/exposes subscribe on the table instance, so the citation should be updated.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/lit-table/skills/lit/compose-with-tanstack-virtual/SKILL.md` around
lines 212 - 213, The doc incorrectly cites TableController as the source of the
AsyncDirective behavior for subscribe; update the attribution in SKILL.md to
point to the actual implementation in
packages/lit-table/src/subscribe-directive.ts (referencing SubscribeDirective
and the exported const subscribe) and note that TableController only
imports/forwards the directive rather than implementing it.

Comment on lines +103 to +138
const actualTemplate = isIdentitySubscription
? (selectorOrTemplate as TemplateFunction<any>)
: template

const sourceChanged = this.latestSource !== source
const selectorChanged = this.latestSelector !== selector
const shouldReinitialize =
!this.initialized || sourceChanged || selectorChanged

if (shouldReinitialize) {
if (this.initialized) {
this.controller?.hostDisconnected()
this.controller = undefined
}

this.latestSource = source
this.latestSelector = selector
this.resolvedTemplate = actualTemplate

if (!this.controller) {
this.controller = new TanStackStoreSelector(
this.createFakeHost(),
() => this.latestSource,
(state) => this.latestSelector?.(state),
)
}

this.controller.hostUpdate()
this.initialized = true

return this.resolvedTemplate?.(this.controller.value)
}

// Host rerender with same source + selector, so we can skip updating
return noChange
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Template callback changes are ignored, which can render stale content.

When source and selector stay referentially equal, update() always returns noChange. If the template callback changes (new closure/outer values), the directive won’t re-render and can show stale UI.

💡 Suggested fix
   update(
@@
     const actualTemplate = isIdentitySubscription
       ? (selectorOrTemplate as TemplateFunction<any>)
       : template
+    const templateChanged = this.resolvedTemplate !== actualTemplate
+    this.resolvedTemplate = actualTemplate
 
     const sourceChanged = this.latestSource !== source
     const selectorChanged = this.latestSelector !== selector
@@
-      this.resolvedTemplate = actualTemplate
-
       if (!this.controller) {
         this.controller = new TanStackStoreSelector(
@@
       return this.resolvedTemplate?.(this.controller.value)
     }
 
+    if (templateChanged && this.controller) {
+      return this.resolvedTemplate?.(this.controller.value)
+    }
+
     // Host rerender with same source + selector, so we can skip updating
     return noChange
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/lit-table/src/subscribe-directive.ts` around lines 103 - 138, The
update logic ignores changes to the template callback—when the template function
changes but source and selector are referentially equal the directive returns
noChange; fix this by tracking the current template (e.g. add
this.latestTemplate or reuse this.resolvedTemplate) and include a
templateChanged check in the shouldReinitialize condition inside update(),
update this.resolvedTemplate when it changes, and ensure you call
this.controller.hostUpdate() and return the new template result
(this.resolvedTemplate?.(this.controller.value)) when the template function is
different so the directive re-renders with the new closure/outer values.

Comment on lines +76 to +79
/**
* Convenience method to update the table's data. This is a common operation and
*/
setData: (data: TData) => void

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate setData declarations/usages
rg -n -C3 --type=ts '\bsetData\b'

# Locate canonical table data typing shape
rg -n -C3 --type=ts 'data\s*:\s*TData\[\]|TableOptions<'

Repository: TanStack/table

Length of output: 50371


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect TableController.ts around the setData type and generic params
FILE="packages/lit-table/src/TableController.ts"
echo "=== File header & generic params ==="
rg -n "export (type|interface|class) TableController|function TableController|<.*TData" "$FILE" || true
echo
echo "=== setData region ==="
sed -n '1,220p' "$FILE" | nl -ba | sed -n '1,220p'

# Find all setData implementations/usages within lit-table
echo
echo "=== lit-table setData implementations/usages ==="
rg -n "setData\s*[:(]" packages/lit-table/src --type=ts
echo
rg -n "\.setData\s*\(" packages/lit-table/src --type=ts

# Find table.setData usage in examples (if any)
echo
echo "=== examples table.setData usages ==="
rg -n "\.setData\s*\(" examples --type=ts --max-count=50

Repository: TanStack/table

Length of output: 739


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="packages/lit-table/src/TableController.ts"

echo "=== File imports + type params (top 220 lines) ==="
sed -n '1,220p' "$FILE" | cat -n

echo
echo "=== All setData mentions in TableController.ts ==="
rg -n "setData" "$FILE"

echo
echo "=== Context around setData typing (lines 60-110) ==="
sed -n '60,110p' "$FILE" | cat -n

echo
echo "=== Find LitTable/TableController typing definitions in repo ==="
rg -n "interface LitTable|type LitTable|class LitTable" packages/lit-table/src --type=ts
rg -n "setData\s*[:(]" packages/lit-table/src --type=ts

Repository: TanStack/table

Length of output: 10251


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Search for setData across lit-table ==="
rg -n "setData" packages/lit-table/src --type=ts

echo
echo "=== Search for setData signature in repo (any TS declarations) ==="
rg -n "setData\s*:\s*\(" . --type=ts

echo
echo "=== Search for data: TData[] patterns in lit-table ==="
rg -n "data\s*:\s*TData\[\]" packages/lit-table/src --type=ts || true

echo
echo "=== Search for 'data' in TableOptions usage in lit-table ==="
rg -n "TableOptions<.*TData|data\s*:" packages/lit-table/src --type=ts

Repository: TanStack/table

Length of output: 1257


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search for setData usage in lit-table
rg -n "\.setData\s*\(" packages/lit-table/src --type=ts || true
rg -n "setData\s*:" packages/lit-table/src --type=ts || true

# Show relevant slices from createTableHook.ts
FILE="packages/lit-table/src/createTableHook.ts"
echo "=== setData mentions in createTableHook.ts ==="
rg -n "setData" "$FILE" --type=ts || true

echo
echo "=== Context around data typing / options in createTableHook.ts ==="
rg -n "data\s*:" "$FILE" --type=ts | head -n 50
rg -n "TableOptions<" "$FILE" --type=ts | head -n 50

# Show around the lines where TableOptions is used
sed -n '560,720p' "$FILE" | nl -ba | head -n 200

Repository: TanStack/table

Length of output: 497


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="packages/lit-table/src/createTableHook.ts"

echo "=== createTableHook.ts: context around ~370-430 ==="
sed -n '360,440p' "$FILE" | cat -n

echo
echo "=== createTableHook.ts: context around ~560-700 ==="
sed -n '560,720p' "$FILE" | cat -n

echo
echo "=== createTableHook.ts: search for 'data' and 'TableOptions' types ==="
rg -n "data\s*:\s*|TableOptions<" "$FILE" --type=ts

Repository: TanStack/table

Length of output: 9849


🌐 Web query:

@tanstack/table-core Table setData signature TData

💡 Result:

In @tanstack/table-core, there is no direct method named setData on the table instance [1][2]. Data is managed as a property within the table options [2][3]. To update the table data, you should update the data passed to the useReactTable hook's options [4][5]. The table instance reacts to changes in the data property when its reference changes [2][3]. The signature for the data option is: data: TData[] TData is a generic type representing the shape of an individual row in your table [4][5]. To ensure proper type safety and performance, you should: 1. Define a type for your data (e.g., TData = User) [4][5]. 2. Provide this type as the generic argument to useReactTable (e.g., useReactTable(...)) [1][6]. 3. Ensure the data array has a stable reference (e.g., using React.useState or React.useMemo) to prevent infinite re-renders [4][5]. If you need to update table options dynamically (including changing the data reference), you can use the table.setOptions method [1][7]: table.setOptions(prev => ({...prev, data: newData })) This method accepts an updater function (or a direct partial options object) to update the table's configuration [1][7].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Locate setData in packages/table-core ==="
rg -n "setData" packages/table-core --type=ts || true

echo
echo "=== Locate TableOptions Core 'data' typing (TData[]) ==="
rg -n "interface TableOptions|type TableOptions|data:\s*TData\[\]" packages/table-core --type=ts || true

echo
echo "=== Inspect core Table type for any setData method ==="
# show likely table interface/class file(s)
rg -n "export (type|interface|class) Table<|class Table<|interface Table<" packages/table-core/src --type=ts | head -n 50

# show the table.ts file that web_search referenced
FILE="packages/table-core/src/core/table.ts"
if [ -f "$FILE" ]; then
  echo
  echo "=== Snippet around Table in $FILE (searching for setData) ==="
  rg -n "setData" "$FILE" --type=ts || true
  sed -n '1,260p' "$FILE" | cat -n | head -n 260
fi

Repository: TanStack/table

Length of output: 2759


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Repo-wide setData occurrences (ts/js) ==="
rg -n "setData" . --type=ts --type=tsx --type=js --type=jsx

echo
echo "=== Inspect TableController.ts full for any setData implementation ==="
FILE="packages/lit-table/src/TableController.ts"
rg -n "setData" "$FILE" -n
sed -n '1,260p' "$FILE" | cat -n

Repository: TanStack/table

Length of output: 150


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Confirm if TableController.ts runtime adds setData
FILE="packages/lit-table/src/TableController.ts"
echo "=== setData occurrences in ${FILE} (all) ==="
rg -n "setData" "$FILE" --type=ts || true

echo
echo "=== Inspect TableController.ts tail (to see if setData implemented later) ==="
sed -n '220,500p' "$FILE" | cat -n

echo
echo "=== Inspect TableOptions core data typing (TableOptions.ts) ==="
TABLE_OPTIONS_FILE="packages/table-core/src/types/TableOptions.ts"
rg -n "data\s*:" "$TABLE_OPTIONS_FILE" --type=ts || true
sed -n '70,140p' "$TABLE_OPTIONS_FILE" | cat -n

echo
echo "=== Inspect core Table type for methods/properties (Table.ts) ==="
TABLE_FILE="packages/table-core/src/types/Table.ts"
sed -n '1,140p' "$TABLE_FILE" | cat -n
rg -n "setData" "$TABLE_FILE" --type=ts || true

echo
echo "=== Inspect TableOptions_Core interface for data property ==="
rg -n "interface TableOptions_Core" "$TABLE_OPTIONS_FILE" --type=ts
sed -n '1,90p' "$TABLE_OPTIONS_FILE" | cat -n

Repository: TanStack/table

Length of output: 11787


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Confirm setData in table-core (should be none) ==="
rg -n "setData" packages/table-core/src --type=ts || true

echo
echo "=== Confirm setData in lit-table (only type?) ==="
rg -n "setData" packages/lit-table/src --glob='*.ts' --glob='*.tsx' || true

echo
echo "=== Locate core TableOptions data property typing ==="
# Find where `data:` is declared in core table options typing
rg -n "data\s*:\s*TData\[\]" packages/table-core/src --type=ts || true
rg -n "data\s*:\s*.*TData\[\]" packages/table-core/src --type=ts || true

# Also print the surrounding type block for TableOptions_Table
FILE="packages/table-core/src/core/table/coreTablesFeature.types.ts"
echo
echo "=== Search data: in $FILE ==="
rg -n "data\s*:" "$FILE" --type=ts || true
echo
echo "=== Snippet around first data: match in $FILE (if any) ==="
MATCH_LINE=$(rg -n "data\s*:" "$FILE" --type=ts | head -n 1 | cut -d: -f1 || true)
if [ -n "${MATCH_LINE:-}" ]; then
  START=$((MATCH_LINE-20)); END=$((MATCH_LINE+30));
  sed -n "${START},${END}p" "$FILE" | cat -n
else
  echo "No data: matches found in $FILE"
fi

Repository: TanStack/table

Length of output: 3145


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Repo-wide runtime usage of .setData(...) ==="
rg -n "\.setData\s*\(" . --type=ts --type=tsx --type=js --type=jsx || true

echo
echo "=== Any other setData implementation in lit-table besides the type ==="
rg -n "setData" packages/lit-table/src --type=ts || true

Repository: TanStack/table

Length of output: 303


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Search for setOptions in table-core Table types ==="
rg -n "setOptions" packages/table-core/src --type=ts | head -n 50

echo
echo "=== Search for 'data' usage in setOptions-related typing ==="
rg -n "setOptions\(|data:" packages/table-core/src --type=ts | head -n 80

Repository: TanStack/table

Length of output: 1422


🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n "setData" packages/table-core || true

Repository: TanStack/table

Length of output: 255


🏁 Script executed:

rg -n "\bsetData\b" packages/lit-table/src/TableController.ts
rg -n "readonly data:\s*ReadonlyArray<TData>" packages/table-core/src/core/table/coreTablesFeature.types.ts
rg -n "\bsetData\b" packages/table-core/src || true

Repository: TanStack/table

Length of output: 135


Fix LitTable’s setData API contract (likely missing at runtime)

  • packages/lit-table/src/TableController.ts declares setData: (data: TData) => void, but core tables are driven by TableOptions’s readonly data: ReadonlyArray<TData> and do not provide a setData method; TableController.table() only returns ...this._table (no setData is added), so calling table.setData(...) can fail at runtime.
  • Either remove setData from the public LitTable API or implement it by updating the table options, typed as setData: (data: ReadonlyArray<TData>) => void.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/lit-table/src/TableController.ts` around lines 76 - 79, The declared
setData signature on LitTable is incorrect/missing at runtime: update or remove
it so the public API matches actual behavior; either remove setData from the
LitTable interface in TableController or implement setData to update the
underlying TableOptions data by replacing the readonly data array (type it as
setData: (data: ReadonlyArray<TData>) => void) and ensure
TableController.table() exposes that method (or forwards to a helper that calls
this._table.setOptions({ data })) so callers can safely call table.setData(...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants