Skip to content

feat: show content section badge in search results#85

Merged
rsbh merged 4 commits into
mainfrom
feat/search-folder-badge
May 18, 2026
Merged

feat: show content section badge in search results#85
rsbh merged 4 commits into
mainfrom
feat/search-folder-badge

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented May 18, 2026

Summary

  • Add section field to search API response, derived from URL's first segment matched against content/API config entries
  • Display section label (e.g. "Docs", "Petstore") as a badge on the right side of each search result

Test plan

  • Search suggestions show section badge
  • Search results show section badge
  • Badge shows correct label from config (content label or API name)
  • Results without a matching section show no badge

🤖 Generated with Claude Code

rsbh and others added 2 commits May 18, 2026 14:25
Derive section from URL's first segment matched against content/API
config entries. Returns label (e.g. "Docs", "Petstore") per result.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Display content folder label (e.g. "Docs", "Petstore") as a badge
on the right side of each search result.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 18, 2026

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

Project Deployment Actions Updated (UTC)
chronicle Ready Ready Preview, Comment May 18, 2026 9:10am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Review Change Stack

Warning

Rate limit exceeded

@rsbh has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 11 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 077a4e67-785a-4aae-8c6c-4b425fa38748

📥 Commits

Reviewing files that changed from the base of the PR and between f8ff37d and 5e3a65f.

📒 Files selected for processing (1)
  • packages/chronicle/src/server/api/search.ts
📝 Walkthrough

Walkthrough

This PR extends the search feature with section labeling. Backend code computes section identifiers from configured content paths and API spec names, stores them in the search index, and returns them in API responses. The UI imports a Badge component and renders section labels as right-aligned badges alongside search suggestions and results.

Changes

Search Results Section Labeling

Layer / File(s) Summary
Section data contract and derivation logic
packages/chronicle/src/server/api/search.ts
SearchDocument type gains an optional section field. New buildSectionMap and getSectionLabel helpers map configured content/API base paths to section labels and extract labels by URL first path segment or OpenAPI spec name.
Index schema and document insertion
packages/chronicle/src/server/api/search.ts
The search_docs SQLite table adds version and section columns. Document insertion logic is updated to include section values computed from page URLs via the section map or from API spec names. buildDocs loads config and constructs the section mapping.
API response inclusion
packages/chronicle/src/server/api/search.ts
Empty-query search responses select and return the section field (nullable) for each result from the search index.
Section badge rendering and styling
packages/chronicle/src/components/ui/search.tsx, packages/chronicle/src/components/ui/search.module.css
SearchResult type is extended with optional section?: string. Badge component is imported and conditionally rendered in both suggestion items and search results. CSS styling adds .sectionBadge with margin-left: auto and flex-shrink: 0 to right-align the badge, and .itemContent is updated to flex: 1 for proper layout growth.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • raystack/chronicle#8: Introduces the core search UI components (search.tsx and search.module.css) that are extended in this PR to display section-labeled results.

Suggested reviewers

  • rohilsurana
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: show content section badge in search results' clearly and directly describes the main change: adding a visible section badge to search results.
Description check ✅ Passed The description is directly related to the changeset, explaining the section field addition to the API response and its display as a badge in the search UI with test coverage details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/search-folder-badge

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.

Compute section label once during indexing and store in search_docs
table. Query handler reads it directly from DB.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Section for docs pages derived from URL + config.content inline.
Section for API pages uses spec.name directly. No helper functions needed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/chronicle/src/server/api/search.ts`:
- Around line 228-238: The map keys created in buildSectionMap use basePath with
only the leading slash removed, so values like "/apis/" become "apis/" and won't
match later lookups; update the basePath normalization in buildSectionMap (the
basePath variable) to strip both leading and trailing slashes (e.g., remove any
trailing "/" after removing the leading "/") before calling map.set so stored
keys match URL-segment extraction.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8c842fd1-61df-491d-94b6-6c0dbd216e4f

📥 Commits

Reviewing files that changed from the base of the PR and between 920543a and f8ff37d.

📒 Files selected for processing (3)
  • packages/chronicle/src/components/ui/search.module.css
  • packages/chronicle/src/components/ui/search.tsx
  • packages/chronicle/src/server/api/search.ts

Comment thread packages/chronicle/src/server/api/search.ts Outdated
@rsbh rsbh merged commit 5d9c944 into main May 18, 2026
4 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.

2 participants