Skip to content

fix(algolia): tighten tools.config, add geo/facet search + task-status tool; icon/color tweaks#5356

Open
waleedlatif1 wants to merge 5 commits into
stagingfrom
worktree-algolia-validate
Open

fix(algolia): tighten tools.config, add geo/facet search + task-status tool; icon/color tweaks#5356
waleedlatif1 wants to merge 5 commits into
stagingfrom
worktree-algolia-validate

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Ran a full /validate-integration pass on Algolia against the live REST API docs (14 tools + block).
  • tools.config.tool was doing param remapping/coercion (createIfNotExists, forwardToReplicas, copyMoveOperation→operation, deleteFilters→filters, getRecordsRequests→requests, list pagination) at serialization time, before variable resolution — this could destroy dynamic <Block.output> references. Split into a pure tool() selector and a proper params() function.
  • facets and getRankingInfo were never sent by the search tool, so the documented facets/facets_stats/_rankingInfo outputs were permanently unreachable. Wired both through.
  • Geo-search (aroundLatLng/aroundRadius/insideBoundingBox/insidePolygon) only existed on delete_by_filter, not on search/browse_records — added to both.
  • Fixed aroundRadius's declared type (was number, but the field legitimately accepts "all").
  • Synced batch_operations' param description with the real action set (was missing delete/clear, present elsewhere).
  • Consolidated list_indices pagination into the shared page/hitsPerPage fields instead of duplicate listPage/listHitsPerPage subBlocks + remapping.
  • Added algolia_get_task_status (every write op returns a taskID but there was no way to poll it — cheap, high-leverage addition per the endpoint audit).
  • .trim() on indexName/objectID/destination before building request URLs.
  • Added 2 niche skills (ranking tuning, index snapshot-before-change) to AlgoliaBlockMeta, grounded in existing tools.
  • Swapped the Dropcontact icon to the official wordmark's teal swirl mark (leftmost mark only, not the full wordmark) and updated bgColor to match; regenerated docs.
  • Set Grafana's bgColor to white.

Endpoints intentionally NOT added (from the audit): synonyms/rules management, API key management, multi-cluster, A/B testing, Recommend — all separate products or lower-value relative to core CRUD/search/settings coverage already in place.

Type of Change

  • Bug fix
  • Enhancement

Testing

Tested manually; bun run lint and targeted typecheck clean.

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)

…arch, task status tool

- move all tools.config coercion/remapping out of tool() into a proper params() function so dynamic block references aren't destroyed before variable resolution
- wire facets and getRankingInfo into the search tool so those documented outputs are actually reachable
- add geo-search (aroundLatLng/aroundRadius/insideBoundingBox/insidePolygon) to search and browse_records, matching delete_by_filter
- fix aroundRadius param type (string, not number, since it accepts "all")
- sync batch_operations description with the real action set (delete, clear)
- consolidate list_indices pagination into the shared page/hitsPerPage fields instead of duplicate listPage/listHitsPerPage
- add algolia_get_task_status tool so workflows can poll a taskID instead of guessing when a write is applied
- trim indexName/objectID/destination before building request URLs
- add ranking-tuning and index-snapshot skills to AlgoliaBlockMeta

fix(dropcontact): swap icon to the official wordmark's teal swirl mark, bgColor to match

chore(grafana): bgColor to white to match brand tile convention
@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 7:11am

Request Review

@cursor

cursor Bot commented Jul 2, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Algolia changes alter how saved workflows serialize params and can affect live index/search behavior; mistakes in delete/batch/geo calls could impact production data, though migrations reduce breakage for renamed subblocks.

Overview
Algolia gets the largest set of changes: the block’s tools.config now uses a pure tool() selector plus a dedicated params() mapper so remapping/coercion no longer runs at the wrong time (avoiding broken dynamic references). Search gains facets, getRankingInfo, and geo parameters; browse gains the same geo options; Get Task Status is a new operation/tool/docs entry; list-indices pagination reuses shared page/hitsPerPage with a subblock ID migration from listPage/listHitsPerPage. Request URLs trim index/object IDs; batch action docs include delete/clear; aroundRadius is documented/typed as a string where "all" is valid.

Dropcontact and Grafana are visual-only: official teal swirl icon and #0ABA9F branding for Dropcontact; Grafana block/docs card background set to white. Two new Algolia block skills cover ranking tuning and pre-change index snapshots.

Reviewed by Cursor Bugbot for commit 6fde39f. Configure here.

Comment thread apps/sim/blocks/blocks/algolia.ts Outdated
Comment thread apps/sim/blocks/blocks/algolia.ts
Comment thread apps/sim/blocks/blocks/dropcontact.ts
…Page

CI's subblock-id stability check correctly flagged that consolidating
list_indices pagination into the shared page/hitsPerPage fields would
silently drop values from already-deployed workflows. Add the rename
mapping so existing saved state migrates instead of being lost.
@greptile-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR performs a comprehensive audit and fix pass on the Algolia integration: it corrects the tools.config to split into a pure tool() selector and a proper params() function (preventing premature variable resolution), wires facets/getRankingInfo through to the search response, extends geo-search params to search and browse_records, fixes aroundRadius type, consolidates list_indices pagination, adds a new algolia_get_task_status tool, and applies .trim() to index/object names across all write tools. Icon and color tweaks for Dropcontact and Grafana round out the change.

  • params() refactor (algolia.ts): the old tool() function mutated params in-place before variable resolution; the new split ensures dynamic <Block.output> references are resolved before any coercion or remapping runs.
  • New get_task_status tool (get_task_status.ts, registry.ts): polls GET /1/indexes/{index}/task/{taskID} and exposes status ("published"/"notPublished"), closing the loop on every write operation that returns a taskID.
  • Subblock migration (subblock-migrations.ts): listPagepage and listHitsPerPagehitsPerPage preserve saved workflow state after the pagination field consolidation.

Confidence Score: 4/5

The change is safe to merge with one outstanding fix: the search tool still sends an untrimmed indexName in the POST body, which can cause 404s for indices where the value has stray whitespace.

The params() refactor and new geo/facet/task-status additions are well-implemented. The one concrete defect is in search.ts: indexName is placed untrimmed in the multi-index request body while every other tool in this PR correctly trims before encoding into the URL. A leading or trailing space in the index name — easily introduced by a block wiring that returns whitespace-padded output — will cause Algolia to silently 404 the entire search call.

apps/sim/tools/algolia/search.ts — indexName in the POST body needs .trim() to match the treatment applied across every other Algolia tool in this PR

Important Files Changed

Filename Overview
apps/sim/tools/algolia/search.ts Added facets, getRankingInfo, and all four geo-search params; indexName is still not trimmed in the request body
apps/sim/tools/algolia/get_task_status.ts New tool for polling Algolia task completion; well-structured, follows existing tool patterns
apps/sim/blocks/blocks/algolia.ts Refactored config.tool to pure selector + params(), added get_task_status op, wired facets/geo params, migrated list_indices pagination subBlocks to shared fields
apps/sim/tools/algolia/browse_records.ts Added all four geo-search parameters and indexName.trim(); geo params are correctly omitted when cursor pagination is active
apps/sim/lib/workflows/migrations/subblock-migrations.ts Added algolia migration for listPage→page and listHitsPerPage→hitsPerPage to preserve saved workflow state after subBlock consolidation
apps/sim/tools/algolia/delete_by_filter.ts Fixed aroundRadius declared type from number to string (accommodates 'all' value), added indexName.trim()
apps/sim/tools/algolia/types.ts Added type definitions for new geo-search params on search/browse, and new AlgoliaGetTaskStatus param/response interfaces
apps/sim/tools/registry.ts Registered algoliaGetTaskStatusTool in the global tool registry

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant W as Workflow
    participant B as Algolia Block (params())
    participant T as Tool (e.g. add_record)
    participant A as Algolia REST API
    participant GT as get_task_status Tool

    W->>B: operation + subBlock values
    B->>B: strip empty/null/undefined, coerce booleans, remap aliased fields
    B->>T: clean params object
    T->>A: "POST /1/indexes/{indexName}/... (with .trim())"
    A-->>T: "{ taskID, updatedAt }"
    T-->>W: output.taskID (number)

    Note over W: user wires taskID to get_task_status

    W->>GT: "{ indexName, taskID }"
    GT->>A: "GET /1/indexes/{indexName}/task/{taskID}"
    A-->>GT: "{ status: published or notPublished }"
    GT-->>W: output.status
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 W as Workflow
    participant B as Algolia Block (params())
    participant T as Tool (e.g. add_record)
    participant A as Algolia REST API
    participant GT as get_task_status Tool

    W->>B: operation + subBlock values
    B->>B: strip empty/null/undefined, coerce booleans, remap aliased fields
    B->>T: clean params object
    T->>A: "POST /1/indexes/{indexName}/... (with .trim())"
    A-->>T: "{ taskID, updatedAt }"
    T-->>W: output.taskID (number)

    Note over W: user wires taskID to get_task_status

    W->>GT: "{ indexName, taskID }"
    GT->>A: "GET /1/indexes/{indexName}/task/{taskID}"
    A-->>GT: "{ status: published or notPublished }"
    GT-->>W: output.status
Loading

Comments Outside Diff (1)

  1. apps/sim/tools/algolia/search.ts, line 108-111 (link)

    P1 The indexName placed in the request body is not trimmed. Every other Algolia tool in this PR calls .trim() before encoding the index name into the URL, but the search tool sends the multi-index endpoint with indexName inside the POST body. A stray leading or trailing space will cause Algolia to return a 404 for an otherwise valid index name.

Reviews (2): Last reviewed commit: "fix(algolia): coerce getRankingInfo/crea..." | Re-trigger Greptile

Algolia's Get Task Status response (additionalProperties: false) only
returns `status` (published | notPublished) — pendingTask belongs to
the List Indices response, not this endpoint. Drop it from the tool's
output, response type, and block outputs rather than inventing data.
…as from real booleans, not just strings

A wired <Block.output> boolean (e.g. true) failed the `=== 'true'`
string-only checks and silently flipped to the wrong value. Add a
toBool helper that accepts both the dropdown's string values and a
genuine boolean passed in via a dynamic reference.

fix(dropcontact): render icon with currentColor instead of hardcoded fill

The new teal swirl mark's fill (#0ABA9F) matched the block's bgColor
exactly, making the icon invisible on its own tile. Use currentColor
and set iconColor so the shared tile-contrast logic (getTileIconColorClass)
renders it white-on-teal like the rest of the brand icon system.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Greptile caught that search.ts's body-level indexName (sent inside the
multi-query POST body, not URL-encoded) wasn't trimmed like every other
tool's URL-path indexName. Fixed there and in get_records.ts's per-request
indexName default/override, which had the same gap.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

Fixed in 1a8b0c3search.ts's body-level indexName (sent inside the multi-query POST body, not URL-encoded like every other tool) wasn't trimmed. Also caught and fixed the same gap in get_records.ts's per-request indexName default/override. Thanks for catching this.

@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.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6fde39f. Configure here.

output: {
status: data.status ?? '',
},
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Task status omits pendingTask

Medium Severity

The new algolia_get_task_status integration documents a pendingTask output and the Algolia task endpoint exposes it, but transformResponse only forwards status. Workflows and docs that branch on pendingTask never receive that field.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6fde39f. Configure here.

.split(',')
.map((a: string) => a.trim())
}
if (params.facets) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Search index name not trimmed

Low Severity

This change trims indexName (and related IDs) in most Algolia tools, but the search multi-query body still passes params.indexName unchanged. Leading or trailing whitespace on the index name can make search fail while other operations on the same block succeed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 6fde39f. Configure here.

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