Move subscription shape typing from useTaiiNet to useSubscription#2
Open
Copilot wants to merge 9 commits into
Open
Move subscription shape typing from useTaiiNet to useSubscription#2Copilot wants to merge 9 commits into
useTaiiNet to useSubscription#2Copilot wants to merge 9 commits into
Conversation
Copilot created this pull request from a session on behalf of
Taiiwo
May 26, 2026 20:54
View session
Copilot
AI
changed the title
Convert TaiiNet into a typed TypeScript package with core test coverage
Remove legacy JS sources and introduce React-first May 29, 2026
useTaiiNet API
Copilot
AI
changed the title
Remove legacy JS sources and introduce React-first
Add GitHub Actions test workflow for push/PR events
May 29, 2026
useTaiiNet APIThere was a problem hiding this comment.
Pull request overview
This PR adds GitHub Actions test automation, but the reviewed diff also includes a TypeScript/ESM package rewrite with React hook support, tests, and updated documentation.
Changes:
- Adds Node-based package metadata, TypeScript config, lockfile, and CI test workflow.
- Replaces legacy root JavaScript modules with typed
src/implementations. - Adds Vitest coverage for core query, event, subscription, TaiiNet, and React hook behavior.
Reviewed changes
Copilot reviewed 23 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/tests.yml |
Adds CI workflow running npm ci and npm test. |
.gitignore |
Ignores Node/TypeScript build artifacts. |
README.md |
Updates usage docs for TypeScript package and React hook API. |
package.json |
Defines package exports, scripts, dependencies, and metadata. |
package-lock.json |
Locks npm dependency graph. |
tsconfig.json |
Adds TypeScript compiler configuration. |
src/BacklogSubscription.ts |
Adds typed backlog subscription implementation. |
src/EventBase.ts |
Adds typed event emitter base. |
src/Subscription.ts |
Adds typed subscription implementation. |
src/Swarm.ts |
Adds typed peer swarm implementation. |
src/TaiiNet.ts |
Adds typed TaiiNet client implementation. |
src/index.ts |
Adds public package exports. |
src/query.ts |
Adds query matching helpers. |
src/types.ts |
Adds shared TypeScript interfaces. |
src/useTaiiNet.ts |
Adds React hook wrapper for TaiiNet. |
tests/EventBase.test.ts |
Adds EventBase tests. |
tests/Subscription.test.ts |
Adds Subscription and BacklogSubscription tests. |
tests/TaiiNet.test.ts |
Adds TaiiNet client tests. |
tests/helpers.ts |
Adds test doubles for signaller/swarm/channel behavior. |
tests/query.test.ts |
Adds query helper tests. |
tests/useTaiiNet.test.tsx |
Adds React hook tests. |
BacklogSubscription.js |
Removes legacy JavaScript implementation. |
EventBase.js |
Removes legacy JavaScript implementation. |
Subscription.js |
Removes legacy JavaScript implementation. |
Swarm.js |
Removes legacy JavaScript implementation. |
TaiiNet.js |
Removes legacy JavaScript implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+34
to
+39
| if (data.type === "backlog") { | ||
| if (!this.messages.includes(serializedMessage)) { | ||
| this.messages.push(serializedMessage); | ||
| } | ||
| this.trigger("data", data.data, event); | ||
| return; |
Comment on lines
+49
to
+51
| for (const message of this.messages) { | ||
| this.swarm.send_direct(requestingPeer, JSON.parse(message) as QueryRecord, "backlog"); | ||
| } |
Comment on lines
+41
to
+42
| if (!clientRef.current) { | ||
| clientRef.current = createClient ? createClient(taiiNetOptions) : new TaiiNet(taiiNetOptions); |
Copilot
AI
changed the title
Add GitHub Actions test workflow for push/PR events
Refactor React API to provider-initialized, typed stateful subscriptions
May 29, 2026
Copilot
AI
changed the title
Refactor React API to provider-initialized, typed stateful subscriptions
Move subscription shape typing from May 30, 2026
useTaiiNet to useSubscription
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
useTaiiNetpreviously carried a global subscription type map, which constrained consumers to one shape map per hook instance. This change moves shape typing touseSubscription, so each subscription call can declare its own typed shape map.API typing shift
useTaiiNet/UseTaiiNetResult.UseSubscriptionHookso typed mapping is declared per invocation (useSubscription<...>()), while preserving the untyped fallback overload.Consumer-facing usage update
useTaiiNet()result.Docs and contract alignment