Skip to content

Commit 3b84755

Browse files
Fix plugin order: SetupPlugin must load before AuthPlugin
AuthPlugin's init() method tries to contribute menu items to the setupNav service, which is only registered after SetupPlugin's init() runs. The previous order had AuthPlugin loading first, causing it to silently fail when trying to contribute navigation items. Correct order: 1. SetupPlugin (registers setupNav service in init phase) 2. AuthPlugin (contributes to setupNav in init phase) This ensures the Setup App menu is populated with auth-related items: - Users - Organizations - Teams - API Keys - Sessions Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/07edc3ef-a3a9-4926-bd1a-db0c2513b862 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent f6fe8a0 commit 3b84755

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

apps/console/objectstack.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,22 @@ class MemoryI18nPlugin {
7777
* MemoryI18nPlugin MUST come before AppPlugin so that the i18n service
7878
* exists when AppPlugin.start() → loadTranslations() runs.
7979
*
80-
* AuthPlugin before SetupPlugin: both use namespace 'sys', and the
81-
* ObjectQL registry requires the package that owns objects (AuthPlugin →
82-
* com.objectstack.system) to register first.
80+
* SetupPlugin MUST load before AuthPlugin so that the setupNav service
81+
* is registered and available when AuthPlugin.init() tries to contribute menu items.
8382
*/
8483
const plugins: any[] = [
8584
new MemoryI18nPlugin(),
8685
new ObjectQLPlugin(),
8786
new DriverPlugin(new InMemoryDriver(), 'memory'),
8887
// Each example stack loaded as an independent AppPlugin
8988
...appConfigs.map((config: any) => new AppPlugin(config)),
90-
// Auth & Setup plugins (replaces setupAppConfig)
89+
// SetupPlugin must come before AuthPlugin (setupNav service dependency)
90+
new SetupPlugin(),
91+
// AuthPlugin contributes to setupNav during init, so it must come AFTER SetupPlugin
9192
new AuthPlugin({
9293
secret: process.env.AUTH_SECRET || 'objectui-server-secret',
9394
baseUrl: process.env.BASE_URL || 'http://localhost:3000',
9495
}),
95-
new SetupPlugin(),
9696
new HonoServerPlugin({ port: 3000 }),
9797
new ConsolePlugin(),
9898
];

apps/console/src/mocks/createKernel.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,14 @@ export async function createKernel(options: KernelOptions): Promise<KernelResult
318318
for (const config of configs) {
319319
await kernel.use(new AppPlugin(config));
320320
}
321-
// AuthPlugin before SetupPlugin: both use namespace 'sys', and the
322-
// ObjectQL registry requires the package that owns objects (AuthPlugin →
323-
// com.objectstack.system) to register first.
321+
// SetupPlugin MUST load before AuthPlugin so that the setupNav service
322+
// is registered and available when AuthPlugin.init() tries to contribute menu items.
323+
await kernel.use(new SetupPlugin() as unknown as Plugin);
324+
// AuthPlugin contributes to setupNav during init, so it must come AFTER SetupPlugin.
324325
await kernel.use(new AuthPlugin({
325326
secret: 'objectui-demo-secret',
326327
baseUrl: 'http://localhost:5173', // Vite dev server default
327328
}) as unknown as Plugin);
328-
// SetupPlugin registers setupNav during init and the merged Setup app
329-
// during start. Must come after AuthPlugin to avoid sys namespace collision.
330-
await kernel.use(new SetupPlugin() as unknown as Plugin);
331329

332330
// Register MemoryAnalyticsService so that HttpDispatcher can serve
333331
// /api/v1/analytics/* endpoints in demo/MSW/dev environments.

objectstack.config.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ export default {
6464
new AppPlugin(prepareConfig(crmConfig)),
6565
new AppPlugin(prepareConfig(todoConfig)),
6666
new AppPlugin(prepareConfig(kitchenSinkConfig)),
67-
// AuthPlugin before SetupPlugin: both use namespace 'sys', and the
68-
// ObjectQL registry requires the package that owns objects (AuthPlugin →
69-
// com.objectstack.system) to register first.
67+
// SetupPlugin MUST load before AuthPlugin so that the setupNav service
68+
// is registered and available when AuthPlugin.init() tries to contribute menu items.
69+
new SetupPlugin(),
70+
// AuthPlugin contributes to setupNav during init, so it must come AFTER SetupPlugin.
7071
new AuthPlugin({
7172
secret: process.env.AUTH_SECRET || 'objectui-dev-secret',
7273
baseUrl: 'http://localhost:3000',
7374
}),
74-
// SetupPlugin registers setupNav during init and the merged Setup app
75-
// during start. Must come after AuthPlugin to avoid sys namespace collision.
76-
new SetupPlugin(),
7775
new HonoServerPlugin({ port: 3000 }),
7876
new ConsolePlugin(),
7977
],

0 commit comments

Comments
 (0)