Skip to content

Commit b2820e5

Browse files
committed
feat: Upgrade to official ObjectStack adapter and enhance connection handling
- Replace lightweight local ObjectStackDataSource with @object-ui/data-objectstack adapter. - Introduce ConnectionStatus component to display connection state in the header. - Implement MetadataInspector for shared debug panel across views. - Update App component to manage connection state and initialize data source. - Refactor views (ObjectView, DashboardView, PageView, ReportView) to utilize MetadataInspector. - Add new plugins: plugin-view, plugin-form, plugin-dashboard, plugin-report, plugin-markdown. - Clean up Chinese strings in UI for English-only compliance. - Enhance view switching with schema-driven ViewSwitcher. - Document development plan for future enhancements and fixes.
1 parent bc9485c commit b2820e5

16 files changed

+478
-289
lines changed

apps/console/DEVELOPMENT_PLAN.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# ObjectStack Console — Development Plan
2+
3+
> Generated: 2026-02-07
4+
> Status: **Active**
5+
6+
## Current State
7+
8+
The console is a working prototype that merges 3 example configs (CRM + Todo + KitchenSink) and runs in the browser via MSW mock server. It demonstrates multi-app routing, CRUD, views, dashboards, reports, and pages.
9+
10+
**Key Gaps vs ObjectStack Best Runtime:**
11+
- Lightweight local `ObjectStackDataSource` instead of official `@object-ui/data-objectstack` adapter
12+
- Custom `defineConfig()` instead of `defineStack()` from `@objectstack/spec`
13+
- Chinese UI strings violating English-only rule
14+
- Missing plugin registrations (plugin-view, plugin-form, plugin-dashboard, plugin-report, plugin-markdown)
15+
- Hardcoded view tabs instead of schema-driven `ViewSwitcher`
16+
- No runtime metadata fetching (all static config)
17+
- MSW workarounds that should be fixed upstream
18+
- Duplicated MetadataInspector code across all view components
19+
20+
---
21+
22+
## Phase 1: Data Layer Upgrade ⚡ (Critical)
23+
24+
**Goal:** Replace the lightweight local adapter with the official `@object-ui/data-objectstack` package.
25+
26+
| Task | Description | Files |
27+
|------|-------------|-------|
28+
| 1.1 | Replace `ObjectStackDataSource` with `ObjectStackAdapter` | `src/App.tsx`, `src/dataSource.ts` |
29+
| 1.2 | Add connection state monitoring UI | New: `src/components/ConnectionStatus.tsx` |
30+
| 1.3 | Server-driven metadata fetching (objects, views) | `src/App.tsx` |
31+
| 1.4 | Server-driven view resolution via `client.meta.getView()` | `src/components/ObjectView.tsx` |
32+
33+
**Estimate:** 1-2 days
34+
35+
---
36+
37+
## Phase 2: English-Only Codebase 🌐 (Quick Win)
38+
39+
**Goal:** Remove all Chinese strings per Rule #-1.
40+
41+
| Task | Description | File |
42+
|------|-------------|------|
43+
| 2.1 | Fix breadcrumb labels: 仪表盘→Dashboard, 页面→Page, 报表→Report, 记录→Record | `src/components/AppHeader.tsx` |
44+
| 2.2 | Fix search placeholder: 搜索...→Search... | `src/components/AppHeader.tsx` |
45+
46+
**Estimate:** 30 minutes
47+
48+
---
49+
50+
## Phase 3: Plugin Registration 🧩 (Quick Win)
51+
52+
**Goal:** Ensure all plugins are registered via side-effect imports in one central place.
53+
54+
| Task | Description | File |
55+
|------|-------------|------|
56+
| 3.1 | Add `import '@object-ui/plugin-view'` | `src/main.tsx` |
57+
| 3.2 | Add `import '@object-ui/plugin-form'` | `src/main.tsx` |
58+
| 3.3 | Add `import '@object-ui/plugin-dashboard'` | `src/main.tsx` |
59+
| 3.4 | Add `import '@object-ui/plugin-report'` | `src/main.tsx` |
60+
| 3.5 | Add `import '@object-ui/plugin-markdown'` | `src/main.tsx` |
61+
62+
**Estimate:** 30 minutes
63+
64+
---
65+
66+
## Phase 4: Config Alignment with `@objectstack/spec` 📜 (High)
67+
68+
**Goal:** Use standard spec factories instead of custom config helpers.
69+
70+
| Task | Description |
71+
|------|-------------|
72+
| 4.1 | Replace custom `defineConfig()` with `defineStack()` from `@objectstack/spec` |
73+
| 4.2 | Validate merged config at bootstrap using Zod schemas |
74+
| 4.3 | Remove local `src/config.ts` in favor of spec-standard patterns |
75+
76+
**Estimate:** 1 day
77+
78+
---
79+
80+
## Phase 5: MSW Runtime Fixes 🔧 (Medium)
81+
82+
| Task | Description |
83+
|------|-------------|
84+
| 5.1 | Fix PluginLoader method stripping (upstream) |
85+
| 5.2 | Remove `process.on` polyfill hack |
86+
| 5.3 | Fix discovery endpoint patching in App.tsx |
87+
| 5.4 | Delegate data seeding to AppPlugin |
88+
89+
**Estimate:** 1 day
90+
91+
---
92+
93+
## Phase 6: Schema-Driven Architecture 🎨 (Medium)
94+
95+
| Task | Description |
96+
|------|-------------|
97+
| 6.1 | Use `ViewSwitcher` component from `@object-ui/plugin-view` in ObjectView |
98+
| 6.2 | Wire up `FilterUI` and `SortUI` components in ObjectView |
99+
| 6.3 | Pass `dataSource` to DashboardRenderer |
100+
| 6.4 | Create schema-driven `CrudDialog` using Action System pattern |
101+
102+
**Estimate:** 2-3 days
103+
104+
---
105+
106+
## Phase 7: Layout System Upgrade 🏠 (Medium)
107+
108+
| Task | Description |
109+
|------|-------------|
110+
| 7.1 | Consume `ThemeSchema` tokens from spec |
111+
| 7.2 | Apply CSS custom properties from `app.branding.primaryColor` |
112+
| 7.3 | Support `header` and `empty` layout modes |
113+
| 7.4 | Improve mobile-responsive AppShell |
114+
115+
**Estimate:** 1-2 days
116+
117+
---
118+
119+
## Phase 8: Navigation & Routing 🧭 (Medium)
120+
121+
| Task | Description |
122+
|------|-------------|
123+
| 8.1 | Deep-link support with query param preservation |
124+
| 8.2 | Navigation guards with `visibleOn` expression evaluation |
125+
| 8.3 | `Cmd+K` command palette for quick navigation |
126+
127+
**Estimate:** 1 day
128+
129+
---
130+
131+
## Phase 9: Action System 🎯 (Low — Future Foundation)
132+
133+
| Task | Description |
134+
|------|-------------|
135+
| 9.1 | Implement `ActionEngine` in `@object-ui/core` |
136+
| 9.2 | Wire up button actions via `ActionSchema` |
137+
| 9.3 | Support `navigate`, `validate`, `submit` action types |
138+
139+
**Estimate:** 2-3 days
140+
141+
---
142+
143+
## Phase 10: Developer Experience 🛠️ (Ongoing)
144+
145+
| Task | Description |
146+
|------|-------------|
147+
| 10.1 | Extract shared `MetadataInspector` component |
148+
| 10.2 | Hot-reload on config changes |
149+
| 10.3 | Add React Error Boundaries per route |
150+
| 10.4 | Integration tests with Vitest + MSW |
151+
152+
**Estimate:** Ongoing
153+
154+
---
155+
156+
## Execution Order
157+
158+
```
159+
Phase 2 (i18n) → 30 min ← Quick Win
160+
Phase 3 (plugins) → 30 min ← Quick Win
161+
Phase 4 (spec config) → 1 day ← Spec Compliance
162+
Phase 1 (data layer) → 1-2 days ← Critical Foundation
163+
Phase 6 (schema-driven)→ 2-3 days ← Main Feature Work
164+
Phase 10 (DX) → 1 day ← Code Quality
165+
Phase 5 (MSW fixes) → 1 day ← Upstream
166+
Phase 7 (layout) → 1-2 days ← Polish
167+
Phase 8 (navigation) → 1 day ← Polish
168+
Phase 9 (actions) → 2-3 days ← Architecture
169+
```
170+
171+
**Total: ~2 weeks for Phases 1-8**

apps/console/objectstack.config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ const require = createRequire(import.meta.url);
55
// @ts-ignore
66
globalThis.require = require;
77

8-
import { defineConfig } from './src/config';
98
import { sharedConfig } from './objectstack.shared';
109

10+
// Server-side config extends the shared stack definition with
11+
// build/deploy/runtime settings that are outside the spec schema.
12+
// The shared config is already validated via defineStack() in objectstack.shared.ts.
13+
1114
// @ts-ignore
1215
import * as MSWPluginPkg from '@objectstack/plugin-msw';
1316
// @ts-ignore
@@ -113,7 +116,7 @@ if (process.env.ENABLE_MSW_PLUGIN === 'true') {
113116
plugins.push(new MSWPlugin());
114117
}
115118

116-
export default defineConfig({
119+
export default {
117120
...sharedConfig,
118121

119122
build: {
@@ -142,4 +145,4 @@ export default defineConfig({
142145
target: 'static',
143146
region: 'us-east-1',
144147
},
145-
});
148+
};

apps/console/objectstack.shared.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineConfig } from './src/config';
1+
import { defineStack } from '@objectstack/spec';
22
import crmConfigImport from '@object-ui/example-crm/objectstack.config';
33
import todoConfigImport from '@object-ui/example-todo/objectstack.config';
44
import kitchenSinkConfigImport from '@object-ui/example-kitchen-sink/objectstack.config';
@@ -7,14 +7,6 @@ const crmConfig = (crmConfigImport as any).default || crmConfigImport;
77
const todoConfig = (todoConfigImport as any).default || todoConfigImport;
88
const kitchenSinkConfig = (kitchenSinkConfigImport as any).default || kitchenSinkConfigImport;
99

10-
// Debug check for definition loading
11-
console.log('DEBUG: CRM Objects Count:', crmConfig.objects?.length);
12-
if (crmConfig.objects?.length) {
13-
console.log('DEBUG: CRM Objects:', crmConfig.objects.map((o: any) => o.name || o.id));
14-
} else {
15-
// console.log('DEBUG: CRM Config content:', JSON.stringify(crmConfig, null, 2));
16-
}
17-
1810
// Patch CRM App Navigation to include Report (since it was removed from CRM config for strict validation)
1911
const crmApps = crmConfig.apps ? JSON.parse(JSON.stringify(crmConfig.apps)) : [];
2012
if (crmApps.length > 0) {
@@ -127,4 +119,4 @@ export const sharedConfig = {
127119
}
128120
};
129121

130-
export default defineConfig(sharedConfig);
122+
export default defineStack(sharedConfig as any);

apps/console/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"dependencies": {
2828
"@object-ui/components": "workspace:*",
2929
"@object-ui/core": "workspace:*",
30+
"@object-ui/data-objectstack": "workspace:*",
3031
"@object-ui/example-crm": "workspace:*",
3132
"@object-ui/example-kitchen-sink": "workspace:*",
3233
"@object-ui/example-todo": "workspace:*",
@@ -42,8 +43,10 @@
4243
"@object-ui/plugin-kanban": "workspace:*",
4344
"@object-ui/plugin-list": "workspace:*",
4445
"@object-ui/plugin-map": "workspace:*",
46+
"@object-ui/plugin-markdown": "workspace:*",
4547
"@object-ui/plugin-report": "workspace:*",
4648
"@object-ui/plugin-timeline": "workspace:*",
49+
"@object-ui/plugin-view": "workspace:*",
4750
"@object-ui/react": "workspace:*",
4851
"@object-ui/types": "workspace:*",
4952
"@objectstack/client": "^1.0.11",

0 commit comments

Comments
 (0)