Repository navigation
fix: wire complete action execution chain for record detail page buttons - #995
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…m/API handlers - Wrap DetailView with ActionProvider in RecordDetailView - Add API action handler mapping logical names to dataSource operations - Add Shadcn-based ActionConfirmDialog for promise-based confirmations - Add ActionParamDialog for collecting user input before action execution - Wire toast handler to Sonner, navigate handler to React Router - Fix action-button.tsx: detect ActionParam[] and pass as actionParams - Fix action-bar.tsx: forward data prop to child renderers for visibility Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…line
The action:bar component was overriding action.type ('api') with the
component type ('action:button'), causing ActionRunner to miss the
registered 'api' handler. Now stores the original type as 'actionType'
and action-button uses it for execution.
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…idation errors, input types Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 14:51:20.360 @object-ui/layout:build: ERROR: command finished with error: command (/vercel/path0/packages/layout) /vercel/.local/share/pnpm/.tools/pnpm/10.28.2/bin/pnpm run build was killed (exit code 137), likely due to running out of memory |
The turbo pre-build step was running 30+ package builds with default concurrency and no memory limits, causing OOM (exit code 137) on Vercel. Added NODE_OPTIONS=--max-old-space-size=4096 and --concurrency=3. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
The OOM is from the turbo pre-build step running 30+ package builds with default concurrency and no memory limits — not caused by the code changes in this PR (vercel.json was unchanged). Fixed in |
|
@copilot 15:05:45.366 @object-ui/plugin-dashboard:build: �[96msrc/DashboardRenderer.tsx�[0m:�[93m203�[0m:�[93m44�[0m - �[91merror�[0m�[90m TS2339: �[0mProperty 'filter' does not exist on type '{ provider: "object"; object?: string | undefined; aggregate?: any; }'. |
The turbo step compiled all 30+ packages with tsc, hitting pre-existing TS errors in plugin-dashboard, plugin-detail, and plugin-grid. Vite already compiles all workspace packages from source via src/ aliases — turbo is unnecessary and also causes "Unknown component type" runtime errors. Also adds missing vite.config.ts aliases for @object-ui/mobile and @object-ui/plugin-designer which are imported by the console app. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
These TS errors are pre-existing in Fixed in Also added missing aliases for |
There was a problem hiding this comment.
Pull request overview
Fixes the broken record-detail action execution pipeline in the console app by restoring correct action type dispatch, wiring ActionProvider handlers (confirm/toast/navigate/param-collection + api handler), and ensuring action visibility/params collection work end-to-end. Also adjusts Vercel build + Vite workspace aliasing to reliably build the console on Vercel.
Changes:
- Preserve original action execution type (
api, etc.) while renderingaction:*components, and pass record data for visibility/enabled evaluation. - Wrap
DetailViewwith a fully wiredActionProvider, add confirm + param collection dialogs, and implement anapihandler backed bydataSource.update(). - Add console integration tests for confirm/params/toast/update behavior; update Vercel build command and Vite aliases.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/src/renderers/action/action-button.tsx | Uses preserved actionType, routes params vs actionParams, and evaluates visibility/enabled using record data. |
| packages/components/src/renderers/action/action-bar.tsx | Preserves original action type (actionType) while overriding component renderer type; forwards record data to inline action renderers. |
| apps/console/src/components/RecordDetailView.tsx | Adds ActionProvider wiring, confirm/toast/navigate/param handlers, and an api handler that maps action targets to dataSource.update(). |
| apps/console/src/components/ActionParamDialog.tsx | New dialog to collect action params based on ActionParamDef[]. |
| apps/console/src/components/ActionConfirmDialog.tsx | New promise-based confirm dialog using Shadcn AlertDialog. |
| apps/console/src/tests/RecordDetailActions.test.tsx | New integration tests covering rendering + confirm/params/toast + dataSource.update() invocation. |
| apps/console/vite.config.ts | Adds missing workspace aliases for @object-ui/mobile and @object-ui/plugin-designer. |
| apps/console/vercel.json | Switches Vercel build to a Vite-only build path (no turbo prebuild), with MSW init + env flags. |
| ROADMAP.md | Documents the root causes and the implemented fixes for the record detail action chain. |
| schema={{ | ||
| ...action, | ||
| type: componentType, | ||
| actionType: action.type, | ||
| variant: action.variant || schema.variant, | ||
| size: action.size || schema.size, | ||
| }} | ||
| data={rest.data} | ||
| /> |
There was a problem hiding this comment.
ActionBarRenderer now preserves the original action type via actionType, but only action:button appears to consume it. If an action uses a different component (e.g. action:icon), that renderer still executes using schema.type (which action:bar overwrites to the component type), so those actions would remain inert. Also, record data is passed to inline renderers but not to the overflow action:menu, so visibility/enabled expressions in overflow items will still evaluate without record context. Consider standardizing on actionType across all action renderers and forwarding data consistently (including overflow).
| }, [navigate]); | ||
|
|
||
| // API action handler — maps logical action targets to dataSource operations | ||
| const apiHandler = useCallback(async (action: ActionDef, _context: ActionCtx) => { |
There was a problem hiding this comment.
apiHandler declares a _context: ActionCtx parameter but doesn’t use it. With noUnusedParameters: true in apps/console/tsconfig.json, this will fail type-checking. Either remove the second parameter (a 1-arg function is assignable here) or use it (e.g., for record/user context).
| const apiHandler = useCallback(async (action: ActionDef, _context: ActionCtx) => { | |
| const apiHandler = useCallback(async (action: ActionDef) => { |
| setActionRefreshKey(k => k + 1); | ||
| return { success: true, reload: true }; |
There was a problem hiding this comment.
The handler always increments actionRefreshKey and returns { reload: true } even when the action doesn’t request a refresh. This ignores action.refreshAfter and may cause unnecessary DetailView remounts/state loss for actions that shouldn’t refresh the record. Consider only triggering the refresh (and setting reload) when action.refreshAfter is true (or when the handler actually mutated record data).
| setActionRefreshKey(k => k + 1); | |
| return { success: true, reload: true }; | |
| const shouldRefresh = action.refreshAfter === true; | |
| if (shouldRefresh) { | |
| setActionRefreshKey(k => k + 1); | |
| } | |
| return { success: true, reload: shouldRefresh }; |
| const handleSubmit = () => { | ||
| // Validate required fields | ||
| const newErrors: Record<string, boolean> = {}; | ||
| for (const param of state.params) { | ||
| if (param.required && !values[param.name]) { | ||
| newErrors[param.name] = true; |
There was a problem hiding this comment.
Required-field validation uses !values[param.name], which treats valid falsy values (e.g. 0 for number, false for boolean) as missing and will incorrectly block submission. Consider checking specifically for undefined/null/empty-string instead (and handling arrays/objects appropriately if those types are supported).
| const handleSubmit = () => { | |
| // Validate required fields | |
| const newErrors: Record<string, boolean> = {}; | |
| for (const param of state.params) { | |
| if (param.required && !values[param.name]) { | |
| newErrors[param.name] = true; | |
| const isMissingValue = (value: unknown): boolean => { | |
| if (value === undefined || value === null) { | |
| return true; | |
| } | |
| if (typeof value === 'string') { | |
| return value.trim() === ''; | |
| } | |
| if (Array.isArray(value)) { | |
| return value.length === 0; | |
| } | |
| return false; | |
| }; | |
| const handleSubmit = () => { | |
| // Validate required fields | |
| const newErrors: Record<string, boolean> = {}; | |
| for (const param of state.params) { | |
| if (param.required) { | |
| const value = values[param.name]; | |
| if (isMissingValue(value)) { | |
| newErrors[param.name] = true; | |
| } |
| {param.type === 'select' && param.options ? ( | ||
| <Select | ||
| value={values[param.name] || ''} | ||
| onValueChange={(val) => updateValue(param.name, val)} | ||
| > | ||
| <SelectTrigger id={param.name} className={errors[param.name] ? 'border-destructive' : ''}> | ||
| <SelectValue placeholder={param.placeholder || `Select ${param.label}`} /> | ||
| </SelectTrigger> | ||
| <SelectContent> | ||
| {param.options.map((opt) => ( | ||
| <SelectItem key={opt.value} value={opt.value}> | ||
| {opt.label} | ||
| </SelectItem> | ||
| ))} | ||
| </SelectContent> | ||
| </Select> | ||
| ) : param.type === 'textarea' ? ( | ||
| <Textarea | ||
| id={param.name} | ||
| value={values[param.name] || ''} | ||
| onChange={(e) => updateValue(param.name, e.target.value)} | ||
| placeholder={param.placeholder} | ||
| className={errors[param.name] ? 'border-destructive' : ''} | ||
| /> | ||
| ) : ( | ||
| <Input | ||
| id={param.name} | ||
| type={(['number', 'email', 'url', 'date', 'datetime-local', 'time', 'password'] as string[]).includes(param.type) ? param.type : 'text'} | ||
| value={values[param.name] || ''} | ||
| onChange={(e) => updateValue(param.name, e.target.value)} | ||
| placeholder={param.placeholder} | ||
| className={errors[param.name] ? 'border-destructive' : ''} | ||
| /> |
There was a problem hiding this comment.
Several inputs use values[param.name] || '', which will coerce valid values like 0 to an empty string and lose data. Also, number inputs currently store e.target.value (string) rather than a number, and boolean params fall back to a text input (returning a string). Consider using nullish coalescing (??) for display, and normalizing value types per param.type (e.g., valueAsNumber for number, Checkbox/Switch for boolean).
| */ | ||
|
|
||
| import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
| import { render, screen, waitFor, within } from '@testing-library/react'; |
There was a problem hiding this comment.
within is imported but never used. With noUnusedLocals: true in the console tsconfig, this will fail type-checking for the test file. Remove the unused import (or use it).
| import { render, screen, waitFor, within } from '@testing-library/react'; | |
| import { render, screen, waitFor } from '@testing-library/react'; |
| // dataSource.update should NOT be called | ||
| // (wait a tick to ensure no async calls happen) | ||
| await new Promise(r => setTimeout(r, 100)); | ||
| expect(ds.update).not.toHaveBeenCalledWith('opportunity', 'opp-1', expect.anything()); |
There was a problem hiding this comment.
This assertion only checks that update wasn’t called with a specific argument shape; the test could still pass even if ds.update was called with different args. If the intent is “no update happens on cancel”, assert expect(ds.update).not.toHaveBeenCalled() (or check call count) to avoid false positives.
| expect(ds.update).not.toHaveBeenCalledWith('opportunity', 'opp-1', expect.anything()); | |
| expect(ds.update).not.toHaveBeenCalled(); |
| variant: action.variant || schema.variant, | ||
| size: action.size || schema.size, | ||
| }} | ||
| data={rest.data} | ||
| /> |
There was a problem hiding this comment.
Since DetailView renders <SchemaRenderer schema={actionBar} data={record} />, action:bar receives a data prop and then spreads ...rest onto the toolbar <div>. That forwards an object-valued data prop to the DOM and can trigger React unknown-prop warnings. Consider destructuring data out of props/rest before spreading onto the <div> (and then explicitly passing it only to child renderers).
| // Record data may be passed from SchemaRenderer (e.g. DetailView passes record data) | ||
| const recordData = rest.data != null && typeof rest.data === 'object' ? rest.data as Record<string, any> : {}; | ||
|
|
||
| // Evaluate visibility and enabled conditions with record data context | ||
| const isVisible = useCondition(schema.visible ? `\${${schema.visible}}` : undefined, recordData); | ||
| const isEnabled = useCondition(schema.enabled ? `\${${schema.enabled}}` : undefined, recordData); |
There was a problem hiding this comment.
data is being read from rest.data but ...rest is still spread onto the underlying Shadcn <Button/>, which forwards props to the DOM. Passing an object-valued data prop to a <button> will cause React unknown-prop warnings and may serialize incorrectly. Consider destructuring data out of props/rest (e.g. const { data, ...rest } = props) so it’s used for condition evaluation but never forwarded to the DOM element.
| // Detect if schema.params are ActionParam definitions (array of {name,type,...}) | ||
| // vs actual param values (Record<string, any>) | ||
| const isParamDefs = Array.isArray(schema.params) && schema.params.length > 0 && | ||
| typeof schema.params[0] === 'object' && 'name' in schema.params[0] && 'type' in schema.params[0]; | ||
|
|
||
| await execute({ | ||
| type: schema.type, | ||
| type: schema.actionType || schema.type, | ||
| name: schema.name, | ||
| target: schema.target, | ||
| execute: schema.execute, | ||
| endpoint: schema.endpoint, | ||
| method: schema.method, | ||
| params: schema.params as Record<string, any> | undefined, | ||
| ...(isParamDefs | ||
| ? { actionParams: schema.params as any } | ||
| : { params: schema.params as Record<string, any> | undefined }), |
There was a problem hiding this comment.
The isParamDefs check treats schema.params as value params unless it’s a non-empty array. But per ActionSchema, params is an array of param definitions and may be []; in that case this code will pass an array into ActionDef.params (expected Record<string, any>), which can leak through to handlers / API bodies. Consider switching to Array.isArray(schema.params) ? { actionParams: schema.params } : { params: schema.params } and typing actionParams as ActionParamDef[] instead of any.
|
@copilot fix all |
- RecordDetailView: remove unused _context param, respect action.refreshAfter - ActionParamDialog: use isMissingValue() for falsy-safe validation, use ?? instead of ||, handle number type with valueAsNumber - RecordDetailActions.test: remove unused 'within' import, use not.toHaveBeenCalled() - action-bar: destructure data from rest to prevent DOM prop warnings - action-button: destructure data from rest, simplify params routing with Array.isArray Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
All 10 review items fixed in
All 764 console tests pass, 12 action-bar tests pass, CodeQL: 0 alerts. |
|
@copilot 更新最新代码修正合并冲突 |
Combined action provider handlers (this PR) with child relation discovery, highlight fields, section groups (from main). Kept main's workspaceAliases variable in vite.config.ts. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Merged latest main and resolved conflicts in
All 768 console tests pass, 12 action-bar tests pass, Vite production build succeeds, CodeQL: 0 alerts. |
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
RecordDetailView.tsx— Wrap DetailView withActionProvider, wire up toast/confirm/navigate/param-collection/api handlersaction-button.tsx— Fix params mapping (ActionParam[] → actionParams), use typedactionTypefor correct action type, null-safe data check, pass record data touseConditionaction-bar.tsx— Forwarddataprop for visibility + preserve originalactionTypethrough schemaaction.type('api') with component type ('action:button'), so ActionRunner never matched the registered 'api' handlerActionParamDialog.tsx— Param collection dialog with validation error display, proper HTML5 input typesActionConfirmDialog.tsx— Confirm dialog using Shadcn AlertDialogOriginal prompt
This section details on the original issue you should resolve
<issue_title>[Bug] 详情页所有 Action 按钮点击无响应 — ActionProvider / 参数弹窗 / API handler / Toast / Confirm 全链路缺失</issue_title>
<issue_description>
问题描述
在记录详情页面(如 Opportunity #107),头部所有 Action 按钮(Change Stage、Mark as Won 等)点击后完全无反应 — 无弹窗、无确认、无 Toast、无 API 调用。
根因分析
Action 执行链路有 5 个环节断裂,导致按钮虽然渲染出来,但点击后执行静默失败:
ActionProviderapps/console/src/components/RecordDetailView.tsxuseAction()回退到空的本地ActionRunner,没有注册任何 handlerapiaction 的target是逻辑名称,不是 URLexamples/crm/src/actions/opportunity.actions.tsActionRunner.executeAPI()对'opportunity_change_stage'执行fetch(),直接报错但被静默 catchonParamCollectionhandlerpackages/core/src/actions/ActionRunner.tsL289-295new_stage参数,但参数收集步骤被跳过onConfirmhandlerpackages/core/src/actions/ActionRunner.tsL194confirmText回退到window.confirm,可能被浏览器抑制onToasthandlerpackages/core/src/actions/ActionRunner.tsL188successMessage/errorMessage)被静默丢弃,用户零反馈调用链路详解
涉及的 Action 定义
现有代码上下文
App.tsx 已有
useActionRunner的使用模式(仅用于 CRUD dialog),可作为参考:但 RecordDetailView 没有类似的 handler 注册逻辑,也没有被
ActionProvider包裹。开发任务清单
任务 1:在 RecordDetailView 中引入 ActionProvider
文件:
apps/console/src/components/RecordDetailView.tsx<ActionProvider>包裹<DetailView>及其子组件context:包含当前 record 数据、objectName、user 信息updateContext)任务 2:实现自定义 API Action Handler
新增文件:
apps/console/src/hooks/useRecordActions.ts(或扩展现有useObjectActions.ts)api类型的 handler,拦截所有type: 'api'的 actionaction.target(逻辑名称)映射到dataSource操作:opportunity_change_stage→dataSource.update(objectName, recordId, { stage: params.new_stage })opportunity_mark_won→dataSource.update(objectName, recordId, { stage: 'closed_won' })opportunity_mark_lost→dataSource.update(objectName, recordId, { stage: 'closed_lost', loss_reason: params.loss_reason })dataSource.update(objectName, recordId, params)作为默认行为{ success: true, reload: true }以触发页面刷新任务 3:实现参数收集弹窗(onParamCollection)
新增文件:
apps/console/src/components/ActionParamDialog.tsxActionParamDef[]动态渲染 Shadcn 表单字段:type: 'select'→<Select>组件,options 来自 param.optionstype: 'text'→<Input>组件type: 'textarea'→<Textarea>组件required验证Record<string, any>,取消返回nullDialog或AlertDialog任务 4:实现确认弹窗(onConfirm)
新增文件:
apps/console/src/components/ActionConfirmDialog.tsx(或复用已有 AlertDialog)window.confirmconfirmText内容confirm对象(title、message、confirmText、cancelText)Promise<boolean>任务 5:接入 Toast Handler
文件:
apps/console/src/components/RecordDetailView.tsx🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.