Skip to content

Commit fee1558

Browse files
authored
Merge pull request #330 from objectstack-ai/copilot/fix-action-run-step-error
2 parents 5b8433c + 974a6ee commit fee1558

17 files changed

Lines changed: 146 additions & 61 deletions

File tree

apps/console/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default defineConfig({
5353
test: {
5454
globals: true,
5555
environment: 'happy-dom',
56-
setupFiles: ['./vitest.setup.tsx'],
56+
setupFiles: ['../../vitest.setup.tsx'],
5757
server: {
5858
deps: {
5959
inline: [/@objectstack/]

packages/components/vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ export default defineConfig({
2222
resolve: {
2323
alias: {
2424
'@': resolve(__dirname, './src'),
25+
'@object-ui/core': resolve(__dirname, '../core/src'),
26+
'@object-ui/types': resolve(__dirname, '../types/src'),
27+
'@object-ui/react': resolve(__dirname, '../react/src'),
28+
'@object-ui/components': resolve(__dirname, './src'), // Self-reference for vitest.setup.tsx
29+
'@object-ui/fields': resolve(__dirname, '../fields/src'),
30+
'@object-ui/plugin-dashboard': resolve(__dirname, '../plugin-dashboard/src'),
31+
'@object-ui/plugin-grid': resolve(__dirname, '../plugin-grid/src'),
2532
},
2633
},
2734
build: {
@@ -45,7 +52,7 @@ export default defineConfig({
4552
test: {
4653
globals: true,
4754
environment: 'happy-dom',
48-
setupFiles: ['../../vitest.setup.ts'],
55+
setupFiles: ['../../vitest.setup.tsx'],
4956
passWithNoTests: true,
5057
// Ensure dependencies are resolved properly for tests
5158
deps: {

packages/fields/src/standard-widgets.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ describe('Standard Field Widgets', () => {
130130
/>
131131
);
132132
// getByRole('textbox') doesn't work for password type usually
133-
// eslint-disable-next-line testing-library/no-node-access
134133
const input = screen.getByDisplayValue('secret');
135134
expect(input).toHaveAttribute('type', 'password');
136135
});

packages/fields/src/widgets/BooleanField.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import React from 'react';
1+
import React, { useId } from 'react';
22
import { Switch, Checkbox, Label } from '@object-ui/components';
33
import { FieldWidgetProps } from './types';
44

55
export function BooleanField({ value, onChange, field, readonly, ...props }: FieldWidgetProps<boolean>) {
6-
if (readonly) {
7-
return <span className="text-sm">{value ? 'Yes' : 'No'}</span>;
8-
}
9-
106
const config = (field || (props as any).schema) as any;
117
// Use simple type assertion for arbitrary custom properties not in BaseFieldMetadata
128
const widget = config?.widget;
13-
const id = config?.name || `boolean-field-${Math.random().toString(36).substr(2, 9)}`;
9+
// Generate unique ID using React's useId hook - must be before early returns (rules of hooks)
10+
const generatedId = useId();
11+
const id = config?.name || generatedId;
1412
const label = config?.label || 'Checkbox';
1513

14+
if (readonly) {
15+
return <span className="text-sm">{value ? 'Yes' : 'No'}</span>;
16+
}
17+
1618
if (widget === 'checkbox') {
1719
return (
1820
<div className="flex items-center space-x-2">

packages/fields/src/widgets/ObjectField.tsx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,38 @@ import { FieldWidgetProps } from './types';
88
*/
99
export function ObjectField({ value, onChange, field, readonly, ...props }: FieldWidgetProps<any>) {
1010
const config = field || (props as any).schema;
11-
const [jsonString, setJsonString] = useState('');
11+
12+
// Initialize string state based on value
13+
const getInitialJsonString = () => {
14+
if (value === undefined || value === null) return '';
15+
return JSON.stringify(value, null, 2);
16+
};
17+
18+
const [jsonString, setJsonString] = useState(getInitialJsonString);
1219
const [error, setError] = useState<string | null>(null);
1320

14-
// Initialize/Sync internal string state when value changes externally
21+
// Sync internal string state when value changes externally
22+
// This is a controlled component pattern where we need to sync external changes
1523
useEffect(() => {
1624
try {
17-
if (value === undefined || value === null) {
18-
setJsonString('');
19-
return;
20-
}
21-
// Only update if the parsed internal state doesn't match the new value
22-
// This prevents cursor jumping/reformatting while typing valid JSON
23-
const currentParsed = jsonString ? JSON.parse(jsonString) : null;
24-
if (JSON.stringify(currentParsed) !== JSON.stringify(value)) {
25-
setJsonString(JSON.stringify(value, null, 2));
26-
}
27-
} catch (e) {
28-
// Fallback if internal state was invalid JSON
25+
if (value === undefined || value === null) {
26+
// eslint-disable-next-line react-hooks/set-state-in-effect -- Required for controlled component sync
27+
setJsonString('');
28+
return;
29+
}
30+
// Only update if the parsed internal state doesn't match the new value
31+
// This prevents cursor jumping/reformatting while typing valid JSON
32+
const currentParsed = jsonString ? JSON.parse(jsonString) : null;
33+
if (JSON.stringify(currentParsed) !== JSON.stringify(value)) {
34+
// eslint-disable-next-line react-hooks/set-state-in-effect -- Required for controlled component sync
2935
setJsonString(JSON.stringify(value, null, 2));
36+
}
37+
} catch {
38+
// Fallback if internal state was invalid JSON
39+
// eslint-disable-next-line react-hooks/set-state-in-effect -- Required for controlled component sync
40+
setJsonString(JSON.stringify(value, null, 2));
3041
}
31-
}, [value]);
42+
}, [value, jsonString]);
3243

3344
if (readonly) {
3445
if (!value) return <span className="text-sm">-</span>;

packages/fields/vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ export default defineConfig({
1313
resolve: {
1414
alias: {
1515
'@': path.resolve(__dirname, './src'),
16+
'@object-ui/core': path.resolve(__dirname, '../core/src'),
17+
'@object-ui/types': path.resolve(__dirname, '../types/src'),
18+
'@object-ui/react': path.resolve(__dirname, '../react/src'),
19+
'@object-ui/components': path.resolve(__dirname, '../components/src'),
20+
'@object-ui/fields': path.resolve(__dirname, './src'), // Self-reference for vitest.setup.tsx
21+
'@object-ui/plugin-dashboard': path.resolve(__dirname, '../plugin-dashboard/src'),
22+
'@object-ui/plugin-grid': path.resolve(__dirname, '../plugin-grid/src'),
1623
},
1724
},
1825
build: {
@@ -44,7 +51,7 @@ export default defineConfig({
4451
test: {
4552
globals: true,
4653
environment: 'jsdom',
47-
setupFiles: ['../../vitest.setup.ts'],
54+
setupFiles: ['../../vitest.setup.tsx'],
4855
passWithNoTests: true,
4956
},
5057
});

packages/plugin-aggrid/vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export default defineConfig({
2424
resolve: {
2525
alias: {
2626
'@': resolve(__dirname, './src'),
27+
'@object-ui/core': resolve(__dirname, '../core/src'),
28+
'@object-ui/types': resolve(__dirname, '../types/src'),
29+
'@object-ui/react': resolve(__dirname, '../react/src'),
30+
'@object-ui/components': resolve(__dirname, '../components/src'),
31+
'@object-ui/fields': resolve(__dirname, '../fields/src'),
32+
'@object-ui/plugin-dashboard': resolve(__dirname, '../plugin-dashboard/src'),
33+
'@object-ui/plugin-grid': resolve(__dirname, '../plugin-grid/src'),
2734
},
2835
},
2936
build: {
@@ -50,7 +57,7 @@ export default defineConfig({
5057
test: {
5158
globals: true,
5259
environment: 'happy-dom',
53-
setupFiles: ['../../vitest.setup.ts'],
60+
setupFiles: ['../../vitest.setup.tsx'],
5461
passWithNoTests: true,
5562
},
5663
});

packages/plugin-charts/vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export default defineConfig({
2424
resolve: {
2525
alias: {
2626
'@': resolve(__dirname, './src'),
27+
'@object-ui/core': resolve(__dirname, '../core/src'),
28+
'@object-ui/types': resolve(__dirname, '../types/src'),
29+
'@object-ui/react': resolve(__dirname, '../react/src'),
30+
'@object-ui/components': resolve(__dirname, '../components/src'),
31+
'@object-ui/fields': resolve(__dirname, '../fields/src'),
32+
'@object-ui/plugin-dashboard': resolve(__dirname, '../plugin-dashboard/src'),
33+
'@object-ui/plugin-grid': resolve(__dirname, '../plugin-grid/src'),
2734
},
2835
},
2936
build: {
@@ -48,7 +55,7 @@ export default defineConfig({
4855
test: {
4956
globals: true,
5057
environment: 'happy-dom',
51-
setupFiles: ['../../vitest.setup.ts'],
58+
setupFiles: ['../../vitest.setup.tsx'],
5259
passWithNoTests: true,
5360
},
5461
});

packages/plugin-editor/vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ export default defineConfig({
2222
resolve: {
2323
alias: {
2424
'@': resolve(__dirname, './src'),
25+
'@object-ui/core': resolve(__dirname, '../core/src'),
26+
'@object-ui/types': resolve(__dirname, '../types/src'),
27+
'@object-ui/react': resolve(__dirname, '../react/src'),
28+
'@object-ui/components': resolve(__dirname, '../components/src'),
29+
'@object-ui/fields': resolve(__dirname, '../fields/src'),
30+
'@object-ui/plugin-dashboard': resolve(__dirname, '../plugin-dashboard/src'),
31+
'@object-ui/plugin-grid': resolve(__dirname, '../plugin-grid/src'),
2532
},
2633
},
2734
build: {
@@ -46,7 +53,7 @@ export default defineConfig({
4653
test: {
4754
globals: true,
4855
environment: 'happy-dom',
49-
setupFiles: ['../../vitest.setup.ts'],
56+
setupFiles: ['../../vitest.setup.tsx'],
5057
passWithNoTests: true,
5158
},
5259
});

packages/plugin-form/vite.config.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@ export default defineConfig({
1313
],
1414
resolve: {
1515
alias: {
16-
'@object-ui/core': resolve(__dirname, '../core/src/index.ts'),
17-
'@object-ui/types': resolve(__dirname, '../types/src/index.ts'),
18-
'@object-ui/data-objectstack': resolve(__dirname, '../data-objectstack/src/index.ts'),
16+
'@object-ui/core': resolve(__dirname, '../core/src'),
17+
'@object-ui/types': resolve(__dirname, '../types/src'),
18+
'@object-ui/data-objectstack': resolve(__dirname, '../data-objectstack/src'),
19+
'@object-ui/react': resolve(__dirname, '../react/src'),
20+
'@object-ui/components': resolve(__dirname, '../components/src'),
21+
'@object-ui/fields': resolve(__dirname, '../fields/src'),
22+
'@object-ui/plugin-dashboard': resolve(__dirname, '../plugin-dashboard/src'),
23+
'@object-ui/plugin-grid': resolve(__dirname, '../plugin-grid/src'),
1924
}
2025
},
2126
build: {
@@ -46,7 +51,7 @@ export default defineConfig({
4651
test: {
4752
globals: true,
4853
environment: 'happy-dom',
49-
setupFiles: ['../../vitest.setup.ts'],
54+
setupFiles: ['../../vitest.setup.tsx'],
5055
passWithNoTests: true,
5156
},
5257
});

0 commit comments

Comments
 (0)