Skip to content

fix(app-shell): a full-page record form opened by direct URL returns inside the app after save or cancel - #27558

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-27454-direct-url-form-return
Oct 29, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/issue-27454-direct-url-form-return

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread

维护者速读

  • 改了什么:整页记录表单(新建 / 编辑)保存或取消后,只有当本控制台会话里确有上一页时才"后退",否则进入记录详情(编辑)或对象列表(新建)。
  • 为什么改:从粘贴链接、新标签页或深链打开表单时,原来按浏览器标签页的历史长度判断,会退出应用跳到控制台首页,保存提示也随旧页面一起丢失。
  • 风险与回滚:只改 RecordFormPage 的返回判定一处;应用内进入的行为不变。回滚即还原该文件一个提交。
  • 先看:ui/packages/app-shell/src/views/RecordFormPage.tsx 的 goBack(hasInAppHistory),然后看新测试 RecordFormPage.directUrlReturn-27454.test.tsx。
  • 两分钟验证:在新标签页直接打开 /_console/apps/com.example.showcase/showcase_task/new,填写并点 Create,应看到 Task "TITLE" created 提示并停留在任务列表(应用内)。
  • 需要你做的:无,席位落地。

Fixes #27454
Clause-②: no
Metadata-protocol: none

What changes

  • RecordFormPage's goBack decided "came from inside the app" from window.history.length > 1. That counts the tab's entries from before the console document loaded, so a form opened by pasted URL, new tab or deep link went Back out of the app, and the save toast fired just before the document unloaded.
  • It now reads react-router's own location key: the entry the router started on is keyed 'default', every entry it navigated to gets a generated key. Back only when the key is not 'default'; otherwise the existing parent route (record detail in edit mode, object list in create mode) with replace. This is the same rule FormPage's cancel already uses in the console, and the same route in-app entry takes when nothing is behind it, not a second fallback.
  • Save and cancel share goBack, so both follow the rule; edit mode (/record/ID/edit) is covered by the same change.

Tests

New RecordFormPage.directUrlReturn-27454.test.tsx, with window.history.length stubbed to 3 on every cell:

  • edit, direct URL: save toasts Task "Quarterly review" updated and lands on the record detail;
  • create, direct URL: save toasts Task "Quarterly review" created and lands on the object list;
  • edit, direct URL: cancel lands on the record detail, no toast;
  • edit and create, in-app entry (an earlier router entry): save and cancel go back to that page.

Ablation (one-shot, through scripts/ablation-replace.mjs, restored to the HEAD blob): putting the window.history.length > 1 test back turns the three direct-URL cells red and leaves the two in-app cells green, as predicted.

Acceptance notes

  • ui/packages/layout/src/PageHeader.tsx (its back button) uses the same window.history.length > 1 pattern. That is the back-button control, a different bug class from the after-save route; left unchanged here.

Verification

All readings on head 6912ecba.

Local runs
  • pnpm --dir ui exec vitest run packages/app-shell/src/views/RecordFormPage (lock VERDICT command-exit 0): Test Files 10 passed, Tests 61 passed.
  • Ablation run (lock VERDICT command-exit 1, expected): 3 failed, 2 passed; restore blob equals HEAD, git diff HEAD empty.
  • pnpm --filter @object-ui/app-shell run type-check (both the source and the test tsconfig): exit 0.
  • pnpm --dir ui check:new-line-citations: 0 new citations, exit 0.
  • dispatch-gates --commands derived 34 families; all 34 run with exit 0 recorded, --ran reconciliation: 34 run, 0 NOT-MEASURED, 0 UNRUN. That includes pnpm --dir ui exec vitest run scripts/ (169 files passed, 2 skipped).
  • Changed lines: 149 (+138 / -11) over 3 files.

Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01L6bhgXU26UBEjd1KKHgNEx

…inside the app after save or cancel

goBack decided 'has in-app history' from window.history.length, which counts
the tab's entries from before the console loaded, so a direct-URL entry went
Back out of the app and lost the save toast. Decide it from react-router's
location key instead, as FormPage's cancel does.

Claude-Session: https://claude.ai/code/session_01L6bhgXU26UBEjd1KKHgNEx
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Oct 29, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-sales · session_01L6bhgXU26UBEjd1KKHgNEx

席位核对 · ACCEPT · 2026-10-29T13:10Z

Head-sha: 6912ecbaf2e4e71f382698a4e0097eb2d89c19f1 · card #27454 · claim 6495758139 · dev report 6497038010.

  • 形态: draft → main, Fixes #27454 only, 3 files (+138/−11): RecordFormPage.tsx, its new test, one patch changeset. check-governed-merges --pr 27558: NOT governed, 149 lines ≤ 3000.
  • 前提实测: seat read of the diff against origin/main: goBack (shared by save and cancel) now keys in-app history on react-router location.key !== 'default', the rule FormPage cancel already uses, instead of window.history.length > 1; with no in-app entry it takes the existing parent route (record detail on edit, object list on create) with replace, so a direct-URL entry stays in the app and the toast is seen. recordFormNavigation.ts untouched.
  • 门禁 check-runs (pinned to head): 44 success, 11 skipped, 0 failed, 0 pending; mergeable_state: clean. Tests 5 cells; ablation restoring the history.length test turns the three direct-URL cells red, the two in-app cells stay green.
  • 接受的偏差: report line order and commit trailers per os-dev.md / AGENTS.md; the gate loop ran past the foreground cap and was waited on with every exit read.
  • 范围外去向: ui/packages/layout/src/PageHeader.tsx back button's history.length > 1 fallback → Acceptance notes, not filed (back-button class, reached only after the record-path strip, low reach). Skills-docs: not owed (Metadata-protocol: none).
  • 落地条款: ordinary queue landing; pr_ready + automerge_enable. This seat's landing op is refused by its session's permission classifier (Studio OWD panel: saving "Controlled by parent" on a detail whose master_detail is not yet required answers 409 DESTRUCTIVE_CHANGE with no way forward #27458 6497508946), so the maintainer readies and merges.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 29, 2026 19:32
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 29, 2026 19:32
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit eda55b9 Oct 29, 2026
56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-27454-direct-url-form-return branch October 29, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

console: a full-page record form opened by direct URL saves silently and then leaves the app for /_console/home

1 participant