Skip to content

feat(mcp,extension,client): date-range search, agent abort support, i18n fixes#152

Merged
lcomplete merged 2 commits into
mainfrom
dev
Apr 28, 2026
Merged

feat(mcp,extension,client): date-range search, agent abort support, i18n fixes#152
lcomplete merged 2 commits into
mainfrom
dev

Conversation

@lcomplete
Copy link
Copy Markdown
Owner

Summary

  • Server – MCP search enhancements: add start_date/end_date/date_field date-range filtering and pagination (page parameter) to SearchContentTool; expose collectionId/collectedAt in all McpPageItem builder paths; add structured filter fields (contentType, libraryFilter, alreadyRead, searchTitleOnly) directly to SearchQuery instead of relying on the legacy queryOptions string; refactor McpServerController tool dispatch with getToolArguments/executeTool helpers; refactor LuceneService search-option resolution and add buildSearchDateRangeQuery
  • Server – new MCP tools: ListCollections, ListCollectionContent, GetXSaveRules
  • Extension – agent tools: add AbortSignal support to createAgentToolContext and MCP client loading so in-flight requests are cancelled when the user stops a chat; add getCurrentTimeTool for time-aware AI responses; add retry button (RotateCcw) to UserMessage; increase agent tool loop max steps from 5 → 50
  • Client – i18n: translate document titles and nav labels in all settings pages and PageList so they update correctly on language switch

Test plan

  • Server: ./mvnw test in huntly-server — new unit tests in SearchContentToolTest, CollectionMcpToolsTest, GetXSaveRulesToolTest, McpUtilsTest, LuceneServiceSearchSyntaxTest, McpServerControllerTest all pass
  • Extension: yarn test in app/extensionagentToolsAbort.test.ts and UserMessage.test.tsx pass
  • Manual: verify MCP search with start_date/end_date returns only items in range
  • Manual: verify aborting a chat cancels MCP SSE connections (no dangling requests)
  • Manual: switch UI language and confirm settings page titles and nav labels update immediately

🤖 Generated with Claude Code

…18n fixes

Server:
- Add date range filtering (start_date/end_date/date_field) and pagination to MCP search tool
- Add collectionId/collectedAt fields to McpPageItem and all builder paths in McpUtils
- Add structured filter fields (contentType, libraryFilter, alreadyRead, searchTitleOnly) to SearchQuery
- Add new MCP tools: ListCollections, ListCollectionContent, GetXSaveRules
- Refactor McpServerController tool dispatch with getToolArguments/executeTool helpers
- Refactor LuceneService search option resolution; add buildSearchDateRangeQuery

Extension:
- Add AbortSignal support to createAgentToolContext and MCP client loading
- Add getCurrentTimeTool for time-aware AI responses
- Add retry button to UserMessage component
- Increase agent tool loop max steps from 5 to 50

Client:
- Fix i18n: translate document titles and nav labels in settings pages and PageList

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Apr 28, 2026

🤖 Augment PR Summary

Summary: This PR expands Huntly’s MCP surface area across server + extension, adding date-range search/pagination support, abortable agent tool loading, and i18n fixes for document titles.

Changes:

  • Server (MCP search): `search_content` now supports `start_date`/`end_date` with `date_field`, plus 1-based pagination via `page` and richer paging metadata in responses.
  • Server (search plumbing): Search filters are modeled as structured fields on `SearchQuery` and resolved in `LuceneService`, including a Lucene date-range query builder.
  • Server (MCP items): `McpPageItem` now consistently includes `collectionId` and `collectedAt` across builder paths.
  • Server (new tools): Adds `list_collections`, `list_collection_content`, and `get_x_save_rules`, with new unit tests covering these tools and controller behavior.
  • Extension (agent tooling): Adds `AbortSignal` support so in-flight MCP tool loading/SSE work can be cancelled, and introduces a local `get_current_time` tool.
  • Extension (UI): Adds a retry action for user messages and increases the tool-loop max steps from 5 → 50.
  • Client (i18n): Translates settings/nav document titles and labels so they update immediately when switching languages.

Technical Notes: Date filtering is applied in Lucene as a LongPoint range query over the selected timestamp field (created_at, collected_at, or last_read_at).

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

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

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

String endDate = mcpUtils.getStringArg(arguments, "end_date");
String dateField = mcpUtils.getStringArg(arguments, "date_field");
int limit = Math.min(Math.max(mcpUtils.getIntArg(arguments, "limit", 50), 1), 500);
int page = Math.max(mcpUtils.getIntArg(arguments, "page", 1), 1);
Copy link
Copy Markdown

@augmentcode augmentcode Bot Apr 28, 2026

Choose a reason for hiding this comment

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

app/server/huntly-server/src/main/java/com/huntly/server/mcp/tool/SearchContentTool.java:118page is only clamped to >=1, so a very large page combined with a large limit can drive page * size extremely high in Lucene (TopScoreDocCollector.create(page * size, ...)), risking integer overflow or excessive memory usage. This is user-controllable via the MCP tool arguments, so it can become a stability issue.

Severity: high

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

if (date.contains("T") || date.contains(":")) {
return parseSearchDateTime(date);
}
return LocalDate.parse(date).atStartOfDay(ZoneId.systemDefault()).toInstant().plus(plusDay, ChronoUnit.DAYS);
Copy link
Copy Markdown

@augmentcode augmentcode Bot Apr 28, 2026

Choose a reason for hiding this comment

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

app/server/huntly-server/src/main/java/com/huntly/server/service/LuceneService.java:704LocalDate.parse(...) (and LocalDateTime.parse(...) in the fallback path) can throw DateTimeParseException, which will bubble up and fail the whole search_content call for a simple typo in start_date/end_date. It may be worth ensuring invalid date inputs produce a controlled/agent-friendly error rather than an internal exception.

Severity: medium

Other Locations
  • app/server/huntly-server/src/main/java/com/huntly/server/service/LuceneService.java:714

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Instant start = parseSearchDate(searchQuery.getStartDate(), 0);
Instant end = parseSearchDate(searchQuery.getEndDate(), 1);
long startEpochSecond = start != null ? start.getEpochSecond() : Long.MIN_VALUE;
long endEpochSecond = end != null ? end.getEpochSecond() - 1 : Long.MAX_VALUE;
Copy link
Copy Markdown

@augmentcode augmentcode Bot Apr 28, 2026

Choose a reason for hiding this comment

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

app/server/huntly-server/src/main/java/com/huntly/server/service/LuceneService.java:670 — Subtracting 1 second from endEpochSecond makes end_date effectively exclusive at second granularity, which can be surprising when callers provide a precise timestamp (e.g., results at exactly the end second will be omitted). If this is intentional, it may need to be documented explicitly for date-time inputs (not just date-only inputs).

Severity: low

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

- Use <= threshold in isScrollPinnedToBottom and raise threshold to 160px
- Switch useScrollPinToBottom to useLayoutEffect and direct scrollTop assignment
  to avoid rAF/scrollIntoView jitter during streaming
- Cap SearchContentTool page to MAX_LUCENE_RESULT_WINDOW/MAX_LIMIT (20) to keep
  Lucene collection bounded; reflect constraint in schema and execute clamping
- Add comprehensive hook integration tests and page-clamping unit test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lcomplete lcomplete merged commit 80ae479 into main Apr 28, 2026
1 check 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.

1 participant