Feat: Agent Tools Improvements#171
Open
medazizktata25 wants to merge 19 commits intoGuepard-Corp:mainfrom
Open
Feat: Agent Tools Improvements#171medazizktata25 wants to merge 19 commits intoGuepard-Corp:mainfrom
medazizktata25 wants to merge 19 commits intoGuepard-Corp:mainfrom
Conversation
…igation - Added functionality to regenerate the last assistant message if the trigger is 'regenerate-message'. - Updated routing for datasource tables to include schema and table name in the URL. - Enhanced the agent UI to support opening datasources and tables in new tabs with updated navigation functions.
…opy functionality - Added functions to format and truncate error details for better readability. - Implemented a copy button to allow users to copy error details to the clipboard. - Updated the UI to conditionally display error details and the copy button based on availability.
- Refactored `useSuggestionDetection` to utilize `useLayoutEffect` for improved performance and state management. - Updated `StreamdownWithSuggestions` to preprocess suggestions for rendering, ensuring cleaner output. - Introduced new utility functions for preprocessing suggestions to avoid formatting issues. - Added comprehensive tests for suggestion detection and enhancement workflows to ensure reliability.
…onents - Added hover effects and improved styling for the DatasourceBadge component. - Introduced a readOnly prop to the DatasourceSelector for better control over user interactions. - Updated the UserMessageBubble to conditionally display datasource badges and selectors based on user interactions.
…endering - Added ToolWithTaskDelimiter component to manage task delimiters for tool parts. - Updated message rendering to utilize the new ToolWithTaskDelimiter for improved task management. - Refactored todo logic and scrolling utilities for better task handling and user experience.
…metadata retrieval - Refactored GetSchemaTool to utilize structured types for success and error results. - Improved error handling for datasource retrieval and driver instantiation. - Updated tests to ensure parallel execution and correct schema fetching behavior
…ge export to Markdown, and refactor sidebar components with new hooks and stores.
…nhance tool name generation with message part context.
…s with badges, and prevent input clearing on send.
…lUIPart` and remove unused prompt input controller.
… selection and improve web fetch visualizer tool UI
| {(isLoading && initialSuggestions?.length) || | ||
| badgeSuggestions.length > 0 ? ( | ||
| <div className="flex justify-center"> | ||
| {isLoading && !badgesFadingOut ? ( |
Check warning
Code scanning / CodeQL
Useless conditional Warning
| {(isLoading && initialSuggestions?.length) || | ||
| badgeSuggestions.length > 0 ? ( | ||
| <div className="flex justify-center"> | ||
| {isLoading && !badgesFadingOut ? ( |
Check warning
Code scanning / CodeQL
Useless conditional Warning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
All 8 commits in
feat/tools-handling-and-uiare covered below.How
Chat + transport (04fe786, b1b6e42)
apps/server/src/routes/chat.ts):body.trigger === 'regenerate-message':MessageRole.ASSISTANT).packages/agent-factory-sdk/src/services/default-transport.ts):prepareSendMessagesRequestnow:triggerfrom the request and forwards it intobodywhen present.body.messages(as before), but now with thetriggerincluded so the backend can differentiate “normal send” vs “regenerate”.Datasource routing & navigation (04fe786, b1b6e42)
apps/web/app/routes.ts):ds/:slug/tables/:idtods/:slug/tables/:schema/:tableName.apps/web/app/routes/datasource/tables.tsx:handleTableClicknow builds/ds/${slug}/tables/${encodeURIComponent(schema ?? 'main')}/${encodeURIComponent(name)}instead of usingid.apps/web/app/routes/datasource/table.tsx:schemaandtableNameparams, decodes them, and:(t.schema ?? 'main') === schema && t.name === tableName.table_id === table.id,table === table.name, and(col.schema ?? 'main') === (table.schema ?? 'main').table.nameand links back to/ds/${slug}/tables.apps/web/config/project.navigation.config.tsx):createDatasourceTableViewPath(slug, schema, tableName)buildsds/:slug/tables/:schema/:tableNamewith properencodeURIComponentand a default'main'schema when empty.apps/web/lib/utils/datasource-navigation.ts):DatasourceItemLike(id, optionalname,slug) to match UI datasource items.slugifyhelper to normalize ids/names to a safe key.resolveDatasource(items, idOrSlug, name):id, exactslug, slugifiedname/slug/id, and finally plainnamematch.openUrlInNewTab(pathOrUrl):window.location.origin, opens in a new tab withnoopener,noreferrer.openDatasourceInNewTab(items, idOrSlug, name, getPath):getPath(ds.slug)in a new tab if a slug is found.openTableInNewTab(items, datasourceIdOrSlug, datasourceName, schema, tableName, getTablePath):getTablePath(slug, schema || 'main', tableName)in a new tab.Agent UI wiring for datasource/table clicks (04fe786, b1b6e42)
apps/web/app/routes/project/_components/agent-ui-wrapper.tsx:createDatasourceTableViewPathand the navigation helpers._handleDatasourceNameClick(idOrSlug, name)delegates toopenDatasourceInNewTab._handleTableNameClick(datasourceIdOrSlug, datasourceName, schema, tableName)delegates toopenTableInNewTab.onDatasourceNameClick,onTableNameClick, andgetDatasourceTooltiptoAgentUI.packages/ui/src/qwery/ai/conversation-content.tsx:ConversationContentPropsextended with:onDatasourceNameClickonTableNameClickgetDatasourceTooltipMessageRenderer.packages/ui/src/qwery/ai/message-renderer.tsx:MessageRendererPropsextended withonTableNameClick.data-message-id={message.id}to help E2E/debugging.tool-*parts:ToolWithTaskDelimiterinstead of rawToolPart, passing:parts={message.parts},partIndex,part,messageId,executionTimeMs, and both datasource click handlers.onDatasourceNameClick,onTableNameClick, orgetDatasourceTooltipchanges, it re-renders.GetSchema tool: multi‑datasource merge + error reporting (04fe786, b1b6e42)
packages/agent-factory-sdk/src/tools/get-schema.ts):DESCRIPTIONnow clearly states it supports multiple attached datasources and returns a merged schema.No datasources attachedifattachedDatasourcesis empty.attachedDatasource:DatasourceExtensionfromExtensionsRegistry, picks a Node runtime driver if available (falls back to first driver).getDriverInstancewith the datasource config, callsmetadata(), and closes driver if it has aclose()method.{ datasourceId, datasource, datasourceDisplayName, metadata }or{ datasourceId, datasourceDisplayName, error }.schemaPrefix(datasource)helper (slugifiedname/slug/id) to build composite schema keys (e.g.Prod__public).nextTableIdandnextSchemaIdcounters to assign new ids and avoid collisions between datasources.schemas,tables, andcolumnsacross successful results into oneDatasourceMetadata.schemaErrors(withdatasourceId, optionaldatasourceName, anderrormessage) instead of failing the whole tool.packages/agent-factory-sdk/src/tools/__tests__/get-schema.parallel.test.ts):schemaErrors.Schema visualizer: merged view, pagination, errors, click‑through (04fe786, c00a83e, 65f3af0)
packages/ui/src/qwery/ai/schema-visualizer.tsx):SchemaViewMode = 'card' | 'list'.SchemaVisualizerDatasourceItem(id,name?,slug?,datasource_provider?).SchemaSchemaError(datasourceId,datasourceName?,error).SchemaVisualizerPropsextended with:datasources?: SchemaVisualizerDatasourceItem[]schemaErrors?: SchemaSchemaError[](fromGetSchemaTool)pluginLogoMap?: Map<string, string> | Record<string, string>onDatasourceNameClick?andonTableNameClick?(match Agent UI handlers).schemaNameOnly("Prod__public") → "public".datasourcePrefix("Prod__public") → "Prod".slugifyForPrefixaligns prefixes across ids, slugs, and names.groupedTables: Record<schemaKey, TableWithColumns[]>.groupsByDatasource: Record<prefix, schemaKey[]>.datasourceOrder: string[]representing the display order of datasource prefixes.pageBySchemaandviewModeBySchemain local state.SCHEMA_TABLES_PER_PAGEto limit tables per schema section and exposes page up/down usingChevronLeft/ChevronRight.getViewMode(schemaKey)andgetPage(schemaKey)give consistent behavior across rerenders.Database,Table2,ChevronDown,ChevronLeft,ChevronRight,LayoutGrid,List,AlertCircleIconfromlucide-react.variant="minimal"vs"default".schemaErrorslist with an alert style, mapping datasource ids to human names viadatasourcesandpluginLogoMap.Tool error visualization (c00a83e)
packages/ui/src/qwery/ai/tool-error-visualizer.tsx):packages/ui/src/qwery/ai/message-parts.tsx/schema-visualizer.tsx):Suggestion pipeline & Streamdown (9112924)
use-suggestion-detection:useLayoutEffectto avoid flicker and improve consistency when suggestions depend on rendered DOM.use-suggestion-enhancement:packages/ui/src/qwery/ai/utils/suggestion-pattern.ts):packages/ui/src/qwery/ai/streamdown-with-suggestions.tsx):packages/ui/src/qwery/ai/__tests__/suggestions.workflow.test.tsx):Conversation list, load‑more, and layout (84cb935)
packages/ui/src/qwery/ai/conversation-list.tsx):renderLoadMoreFooterandonLoadMoreStateChangeto give parents control over load‑more UX.visibleCountandisLoadingMore, and computeshasMore = allConversations.length > visibleCount.handleLoadMoreincrementsvisibleCountin chunks of 20 (with a short timeout to show loading state).useEffectcallsonLoadMoreStateChangewith{ hasMore, onLoadMore: handleLoadMore, isLoading: isLoadingMore }, unless searching.hasMore, and noonLoadMoreStateChangehandler:data-test="conversation-load-more").flex h-full min-h-0 flex-col.Commandismin-h-0 flex-1, andCommandListismax-h-none min-h-0 flex-1 overflow-y-autofor robust scrolling in nested layouts.apps/web/app/routes/project/conversation/index.tsx):loadMoreStatefromConversationListviaonLoadMoreStateChange.loadMoreState.hasMoreis true, with aButtonwired toloadMoreState.onLoadMore.Message rendering, task delimiter, scroll, todo logic (65f3af0, b1b6e42)
packages/ui/src/qwery/ai/task-delimiter.tsxpackages/ui/src/qwery/ai/tool-with-task-delimiter.tsxmessage.partsandpartIndexto decide how to group related tool outputs.packages/ui/src/qwery/ai/message-item.tsx,message-parts.tsx,message-renderer.tsx):ToolWithTaskDelimiterinto how tool messages are displayed.packages/ui/src/qwery/ai/utils/scroll-utils.ts:packages/ui/src/qwery/ai/virtuoso-message-list.tsx:packages/ui/__tests__/scroll-utils.test.tscovers bottom detection, backscroll, and resize behavior.packages/ui/src/qwery/ai/utils/todo-logic.ts:packages/ui/__tests__/todo-logic.test.tspackages/ui/__tests__/todo-feedback.test.tsxpackages/ui/__tests__/task-delimiter.test.tsxfor task delimiter behavior.packages/ui/src/qwery/agent-ui.tsx):CodeBlock & datasource UI polish (8918e41, c3529aa)
packages/ui/src/ai-elements/code-block.tsx,tool.tsx):preClassName: override the internal<pre>styling (e.g. backgrounds).wrap: enable soft wrapping and word breaking.scrollbarOnHover: show scrollbars on hover even whendisableHoveris true.noInternalScroll: disable internal overflow/scroll to let parents manage scrolling.preBaseClassesandpreOverflowClassescentralize the styling logic.isSQLunless overridden bypreClassName.packages/ui/src/qwery/ai/datasource-badge.tsx,datasource-selector.tsx,user-message-bubble.tsx,sql-query-visualizer.tsx,apps/web/styles/qwery.css):Layers,ExternalLink) and hover affordances for richer datasource hints.readOnlyprop to lock interactions when the datasource context shouldn’t be modified.qwery.cssto keep alignment and hover behavior consistent.Review Guide
apps/server/src/routes/chat.tspackages/agent-factory-sdk/src/services/default-transport.tsapps/web/app/routes.tsapps/web/app/routes/datasource/tables.tsxapps/web/app/routes/datasource/table.tsxapps/web/config/project.navigation.config.tsxapps/web/lib/utils/datasource-navigation.tsapps/web/app/routes/project/_components/agent-ui-wrapper.tsxpackages/ui/src/qwery/ai/conversation-content.tsxpackages/ui/src/qwery/ai/message-renderer.tsxpackages/agent-factory-sdk/src/tools/get-schema.tspackages/ui/src/qwery/ai/schema-visualizer.tsxpackages/ui/src/qwery/ai/tool-error-visualizer.tsxpackages/ui/src/qwery/ai/hooks/use-suggestion-detection.tspackages/ui/src/qwery/ai/hooks/use-suggestion-enhancement.tspackages/ui/src/qwery/ai/utils/suggestion-pattern.tspackages/ui/src/qwery/ai/streamdown-with-suggestions.tsxapps/web/app/routes/project/conversation/index.tsxpackages/ui/src/qwery/ai/conversation-list.tsxpackages/ui/src/qwery/ai/utils/scroll-utils.tspackages/ui/src/qwery/ai/virtuoso-message-list.tsxpackages/ui/src/ai-elements/code-block.tsxpackages/ui/src/qwery/ai/datasource-badge.tsxpackages/ui/src/qwery/ai/datasource-selector.tsxpackages/ui/src/qwery/ai/user-message-bubble.tsxapps/web/styles/qwery.csspackages/agent-factory-sdk/src/tools/__tests__/get-schema.parallel.test.tspackages/ui/__tests__/scroll-utils.test.tspackages/ui/__tests__/task-delimiter.test.tsxpackages/ui/__tests__/todo-feedback.test.tsxpackages/ui/__tests__/todo-logic.test.tspackages/ui/src/qwery/ai/__tests__/suggestions.workflow.test.tsxTesting
get-schema.parallel.test.tsscroll-utils.test.tstask-delimiter.test.tsxtodo-feedback.test.tsxtodo-logic.test.tssuggestions.workflow.test.tsxDocumentation
User Impact
getSchemanow supports multiple attached datasources with a merged, disambiguated schema, and clear per‑datasource error reporting in the UI.ds/:slug/tables/:idtods/:slug/tables/:schema/:tableName; any external deep links must be updated.Checklist
pnpm test)pnpm lint:fix)pnpm typecheck)