Skip to content

Conversation

davemarco
Copy link
Contributor

@davemarco davemarco commented Sep 7, 2025

Description

Moves common types into common workspace. Includes route types, and some other shared types like nullable.

Imports keep common folder structure, instead of using barrel file which is discouraged.

I didnt move some stream metadata types since the types are not exactly the same on server and client. This is due to the types existing prior to new webui work. These types/code need to be refactored first, then can be moved.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

UI loads. Query still sent

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of cancelling and clearing searches by ensuring job IDs are handled consistently.
  • Refactor

    • Centralized shared types, schemas and enums to unify data contracts across the app.
    • Broadened common package exports to allow direct subpath imports.
  • Style

    • Simplified ESLint rules with pattern-based exceptions for TypeBox-related identifiers.
  • Chores

    • Updated import paths across client and server to use the new common module subpaths.

Copy link
Contributor

coderabbitai bot commented Sep 7, 2025

Walkthrough

Refactors and centralizes TypeScript types into @webui/common subpaths, replaces local enums/types with shared modules, updates imports across client and server, adds domain-specific common modules (socket, metadata, presto, query, config), removes the monolithic common index, and adjusts ESLint export patterns. Control flow unchanged.

Changes

Cohort / File(s) Summary
Client API: search & presto
components/webui/client/src/api/presto-search/index.ts, components/webui/client/src/api/search/index.ts
Replace local inline schema types with shared @webui/common/schemas/* types; update function signatures to use exported Static-derived types; remove local type exports.
Client socket types
components/webui/client/src/api/socket/*
components/webui/client/src/api/socket/MongoSocketCollection.ts, .../MongoSocketCursor.ts, .../SocketSingleton.ts, .../useCursor.tsx
Repoint socket event/type imports to @webui/common/socket; change Nullable imports to @webui/common/utility-types. No runtime behavior changes.
Client pages/components: Nullable & presto types
components/webui/client/src/components/**, components/webui/client/src/pages/**, components/webui/client/src/ui/**
Switch many Nullable imports to @webui/common/utility-types; move PrestoSearchResult type imports to @webui/common/presto. No logic changes.
Client search handlers & ID coercion
components/webui/client/src/pages/SearchPage/**
.../SearchControls/search-requests.ts, .../SearchButton/CancelButton.tsx, .../Presto/presto-search-requests.ts
Use shared QueryJob/PrestoQueryJob types; coerce job IDs to numbers when cancelling/clearing and convert to strings when storing after submit.
Client stream-files & typings
components/webui/client/src/api/stream-files/index.ts, components/webui/client/src/typings/query.ts
Centralize QUERY_JOB_TYPE to @webui/common/query; remove local enum export; update Nullable imports.
Client config import
components/webui/client/src/config/index.ts
Import CLP_QUERY_ENGINES from @webui/common/config.
Common package exports
components/webui/common/package.json
Change exports mapping from top-level "." to wildcard "./*" using dist/*.js and dist/*.d.ts to enable subpath imports.
Common: split public API
components/webui/common/src/index.ts (removed), .../src/socket.ts, .../src/metadata.ts, .../src/presto.ts, .../src/query.ts, .../src/config.ts
Remove monolithic index file; add domain modules: typed socket API, metadata enums/types, presto result types, query enum/constants, and CLP query engines enum; export those types.
Common schemas: Static-derived types
components/webui/common/src/schemas/*.ts
presto-search.ts, search.ts, stream-files.ts, archive-metadata.ts
Add TypeBox Static-derived type aliases (e.g., QueryJob, QueryJobCreation, PrestoQueryJob*) and export them; adjust some internal imports.
Server: imports to common subpaths
components/webui/server/src/plugins/**, components/webui/server/src/routes/api/**
Redirect many server imports to @webui/common/* subpaths (config, metadata, query, schemas, socket types); no functional changes.
Server typings cleanup
components/webui/server/src/typings/common.ts, .../typings/query.ts
Remove local Nullable and local QUERY_JOB_TYPE/EXTRACT_JOB_TYPES exports; rely on @webui/common equivalents.
ESLint configs
components/webui/common/eslint.config.mjs, components/webui/client/eslint.config.mjs, components/webui/server/eslint.config.mjs
Replace explicit new-cap exceptions with `capIsNewExceptionPattern: "^(Type

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UI as Client UI
  participant ClientAPI as Client API (search/presto)
  participant Server as Server Routes
  note right of ClientAPI: payload types now from @webui/common/schemas/*
  UI->>ClientAPI: handleQuerySubmit(payload: QueryJobCreation)
  ClientAPI->>Server: POST /search (body typed as QueryJobCreation)
  Server-->>ClientAPI: 200 OK (body typed as QueryJob with numeric IDs)
  ClientAPI-->>UI: response (IDs numeric)
  UI->>UI: store IDs as strings (toString)
  UI->>ClientAPI: handleQueryCancel({ searchJobId: Number(id), aggregationJobId: Number(id) })
  ClientAPI->>Server: POST /search/cancel (typed as QueryJob)
  Server-->>ClientAPI: 200 OK
  ClientAPI-->>UI: success ack
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f18df92 and c09333d.

📒 Files selected for processing (1)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlQueryInput/index.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}

⚙️ CodeRabbit configuration file

  • Prefer false == <expression> rather than !<expression>.

Files:

  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlQueryInput/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: package-image
  • GitHub Check: antlr-code-committed (macos-15)
🔇 Additional comments (1)
components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlQueryInput/index.tsx (1)

8-9: Import Nullable as a type-only import.

Apply this diff:

-import {Nullable} from "@webui/common/utility-types";
+import type {Nullable} from "@webui/common/utility-types";

package.json exports use the "./*" wildcard so "./utility-types" is covered and src/utility-types.ts exports Nullable as a type — ensure the build emits dist/utility-types.{js,d.ts} for consumers.

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Title Check ✅ Passed The title is a short, single-sentence summary that clearly describes the primary change—moving shared TypeScript types into the common workspace—and aligns with the changeset that centralises types under @webui/common and updates imports across client and server files. It is concise, specific, and free of noise or irrelevant details, so a reviewer scanning history will understand the main intent.

@davemarco davemarco requested a review from hoophalab September 8, 2025 14:54
@davemarco davemarco marked this pull request as ready for review September 8, 2025 14:55
@davemarco davemarco requested a review from a team as a code owner September 8, 2025 14:55
coderabbitai[bot]

This comment was marked as off-topic.

Copy link
Contributor

@hoophalab hoophalab left a comment

Choose a reason for hiding this comment

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

looks good. Some minor suggestions.
Validations: Ingest, query, stream extraction, timeline, and data table work.

Comment on lines 22 to 32
capIsNewExceptions: [
"Type.Any",
"Type.Enum",
"Type.Integer",
"Type.Literal",
"Type.Null",
"Type.Required",
"Type.Union",
"Value.Errors",
"Value.Parse",
],
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
capIsNewExceptions: [
"Type.Any",
"Type.Enum",
"Type.Integer",
"Type.Literal",
"Type.Null",
"Type.Required",
"Type.Union",
"Value.Errors",
"Value.Parse",
],
capIsNewExceptionPattern: "(^Type\\..)|(^Value\\..)",

How about using this flag? If yes, we should also update eslint.config.mjs in client and server. Let me know if you feel this is a bad idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think good idea I will test

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
components/webui/common/eslint.config.mjs (2)

16-26: Pattern-based TypeBox exemption looks good and addresses prior feedback

Switching to capIsNewExceptionPattern for Type/Value resolves the earlier reviewer concern about incomplete exceptions. Thanks for aligning with client/server.


22-22: Tighten regex to only match PascalCase members under Type/Value

Small hardening to avoid exempting unrelated members: anchor the property to uppercase.

Apply:

-                    capIsNewExceptionPattern: "^(Type|Value)\\.",
+                    capIsNewExceptionPattern: "^(Type|Value)\\.[A-Z]",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f1b4af and 9a60015.

📒 Files selected for processing (3)
  • components/webui/client/eslint.config.mjs (1 hunks)
  • components/webui/common/eslint.config.mjs (1 hunks)
  • components/webui/server/eslint.config.mjs (1 hunks)
🔇 Additional comments (2)
components/webui/client/eslint.config.mjs (1)

34-40: Remove explicit "Decode"/"Encode" exceptions — no bare usages found

Search of components/webui/client returned no bare Decode/Encode call sites; the regex capIsNewExceptionPattern (^(Type|Value).) covers Value.Decode/Encode, so remove "Decode" and "Encode" from capIsNewExceptions in components/webui/client/eslint.config.mjs.

components/webui/server/eslint.config.mjs (1)

22-22: Regex approach matches client/common; nice consistency

This removes the need to enumerate TypeBox factories.

"Type.Union",
"Value.Parse",
],
capIsNewExceptionPattern: "^(Type|Value)\\.",
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Nit: restrict the exemption to PascalCase members

Prevents accidentally exempting non-factory members.

-                    capIsNewExceptionPattern: "^(Type|Value)\\.",
+                    capIsNewExceptionPattern: "^(Type|Value)\\.[A-Z]",
📝 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
capIsNewExceptionPattern: "^(Type|Value)\\.",
capIsNewExceptionPattern: "^(Type|Value)\\.[A-Z]",
🤖 Prompt for AI Agents
In components/webui/client/eslint.config.mjs around line 39, the current
capIsNewExceptionPattern ("^(Type|Value)\\.") is too broad and may exempt
non-factory members; change the pattern to require PascalCase names before the
dot (e.g., require the identifier to start with an uppercase letter followed by
letters/digits) so only PascalCase members are exempted — update the pattern
accordingly to something that matches an initial uppercase letter then
alphanumerics before the dot (for example: start with ^, then [A-Z] followed by
[A-Za-z0-9]*, then \\.), and replace the existing value with that stricter
regex.

"Value.Errors",
"Value.Parse",
],
capIsNewExceptionPattern: "^(Type|Value)\\.",
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Nit: narrow the regex to uppercase members

Same tightening as elsewhere.

-                    capIsNewExceptionPattern: "^(Type|Value)\\.",
+                    capIsNewExceptionPattern: "^(Type|Value)\\.[A-Z]",
📝 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
capIsNewExceptionPattern: "^(Type|Value)\\.",
capIsNewExceptionPattern: "^(Type|Value)\\.[A-Z]",
🤖 Prompt for AI Agents
In components/webui/server/eslint.config.mjs around line 22, the regex
capIsNewExceptionPattern is too broad (matches any member after "Type." or
"Value."); tighten it to only match when the member name starts with an
uppercase letter by requiring an uppercase char after the dot (update the
pattern string accordingly, keeping proper escaping).

@davemarco davemarco requested a review from hoophalab September 11, 2025 15:28
Copy link
Contributor

@hoophalab hoophalab left a comment

Choose a reason for hiding this comment

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

lgtm

@davemarco davemarco changed the title chore(webui): Move shared types to common workspace. refactor(webui): Move shared types to common workspace. Sep 15, 2025
@davemarco davemarco merged commit 0d1b12c into y-scope:main Sep 15, 2025
20 checks passed
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.

3 participants