Repository navigation
feat(console): 「Edit app」 turns on a design mode in the running app (#36362) - #36397
Conversation
…6362) The shell holds the app's design mode: a bar with Design mode, Cancel and Save across the top, kept from page to page of the app, with an extension point surfaces stage their changes through. Claude-Session: https://claude.ai/code/session_01QsR2jSr8sNCnJrK6Q9kEF5 Co-authored-by: Claude <noreply@anthropic.com>
The design mode draws its bar in the same AppShell slot as AppHeader and keeps the sidebar below it on desktop; the source pins follow. Claude-Session: https://claude.ai/code/session_01QsR2jSr8sNCnJrK6Q9kEF5 Co-authored-by: Claude <noreply@anthropic.com>
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jSpi3g1dQNTvN6zEuH 席位核对L1 (L1-e) on head Checklist
Spot checks
Deviations / owed before ready
|
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC Contract reviewServed-tier: ① Derived judgmentsRead: card #36362 (body + all 4 comments: notice, claim, triage, os-dev-report), PR #36397 body and its 23-file list, the net diff
② Semver level
③ Boundary flags
Implemented-by: VERDICT: PASS |
|
repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC Landing (seat 7, 2026-11-22T10:23Z): head |
…lters a card does not follow (objectstack-ai#36405) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCxiFE11rsKwyNffJZKYqJs)_ repo:objectstack#7 · zhuangjianguo · session_01QsR2jUeSU9HhKxjcVsyprx Fixes objectstack-ai#36372 Clause-②: yes (widening) — one new exported core function (`dashboardFiltersNotApplied`), two new optional `DashboardRenderer` props (`onWidgetResize`, `onAddFilter`), and new `@object-ui/i18n` keys (`dashboard.inPageEdit.*`, `dashboard.filters.notApplied`, `dashboard.filters.addFilter`); nothing removed or renamed Metadata-protocol: none ## 维护者速读 - 是什么:系统管理员在仪表盘页面上点「编辑」就能直接改:拖动和拉伸卡片、点卡片在右侧改属性、添加和删除卡片、添加和修改顶部筛选、设置每张卡片是否跟随页面筛选。「保存」后所有人立刻看到,不需要发布应用包;「放弃」丢掉全部改动。 - 为什么:以前改仪表盘必须进入工作室,管理员在看数据时发现问题要绕一大圈;现在在哪里看就在哪里改。 - 对已安装的应用:改动写进该应用的定制层(和工作室的「定制」写同一处),升级应用不会覆盖。点「编辑」本身什么都不写,定制层在第一次「保存」时才创建,所以「编辑」后「放弃」不留下任何东西。工作室不让定制的情况(本部署只有平台运营方能定制已安装应用、软件包列表没给出版本),页面也不进入编辑,并说明原因;如果工作室里已有这张仪表盘未发布的草稿,页面会提示先去工作室处理,不会替别人发布。 - 另外:每张卡片都会显示一个小标记,写明它不跟随哪些页面筛选(例如「不跟随『区域』筛选」),标记和卡片实际查到的数据用的是同一条判断,不会对不上。 ## What changes **Edit state on the dashboard page** (`DashboardView` + new `DashboardInPageEditor.tsx`). A workspace admin who may author metadata, on a package Studio lists (`useStudioEntryGate`, the gate of the app → Studio entries; writable or read-only, never a kernel package), gets an **Edit** button in the page header (from `sm` up: the edit state needs its side panel). Edit opens the dashboard **as stored** — the layered read's `effective` in the package a save would land in (a customization pair that is not listed yet, or does not hold it yet, opens its base's) — never the served, translated copy. **Opening writes nothing**: it reads the package list and the item only. In the edit state: - the header shows an **Editing** badge, the hint "Saved changes apply to everyone at once", and **Add card**, **Discard**, **Save** (Save is off until something changes); - every card draws dashed and is in the renderer's design mode: drag to move (the existing dnd-kit reorder), click to select, and a new corner handle resizes it by whole grid tracks; - the right panel is Studio's own dashboard panels, unchanged: `DashboardWidgetInspector` for a selected card (its data, the "follow page filters" switches, Remove) and `DashboardDefaultInspector` otherwise (label, cards, filters, layout); - **Add card** appends a card at the end (Studio's id and defaults) and selects it; **Add filter**, drawn at the end of the filter bar, opens the panel's Filters section. **Save** (`saveDashboardInPlace`) is the confirmed-save door of objectstack-ai#35955 (ruling 7058616478): the body is staged as the item's draft under the first-write pin and that one item is published in the same act — no package-wide publish-drafts. Where it lands is read at open by `resolveDashboardEditTarget` (package list only): the owning package when the list carries it writable, else the app's customization package, whose id is taken from the list when it is already listed (`listedCustomizationPairOf`, the read Studio makes of a pair). At Save, and only there, `ensureDashboardSaveTarget` asks the ensure door for the pair (it creates `<base>.custom` on first use, as Studio's first saved customization does), and the body declares `overrides: { package, basedOn }` (`overrideDraftBody`, the body Studio's Customize writes; ADR-0146 D2/D3). So an installed app's dashboard is edited too, through the same doors Studio uses. The edit state is refused up front where Studio's Customize is: the ensure door walled for this caller (`useCustomizeDoorWalled`, toast "only the platform operator can customize an installed app's dashboard") and a base listing no version to declare the override at when the item declares none yet (Studio's `noVersion`). Over a draft already pending there, the edit state is not entered, and a save that races one writes nothing (`'pending-draft'`): a Studio draft is never published on its saver's behalf. **Discard** drops the buffer and writes nothing. After a save the bundle re-read keeps the shown dashboard standing, so the page does not flash its skeleton. The edit state draws the stored document with the served `_packageId` beside it, so its cards' dataset queries keep naming the dashboard's package (`callerPackage`, ADR-0150 D3) as in view mode; a save drops `_` keys. **The not-filtered mark** (`plugin-dashboard`). Every card, in every mode, names the page filters that do not reach it ("Not filtered by Region and Owner"; zh 「不跟随『区域和负责人』筛选」): a filter it opts out of (`filterBindings[name]: false`) or one whose `targetWidgets` leaves it out (an explicit string binding wins over `targetWidgets`). The built-in date filter is named as the bar names it ("Date range"), never by its reserved name. The list is the new core `dashboardFiltersNotApplied(widget, defs)`, which asks `resolveBoundField` — the binding `buildWidgetScopedFilter` builds the card's query from — so the mark and the data cannot disagree. A card every filter reaches carries none. **Renderer design mode** gains two opt-in affordances: `onWidgetResize(widgetId, { w, h })` draws the corner handle (snaps as the pointer crosses half a track; arrow keys step by one; width clamped to the grid's columns; not drawn on a phone), and `onAddFilter()` draws "Add filter" in the filter bar (the bar is drawn for it even before any filter exists). Studio's canvas passes neither, so it is unchanged. **Persistence seam.** `saveAndPublishRuntimeMetadata` itself is unchanged: `saveDashboardInPlace` hands it a client that names the target package on the three writes it makes (draft, publish, discard of a refused publish). Studio is not touched; panel wording is objectstack-ai#36373's (not touched here). ADR: this realises the in-app half of the ADR-0146 D1 amendment row "ADR-0146 D1, \"Studio owns all metadata\"" that seat 7 filed on the weekly ADR card objectstack-ai#36086 (epic objectstack-ai#36359); no `docs/adr` edit here. Persistence stays on the ADR-0034 runtime metadata seam (draft + per-item publish through `/meta`). ## Tests - `ui/packages/core/src/utils/__tests__/dashboard-filters.test.ts` — `dashboardFiltersNotApplied` agrees with `buildWidgetScopedFilter` for default, opted-out, rebound, `targetWidgets`-listed and explicit-over-list widgets. - `ui/packages/plugin-dashboard/src/__tests__/DashboardRenderer.filters.test.tsx` — the mark is on the opted-out card and only it, a rebound card has none, a `targetWidgets`-excluded card has it, an opted-out built-in date filter reads "Not filtered by Date range"; each case reads the query's `runtimeFilter` beside the mark. - `ui/packages/plugin-dashboard/src/__tests__/DashboardRenderer.designMode.test.tsx` — the corner handle only with `onWidgetResize` in design mode, keyboard resize, no card selection from the handle; "Add filter" only in design mode, drawn before any filter exists. - `ui/packages/plugin-dashboard/src/designAffordances.test.ts` — `resizedSpan` snapping and clamps. - `ui/packages/app-shell/src/views/runtime-metadata-persistence.test.ts` — edit target read from the list only (writable package; read-only package with no pair listed: none named, ensure not called; a listed pair named for reading; unbound; refusal), the ensure door asked at save (pair with `basedOn`; refusal and non-writable pair throw), the save body, the target package named on draft/publish/discard, pending-draft writes nothing. - `ui/packages/app-shell/src/views/DashboardInPageEditor.test.ts` — opening (owner's layered `effective`; an installed app with no pair yet opens its base's reading no pair and with no ensure door at all; a listed pair that does not hold it opens its base's; refused when walled and when no version is listed, but not for an item that already declares its override; refused over a pending draft without reading; refusals), add card, resize keeps unnamed coordinates. - `ui/packages/app-shell/src/views/DashboardView.inPageEdit-36372.test.tsx` — through the real `DashboardView` and renderer: no Edit button behind the gate; Edit opens the stored document in design mode with badge and panel; resize + Save stages and publishes in the owning package and leaves the edit state; an installed package asks the ensure door at Save only and saves into `crm.custom` declaring the override; **Edit then Discard on an installed app calls the ensure door zero times and writes nothing**; a walled door refuses with its reason; a dataset card in the edit state still queries with `callerPackage` (ablated: red without the fix); a pending draft refuses; Discard writes nothing. ## Acceptance notes **Live run** (L1-e's REWORK) on head `f0750e0dd`: a fresh local showcase backend (`objectstack dev --seed-admin`, file DB) and the console from source (`ui/apps/console` Vite against it), driven by Playwright as the seeded admin. The writable leg uses a package created over REST (`com.example.livedash`, depending on `com.example.showcase`) holding an app and a four-card dashboard with one card opted out of the date range; the installed leg uses showcase's own `showcase_ops_dashboard` (`com.example.showcase`, listed read-only, version 0.1.0). | Acceptance | Reading | |---|---| | Writable: drag, widen, add, delete, Save | Dragged "Priority Mix" to the front, widened "Tasks all time" by its corner (192 → 400 px, `w` 3 → 6), added a Metric card (given its dataset and measure in the panel; Save without them is refused by the server, 422 `widgets.N.dataset`, shown in the "could not be saved" toast with that reason), removed "Tasks by Status" through the panel. Writes on **Edit**: none. Writes on **Save**: exactly `PUT /api/v1/meta/dashboard/livedash_board?mode=draft&package=com.example.livedash` (200, `state=draft`) then `POST …/livedash_board/publish?package=com.example.livedash` (200). No `/packages/:id/publish-drafts`. | | After a reload the layout holds | The served dashboard reads `w_priority, w_tasks, w_all_time (w 6), widget_1`; the page draws that order, the widened card, the added "Open tasks (added live)" and no "Tasks by Status". | | Installed app: Edit then Discard | Writes on Edit: none; package list before and after Edit → change → Discard: `["com.example.showcase"]` (no `.custom` created); the page shows the original titles. | | Installed app: Save lands in `<base>.custom` | Writes on Save: `POST /api/v1/packages/com.example.showcase/ensure-customization`, `PUT …/showcase_ops_dashboard?mode=draft&package=com.example.showcase.custom` with `overrides: { package: "com.example.showcase", basedOn: "0.1.0" }` (server: "Saved customization overlay"), `POST …/publish?package=com.example.showcase.custom`. After a reload the page shows "Total Budget (customized live)". Studio's Interfaces (`/studio/com.example.showcase/interfaces?surface=dashboard:showcase_ops_dashboard`) shows the same title, the "Overrides ObjectStack Showcase" badge and "Only customizations (1)". | | Discard after a change | Covered in the installed leg above: the page is as before and nothing is written. | | Mark on an opted-out time-filter card | "Tasks all time" (`filterBindings: { dateRange: false }`) reads "Not filtered by Date range"; no other card is marked. Last 90 days: follows 10, all-time 10; Yesterday: follows 1, all-time **10** (unchanged). | | Its switch turned on and saved | The panel's dateRange "Apply" checkbox on that card, then Save: the body's card has no `filterBindings`; draft + per-item publish only. After a reload: no mark on any card; Yesterday: follows 1, all-time **1** (now follows). | The live run found two defects, fixed in `f0750e0dd` and pinned: the mark named the built-in date filter by its reserved name ("dateRange"), and the edit state's dataset queries dropped `?callerPackage=` (the stored document carries no `_packageId`). **Screenshots** (live run, 2× scale) are in the project's shared files, under `repo-objectstack-7/shots/36372/`; they cannot be uploaded to GitHub from the cloud seat, as on objectstack-ai#36397. They replace the harness shots. - `live-en-edit-writable.png` — edit state on the writable dashboard: Editing badge, hint, Add card / Discard / Save, dashed cards, the widened card selected with its panel, the marked card. - `live-en-view-marked-card.png` — view mode with "Not filtered by Date range" on the opted-out card, under "Yesterday". - `live-en-edit-installed.png`, `live-zh-edit-installed.png` — edit state on the installed showcase dashboard (zh: 「编辑中」「保存后所有人立刻看到」, five cards marked 「不跟随「Task Status」筛选」). - `live-en-after-reload-writable.png`, `live-en-after-reload-installed.png`, `live-en-studio-interfaces.png`, `live-en-view-after-switch-on.png` — the after-reload and Studio readings above. **Known gap** (not in this card): leaving the page in the edit state with unsaved changes drops them without asking. objectstack-ai#36362's unsaved-edits seam (`useRegisterUnsavedEdits`) is the place to register it, in a later card. Undo, a business user's own copy, a new dashboard, chart drawing and drill-down are out of scope, per the card. ## Verification - At `f0750e0dd`: type check `@object-ui/app-shell` and `@object-ui/plugin-dashboard` green; `packages/plugin-dashboard/src`, the dashboard view / editor / persistence files, `core` dashboard-filters and `AppContent.dashboardRouteReads-28784` — 223 files, 2213 tests green; `packages/i18n/src/__tests__` 106 files green; `check-i18n-en-drift`, `check-i18n-call-site-keys`, `check-i18n-dead-keys` green. `overlap-check`: clean against main and 7 open PRs (objectstack-ai#36398 included). - At `3e7995a73` (before this round): `node scripts/pm/dispatch-gates.mjs --commands`, 72 derived families all run and accounted (`--ran`); four first-pass reds re-run exit 0 (comment-mask sweep reading a deleted harness file, `vitest run scripts/` killed for memory, `check:skill-examples` prerequisite, `check:test-source-alias` fixed in the tests). This round's diff (app-shell editor, two i18n keys in every locale, the mark's label, docs) is left to CI's gates. https://claude.ai/code/session_01QsR2jUeSU9HhKxjcVsyprx 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#7 · zhuangjianguo · session_01QsR2jUeSU9HhKxjcVsyprx --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Steedos · project thread
repo:objectstack#7 · zhuangjianguo · session_01QsR2jSr8sNCnJrK6Q9kEF5
Fixes #36362
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
「Edit app」 in the page header no longer opens Studio for an administrator who may design the app (
useAppStudioEntry'seditposture: workspace admin,manage_metadata, writable package). It turns on the shell's design mode for the app on screen, in place.layout/designMode.tsx) is held byConsoleLayoutfor the app it was entered in: it survives moving between pages of that app, goes off (and drops what it held) when the app changes, and is never drawn on a phone (enabled: falsehides it and keeps what is staged). It has no address; no URL enters it.layout/DesignModeBar.tsx) is drawn in the AppShell's top slot, across the window, while the mode is on: 「Design mode」 at its left, 「Cancel」 and 「Save」 at its right, nothing else. 「Save」 is off while nothing is staged. On desktop the sidebar sits below the bar while it is shown, and the page header hides its 「Edit app」 button.useDesignModeChange(key): a surface stages a change under a key together with its owncommit. 「Save」 commits every staged change in the order first staged, then leaves; a failed commit stops there, keeps it and every later change staged, keeps the mode on and toasts the reason. 「Cancel」 drops all and commits none. Outside the mode nothing can be staged. This PR stages nothing yet; 设计模式(二)菜单编辑:添加已有的菜单项,上移下移、移到分组、移除、改名和图标 #36363, 设计模式(四)页头按钮:选哪些动作固定在页头、哪些收进「更多」,可以拖动排序 #36366 and 设计模式(三)在「添加菜单项」里新建仪表盘、新建报表:建完落在占好的位置,直接进入编辑 #36364 build on it.chrome/unsavedEdits.ts), which gains an optionalkeeps(url)per registration: a link to another page of the same app does not ask (the mode goes along), a link out of the app and the app switcher ask, and a tab close or reload is held by the browser prompt.designMode.title,designMode.leaveUnsaved,designMode.saveFailedin every hand-written locale, zh-Hant generated.Read first, by risk:
ui/packages/app-shell/src/layout/designMode.tsx— the save loop (order, stop-on-failure, re-staged-while-sending) and the app-change reset.ui/packages/app-shell/src/chrome/unsavedEdits.ts—keepsonly narrows the click guard;confirmUnsavedLeaveandbeforeunloadstill ask for every registration.ui/packages/app-shell/src/layout/ConsoleLayout.tsx/UnifiedSidebar.tsx— the header slot and the sidebar offset while the bar is on.Tests
layout/__tests__/designMode-36362.test.tsx: the bar's contents; 「Save」 off until something is staged; commit order and exit; a failed commit keeps it and later ones, keeps the mode, toasts; 「Cancel」 commits none; nothing staged outside the mode; another app drops it; a phone hides it and keeps what is staged;beforeunloadheld only while staged; an in-app link asks nothing, a link to Home asks;isPageOfAppwith a basename.ShellPageActions-36111.test.tsx: in theeditposture 「Edit app」 is a button (not a link) that enters the mode and is hidden while it is on; a member sees nothing; the read-only eye entry is unchanged.UnifiedSidebar.favoritesMenu-12427.test.tsx: the Favorites section is hidden in design mode and back after.unsavedEdits-13231.test.tsx: thekeepsoption skips only the registrations that keep the URL.consoleTopBar.height-12639.test.ts: the two source pins admit the design mode's arm (same slot, same 48 px; the sidebar below it on desktop).Readings at d78b61b
consoleTopBar.height-12639: 12/12 passed.ConsoleLayout,UnifiedSidebar,ShellPageActions,unsavedEditsordesignMode, 184 files in 4 batches): 1,654 passed; the 2 reds (the top-bar source pins above) fixed in d78b61b and re-run green.keepscheck disabled inunsavedEdits.ts): 3 tests red; restored,git statusclean.turbo type-checkfor@object-ui/app-shelland@object-ui/i18n: 70/70 tasks green.pnpm build: exit 0.dispatch-gates.mjs --commandsderived 41 gates, all exit 0;--ranreconciliation: 41 derived, 41 run, 0 not measured.overlap-check.mjs: origin/main and 8 open PRs sharing files (fix(app-shell): ⌘B / Ctrl+B does what the sidebar's expand / collapse button does #36391 sharesConsoleLayout.tsxandUnifiedSidebar.tsx; the rest share locale files) all merge cleanly.Acceptance notes
editposture only, the gate 「Edit app」 always had. Apps in read-only packages (the showcase, apps installed from the marketplace) show the eye entry and cannot enter the mode. 设计模式(二)菜单编辑:添加已有的菜单项,上移下移、移到分组、移除、改名和图标 #36363 asks that installed apps' menus be editable through the customization layer; that needs the read-only posture to enter the mode too, and is raised with the card's seat rather than decided here.content/docshas none), so no docs change.Verification
Live run against a fresh local backend and the console (Vite), signed in as the seeded admin, on an app in a newly created writable package, at 1280 px and 1440 px: 「Edit app」 is shown in the page header; pressing it draws the bar (
Design modeCancelSave, 「Save」 off), the sidebar moves below it; moving to another page of the app keeps the bar; 「Cancel」 removes it and 「Edit app」 comes back. Screenshots of both states at both widths are in the project files atrepo-objectstack-7/shots/36362/(before-1280.png,before-1440.png,design-1280.png,design-1440.png).The card's 「PR 正文附截图」 is met by those files: a cloud container cannot upload images to the PR.
Two minutes: as a workspace admin, open an app in a package you created in Studio, press 「Edit app」 in the page header: the blue bar appears with 「Cancel」 and a disabled 「Save」; open another page from the sidebar: the bar stays; press 「Cancel」: the bar goes and 「Edit app」 is back. Open an installed app: the header still offers 「Open APP in Studio」.
🤖 Generated with Claude Code