Skip to content

Conversation

nikgraf
Copy link
Collaborator

@nikgraf nikgraf commented Jul 4, 2025

No description provided.

@nikgraf nikgraf force-pushed the ng/fix-space-id-usage branch from 31be751 to ff51bd0 Compare July 4, 2025 14:33
@nikgraf nikgraf requested a review from Copilot July 4, 2025 14:33
@nikgraf nikgraf merged commit b3ef0bb into main Jul 4, 2025
6 checks passed
@nikgraf nikgraf deleted the ng/fix-space-id-usage branch July 4, 2025 14:37
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures the space parameter is consistently captured and forwarded through query hooks, adds an explicit fallback for missing context, and updates the Playground component to accept and propagate a spaceId.

  • Propagate the space argument from useQuery into useQueryPublic and useQueryLocal
  • Introduce space in QueryPublicParams and QueryParams
  • Provide a default fallback in useHypergraphSpaceInternal and update Playground to take spaceId

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/hypergraph-react/src/use-query.tsx Forward space to useQueryPublic
packages/hypergraph-react/src/internal/use-query-public.tsx Destructure/merge space from params and context
packages/hypergraph-react/src/internal/types.ts Add space to QueryPublicParams
packages/hypergraph-react/src/HypergraphSpaceContext.tsx Return default { space: '' } if context is missing
apps/events/src/routes/playground.lazy.tsx Pass spaceId into Playground and wrap children in provider
apps/events/src/components/playground.tsx Change Playground signature to accept spaceId
Comments suppressed due to low confidence (2)

packages/hypergraph-react/src/internal/types.ts:6

  • [nitpick] Consider renaming this space property to spaceId to align with other APIs and clarify that it represents an identifier.
  space?: string | undefined;

packages/hypergraph-react/src/use-query.tsx:149

  • Add unit tests to verify that the space parameter is correctly forwarded to useQueryPublic and that context fallback behaves as expected.
  const publicResult = useQueryPublic(type, { enabled: mode === 'public', include, first, space });

export function useHypergraphSpaceInternal() {
const context = useContext(HypergraphReactContext);
return context as HypergraphContext;
return (context as HypergraphContext) || { space: '' };
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

Fallbacking to an empty string when context is missing can mask missing provider issues. Consider throwing an error or logging a warning to catch unintended usage early.

Suggested change
return (context as HypergraphContext) || { space: '' };
if (!context) {
throw new Error('HypergraphReactContext provider is missing. Ensure that HypergraphSpaceProvider is used.');
}
return context as HypergraphContext;

Copilot uses AI. Check for mistakes.

// TODO: for multi-level nesting it should only allow the allowed properties instead of Record<string, Record<string, never>>
include?: { [K in keyof Schema.Schema.Type<S>]?: Record<string, Record<string, never>> } | undefined;
space?: string;
space?: string | undefined;
Copy link

Copilot AI Jul 4, 2025

Choose a reason for hiding this comment

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

[nitpick] The explicit | undefined is redundant for an optional property; you can simplify this to space?: string for clarity.

Suggested change
space?: string | undefined;
space?: string;

Copilot uses AI. Check for mistakes.

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.

1 participant