Skip to content

Commit b9dbdc9

Browse files
Copilothotlong
andauthored
refactor: simplify expressionEvaluator user fallback; document context-fresh closure
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/9bbb4b9a-dc45-41ea-b03e-55d3172b7dde Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 38af7c3 commit b9dbdc9

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

packages/app-shell/src/console/AppContent.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
145145
// The `objectName` param falls back to the action context's
146146
// `objectName` (set per view) so action buttons mounted inside an
147147
// ObjectView can omit it.
148+
// NOTE on duplication below: each handler reads `runner.getContext()`
149+
// INSIDE its closure (at action-invocation time) rather than once at
150+
// registration. Hoisting the call outside the registrations would
151+
// freeze the context to whatever it was when the effect last ran,
152+
// breaking dynamic per-view `runner.updateContext({ objectName, ... })`
153+
// calls (used by ObjectView / RecordDetailView). Keep the call where
154+
// it is.
148155
runner.registerHandler('navigate_create', async (action: any) => {
149156
const ctx = runner.getContext?.() ?? {};
150157
const result = resolveNavigateCreateUrl({

packages/app-shell/src/views/RecordFormPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ export function RecordFormPage({ mode }: RecordFormPageProps) {
139139
const expressionEvaluator = useMemo(
140140
() =>
141141
new ExpressionEvaluator({
142-
user: user ? expressionUser : {},
142+
// expressionUser already handles the anonymous fallback, so we can
143+
// pass it through unconditionally.
144+
user: expressionUser,
143145
app: { name: appName },
144146
data: {},
145147
}),
146-
[user, expressionUser, appName],
148+
[expressionUser, appName],
147149
);
148150

149151
// Resolve the field list using the same visibility-aware logic as the

0 commit comments

Comments
 (0)