Skip to content

feat(hex): expand API coverage, fix ID trimming, add cursor pagination#5372

Merged
waleedlatif1 merged 7 commits into
stagingfrom
worktree-hex-integration
Jul 2, 2026
Merged

feat(hex): expand API coverage, fix ID trimming, add cursor pagination#5372
waleedlatif1 merged 7 commits into
stagingfrom
worktree-hex-integration

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Added hex_update_collection, hex_create_group, hex_update_group, hex_delete_group, hex_deactivate_user tools + full block wiring (subBlocks, operations, tools.config mapping, outputs, skill)
  • Added missing run_project fields (viewId, notifications) and get_project_runs runTriggerFilter
  • Added after/before cursor pagination to list_projects, list_groups, list_data_connections, list_collections (confirmed against Hex's actual response envelope)
  • Added .trim() on every interpolated ID path param (projectId, runId, groupId, collectionId, dataConnectionId) across all tool files to guard against copy-paste whitespace from upstream block outputs
  • Verified every request/response shape against Hex's live API docs (learn.hex.tech), including two rounds of adversarial cross-checking that caught and fixed an inaccurate notifications schema example and a missing ALL enum value on runTriggerFilter

Type of Change

  • New feature / integration coverage expansion
  • Bug fix (missing .trim())

Testing

Tested manually — typecheck clean, biome clean, bun run check:api-validation passes, two independent subagent audits confirmed block/tool wiring is internally consistent and 100% backward compatible (no removed/renamed fields, only additive changes).

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 2, 2026 6:00pm

Request Review

@cursor

cursor Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
New workspace-admin actions (group delete, user deactivate) can change access if misused, but changes are additive integration wiring with no core auth changes.

Overview
Expands the Hex block and tools with five new operations—update collection, create/update/delete group, and deactivate user—plus full UI wiring, registry entries, types, and an onboard/offboard teammate skill.

Run and list behavior gains optional viewId and notifications on project runs, runTriggerFilter on project runs listing, richer list projects filters (collection, categories, emails, sort, include trashed/components), list users userIds filter, and after/before cursor pagination on major list endpoints (with run-list nextPage/previousPage). List users now surface lastLoginDate.

Reliability tweaks: .trim() on UUIDs in URL paths across Hex tools, and stricter JSON validation for run inputParams/notifications and list categories.

Reviewed by Cursor Bugbot for commit d34d447. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR expands the Hex integration with five new tools (hex_update_collection, hex_create_group, hex_update_group, hex_delete_group, hex_deactivate_user), adds missing fields to existing tools (viewId, notifications for run_project; runTriggerFilter for get_project_runs), and introduces cursor-based pagination (after/before) across all list endpoints. A .trim() guard is applied consistently to every UUID path parameter across the tool files.

  • New tools are correctly wired end-to-end: subBlocks, transformInputs, tools.config case switch, type interfaces, index exports, and registry registration all align. JSON array parameters (memberUserIds, addUserIds, removeUserIds, notifications, categories) include try/catch parse guards and Array.isArray validation, consistent with the fixes applied in previous review rounds.
  • Pagination reads from data.pagination?.after / data.pagination?.before on the response envelope — matching the Hex API's documented shape — and surfaces the cursors as outputs for downstream blocks.
  • The get_project_runs tool continues to expose nextPage/previousPage (not after/before), which is intentionally different because that endpoint uses its own envelope format.

Confidence Score: 5/5

All changes are purely additive — no existing fields renamed or removed, no existing behavior altered — making this safe to merge.

Every new tool follows the established Hex tool pattern faithfully: URL trimming on path params, try/catch + Array.isArray guards on JSON array inputs, consistent transformResponse conventions, and correct block wiring end-to-end. The previously flagged issues (JSON.parse try/catch, Array.isArray on notifications) have been addressed in commits referenced in the thread. The one edge case noted (empty PATCH body in update_collection/update_group) would produce an API-level error rather than silent data corruption.

No files require special attention; update_collection.ts and update_group.ts have a minor edge case around empty bodies but nothing that affects correct use.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/hex.ts Block config expanded with new operations, subBlocks, and output schema; transformInputs correctly renames block-level param IDs to tool param names for all new tools.
apps/sim/tools/hex/update_collection.ts New PATCH tool; sends an empty body when neither name nor description is provided, which may produce an unexpected API response.
apps/sim/tools/hex/update_group.ts New PATCH tool; same empty-body edge case as update_collection when no fields are supplied; parseIds helper and member add/remove wiring are correct.
apps/sim/tools/hex/create_group.ts New POST tool; JSON parse guard and Array.isArray check present; members body structure matches expected Hex API shape.
apps/sim/tools/hex/deactivate_user.ts New POST tool for user deactivation; URL trim applied; response branches are consistent with the delete_group pattern.
apps/sim/tools/hex/delete_group.ts New DELETE tool; groupId trimmed; response handling consistent with deactivate_user.
apps/sim/tools/hex/run_project.ts Adds viewId and notifications params; notifications includes try/catch and Array.isArray guard (addressing previous review feedback); inputParams parse now also wrapped in try/catch.
apps/sim/tools/hex/list_projects.ts Adds many new filter/sort/pagination params; categories JSON array handled with proper validation and repeated query-string appending; cursor pagination reads from data.pagination envelope.
apps/sim/tools/hex/types.ts New interfaces for all five new tools; existing param/response interfaces extended with new optional fields; HexResponse union updated.
apps/sim/tools/registry.ts All five new tools registered under their correct string keys in alphabetical order; no conflicts.
apps/sim/tools/hex/get_project_runs.ts Adds runTriggerFilter query param and nextPage/previousPage cursor outputs; projectId trim applied.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Block as HexBlock (hex.ts)
    participant Tool as Tool Layer
    participant API as Hex API

    Note over Block,API: New tools added in this PR

    Block->>Tool: "create_group { name, memberUserIds }"
    Tool->>API: "POST /api/v1/groups { name, members: { users } }"
    API-->>Tool: "{ id, name, createdAt }"
    Tool-->>Block: "{ id, name, createdAt }"

    Block->>Tool: "update_group { groupId, name?, addUserIds?, removeUserIds? }"
    Tool->>API: "PATCH /api/v1/groups/{groupId.trim()} { name?, members: { add, remove } }"
    API-->>Tool: "{ id, name, createdAt }"
    Tool-->>Block: "{ id, name, createdAt }"

    Block->>Tool: "delete_group { groupId }"
    Tool->>API: "DELETE /api/v1/groups/{groupId.trim()}"
    API-->>Tool: 204 No Content
    Tool-->>Block: "{ success: true, groupId }"

    Block->>Tool: "update_collection { collectionId, name?, description? }"
    Tool->>API: "PATCH /api/v1/collections/{collectionId.trim()} { name?, description? }"
    API-->>Tool: "{ id, name, description, creator }"
    Tool-->>Block: "{ id, name, description, creator }"

    Block->>Tool: "deactivate_user { userId }"
    Tool->>API: "POST /api/v1/users/{userId.trim()}/deactivate"
    API-->>Tool: 204 No Content
    Tool-->>Block: "{ success: true, userId }"

    Note over Block,API: Cursor pagination (list endpoints)
    Block->>Tool: "list_projects { after?, before?, ... }"
    Tool->>API: "GET /api/v1/projects?after=cursor&..."
    API-->>Tool: "{ values: [...], pagination: { after, before } }"
    Tool-->>Block: "{ projects, total, after, before }"
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Block as HexBlock (hex.ts)
    participant Tool as Tool Layer
    participant API as Hex API

    Note over Block,API: New tools added in this PR

    Block->>Tool: "create_group { name, memberUserIds }"
    Tool->>API: "POST /api/v1/groups { name, members: { users } }"
    API-->>Tool: "{ id, name, createdAt }"
    Tool-->>Block: "{ id, name, createdAt }"

    Block->>Tool: "update_group { groupId, name?, addUserIds?, removeUserIds? }"
    Tool->>API: "PATCH /api/v1/groups/{groupId.trim()} { name?, members: { add, remove } }"
    API-->>Tool: "{ id, name, createdAt }"
    Tool-->>Block: "{ id, name, createdAt }"

    Block->>Tool: "delete_group { groupId }"
    Tool->>API: "DELETE /api/v1/groups/{groupId.trim()}"
    API-->>Tool: 204 No Content
    Tool-->>Block: "{ success: true, groupId }"

    Block->>Tool: "update_collection { collectionId, name?, description? }"
    Tool->>API: "PATCH /api/v1/collections/{collectionId.trim()} { name?, description? }"
    API-->>Tool: "{ id, name, description, creator }"
    Tool-->>Block: "{ id, name, description, creator }"

    Block->>Tool: "deactivate_user { userId }"
    Tool->>API: "POST /api/v1/users/{userId.trim()}/deactivate"
    API-->>Tool: 204 No Content
    Tool-->>Block: "{ success: true, userId }"

    Note over Block,API: Cursor pagination (list endpoints)
    Block->>Tool: "list_projects { after?, before?, ... }"
    Tool->>API: "GET /api/v1/projects?after=cursor&..."
    API-->>Tool: "{ values: [...], pagination: { after, before } }"
    Tool-->>Block: "{ projects, total, after, before }"
Loading

Reviews (8): Last reviewed commit: "fix(hex): validate array element types, ..." | Re-trigger Greptile

Comment thread apps/sim/tools/hex/create_group.ts
Comment thread apps/sim/tools/hex/update_group.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/blocks/blocks/hex.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2364c15. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/tools/hex/list_projects.ts Outdated
Comment thread apps/sim/tools/hex/run_project.ts Outdated
Comment thread apps/sim/tools/hex/update_collection.ts
Comment thread apps/sim/tools/hex/create_group.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/tools/hex/list_projects.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/blocks/blocks/hex.ts
Comment thread apps/sim/tools/hex/run_project.ts
Comment thread apps/sim/tools/hex/create_group.ts
Comment thread apps/sim/tools/hex/run_project.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 9db288f. Configure here.

- Add hex_update_collection, hex_create_group, hex_update_group,
  hex_delete_group, hex_deactivate_user tools + block wiring
- Add missing run_project fields (viewId, notifications) and
  get_project_runs runTriggerFilter
- Add after/before cursor pagination to list_projects, list_groups,
  list_data_connections, list_collections
- Add .trim() on all interpolated ID path params to guard against
  copy-paste whitespace
Wrap JSON.parse calls for memberUserIds, addUserIds, removeUserIds,
inputParams, and notifications in try/catch so malformed input throws
a clear error instead of an opaque parse exception.
update_collection's params() mapping only copied collectionDescription
when truthy, so clearing it to an empty string in the UI never reached
the API. Untouched fields resolve to null (not undefined), so use a
loose null check to distinguish "cleared" from "never touched" without
sending description: null on every unrelated update.
Pulled Hex's actual OpenAPI spec (static.hex.site/openapi.json) as
ground truth for a final verification pass:

- list_users was missing after/before cursor pagination and the
  userIds filter, which the spec confirms it supports (an earlier
  doc-summary pass had incorrectly flagged this as unverifiable)
- list_users response also exposes lastLoginDate per user, not
  previously surfaced
- list_projects was missing includeComponents, includeTrashed,
  creatorEmail, ownerEmail, collectionId, categories, sortBy, and
  sortDirection filters that the spec confirms are real query params
Trim collectionId (list_projects filter), viewId (run_project body),
and group member UUIDs (create_group/update_group) to match the
.trim() convention already applied to path-segment IDs elsewhere.
categories, memberUserIds, addUserIds, and removeUserIds could parse
as valid JSON that isn't an array (e.g. an object), which would throw
an opaque "not iterable"/"map is not a function" error deeper in the
call. Validate Array.isArray after parsing and fail with a clear
message instead.
- notifications now gets the same Array.isArray guard already applied
  to categories/memberUserIds/addUserIds/removeUserIds
- member/category array elements are now validated as strings before
  .trim()/append, instead of crashing on non-string entries
- runTriggerFilter "All" option now sends the documented ALL enum
  value explicitly instead of relying on omission
@waleedlatif1 waleedlatif1 force-pushed the worktree-hex-integration branch from 9db288f to d34d447 Compare July 2, 2026 18:00
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d34d447. Configure here.

@waleedlatif1 waleedlatif1 merged commit 11c7a36 into staging Jul 2, 2026
17 of 18 checks passed
@waleedlatif1 waleedlatif1 deleted the worktree-hex-integration branch July 2, 2026 18:14
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