autosolutions-os 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1 - 2026-09-29
4
+
5
+ A fix, with `autosolutions-design-system` 6.3.2. A click on the tab or row
6
+ the frame already shows goes to that tab's or row's own page from a page
7
+ filed under it. In Key Accounts a draft (`/drafts/$id`) files under the
8
+ Requests tab (`match: ["/drafts"]`); on a draft, clicking Requests (or
9
+ stepping out to Commercial and clicking Key accounts again) now goes to `/`,
10
+ as the old sidebar link did, where 0.2.0 stayed on the draft. In the Hub,
11
+ Unmarked Agent on an Agent thread goes to `/comms/agent`.
12
+
13
+ - `osFrame().targetFor` reads the design system's `reselect` flag
14
+ (`OsFrameState.reselect`). A reselected tab or row goes to its own `path`
15
+ unless the URL is exactly that path (the same pathname and the same
16
+ query), and nowhere when it is, so a click on the page you are on adds no
17
+ history entry. Settings, and Admin in the Hub, go back to their page from
18
+ a page under them.
19
+ - A reselect goes to the tab's own path and drops the page's query. Exactly
20
+ includes the query, so on `/analytics?range=90` Analytics goes to
21
+ `/analytics`, as the old sidebar links did. Tell app owners: a page that
22
+ keeps its filters or sort in the query starts again from its defaults
23
+ after that click.
24
+ - As before: a tab with no `path` (page state) goes nowhere; a row that
25
+ carries its own tab row in the page (`menu: false`, the Hub's Smart Comms)
26
+ stays on any view of its own; links to other apps open as they did;
27
+ opening a function's menu is not a navigation.
28
+ - A locked row goes nowhere from `targetFor`, whatever state it is handed.
29
+ The frame never reports a click on one, but a locked Hub row keeps its
30
+ `path` for its hint, and `targetFor` used to return it.
31
+ - `OsWorkspaceFrame` passes the flag through, and so does an app off the
32
+ core that hands `targetFor` the frame's state whole (Key Accounts does).
33
+ Apps change nothing but the two versions.
34
+ - The design-system peer range stays `>=6.3.0 <7`. With 6.3.0 or 6.3.1 the
35
+ flag never comes and this release behaves exactly as 0.2.0: the consumer
36
+ check on design system 6.3.1 passes every test but the new reselect ones.
37
+ Raising it to `>=6.3.2` would not stop the pairing that goes wrong, which
38
+ is design system 6.3.2 with os 0.2.0 (0.2.0's own range allows it).
39
+
40
+ **Take both together.** Design system 6.3.2 with os 0.2.0 is the one pairing
41
+ that misbehaves: 6.3.2 reports the click on the selected tab and 0.2.0's
42
+ `targetFor` does not know the flag, so where a tab's path is also its tool's
43
+ (Key Accounts' Requests at `/`), that click on the page you are on pushes a
44
+ second history entry for it. 0.2.0's peer range and the apps' caret ranges
45
+ allow that pairing, so the release order has to prevent it: publish os
46
+ 0.2.1 no later than design system 6.3.2, and have each app bump both
47
+ packages in one commit (Key Accounts, e-sales and the Hub pin `^6.3.1` and
48
+ `^0.2.0` with lockfiles).
49
+
3
50
  ## 0.2.0 - 2026-09-28
4
51
 
5
52
  The OS menu and the workspace frame. Needs `autosolutions-design-system` 6.3
package/README.md CHANGED
@@ -62,7 +62,15 @@ import { OsWorkspaceFrame } from "autosolutions-os/frame";
62
62
  It works with any router: it reads `location` and calls `onNavigate(href)` for
63
63
  paths inside the app, and opens other apps itself, in the same tab. Browser
64
64
  Back moves the menus because the frame follows `location`, and it calls
65
- `onNavigate` only when someone clicks, so there is no loop.
65
+ `onNavigate` only when someone clicks, so there is no loop. A click on the tab
66
+ or row the frame already shows goes to that tab's or row's own path from a
67
+ page under it (a draft filed under Requests goes back to Requests), and
68
+ nowhere when the URL is exactly that path. It goes to the tab's own path and
69
+ drops the page's query: on `/analytics?range=90`, Analytics goes to
70
+ `/analytics`, as the old sidebar links did, so a page that keeps its filters in
71
+ the query starts again from its defaults. Design system 6.3.2 is what reports
72
+ that click: take it together with this package's 0.2.1 (the CHANGELOG says
73
+ why).
66
74
 
67
75
  - `tools` are this app's own rows, by menu-map id, with their routes. They are
68
76
  live whatever the map says. A row the map does not have takes `fn`, `section`,
package/dist/frame.d.ts CHANGED
@@ -10,7 +10,8 @@
10
10
  * query) and an `onNavigate(href)` that pushes an in-app path; links to other
11
11
  * apps it opens itself, in the same tab. Browser Back and Forward move the
12
12
  * menus because the frame follows `location`, and it only calls `onNavigate`
13
- * when someone clicks.
13
+ * when someone clicks. A click on the tab or row it already shows, from a page
14
+ * filed under it (a draft under Requests), goes to that tab's own page.
14
15
  */
15
16
  import { type ReactNode } from "react";
16
17
  import type { WorkspaceState } from "autosolutions-design-system";
package/dist/frame.js CHANGED
@@ -11,7 +11,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
11
11
  * query) and an `onNavigate(href)` that pushes an in-app path; links to other
12
12
  * apps it opens itself, in the same tab. Browser Back and Forward move the
13
13
  * menus because the frame follows `location`, and it only calls `onNavigate`
14
- * when someone clicks.
14
+ * when someone clicks. A click on the tab or row it already shows, from a page
15
+ * filed under it (a draft under Requests), goes to that tab's own page.
15
16
  */
16
17
  import { useEffect, useMemo, useState } from "react";
17
18
  import { ActionList, TopBar, WorkspaceFrame } from "autosolutions-design-system";
package/dist/nav.d.ts CHANGED
@@ -185,7 +185,10 @@ export type OsTarget = {
185
185
  href: string;
186
186
  external: boolean;
187
187
  };
188
- /** The part of WorkspaceFrame's state a destination depends on. */
188
+ /**
189
+ * The part of WorkspaceFrame's state a destination depends on. `reselect` is
190
+ * WorkspaceFrame's flag for a click on what it already shows.
191
+ */
189
192
  export type OsFrameState = {
190
193
  fn: {
191
194
  id: string;
@@ -196,6 +199,7 @@ export type OsFrameState = {
196
199
  tab: {
197
200
  id: string;
198
201
  } | null;
202
+ reselect?: boolean | undefined;
199
203
  };
200
204
  export type OsFrameOptions = {
201
205
  /** This app's catalogue key; "hub" for the Hub itself. */
@@ -224,7 +228,13 @@ export type OsFrame = {
224
228
  homeFunction: "hub";
225
229
  /** Where a location (pathname plus query) sits in the frame. */
226
230
  locate: (location: string) => OsLocation;
227
- /** Where a click from `location` goes; null when it goes nowhere (opening a menu, or already there). */
231
+ /**
232
+ * Where a click from `location` goes; null when it goes nowhere (opening a
233
+ * menu, a locked row, or already there). A reselect (`state.reselect`, a
234
+ * click on the tab or row the frame already shows) goes to that tab's or
235
+ * row's own path unless `location` is exactly it, so a page filed under a
236
+ * tab (a draft under Requests) goes back to the tab's page.
237
+ */
228
238
  targetFor: (state: OsFrameState, location: string) => OsTarget | null;
229
239
  };
230
240
  /**
package/dist/nav.js CHANGED
@@ -374,15 +374,21 @@ export function osFrame(options) {
374
374
  const targetFor = (state, location) => {
375
375
  const fn = state.fn.id;
376
376
  const here = locate(location);
377
+ const again = state.reselect === true;
377
378
  const internal = (href, spot) => (here.fn === spot.fn && here.item === spot.item && here.tab === spot.tab ? null : { href, external: false });
379
+ /* A path of this app, unless the URL is exactly there already. */
380
+ const goTo = (href) => (at(location, href) ? null : { href, external: false });
378
381
  if (fn === "settings") {
379
382
  const path = settingsPath ?? (isHub ? HUB_PATHS.settings : undefined);
380
383
  if (!path)
381
384
  return toHub(HUB_PATHS.settings);
382
- return at(location, path) ? null : { href: path, external: false };
385
+ return goTo(path);
386
+ }
387
+ if (fn === "admin") {
388
+ if (!isHub)
389
+ return toHub(HUB_PATHS.admin);
390
+ return again ? goTo(HUB_PATHS.admin) : internal(HUB_PATHS.admin, { fn, item: null, tab: null });
383
391
  }
384
- if (fn === "admin")
385
- return isHub ? internal(HUB_PATHS.admin, { fn, item: null, tab: null }) : toHub(HUB_PATHS.admin);
386
392
  const row = state.item ? (sections[fn] ?? []).flatMap((section) => section.items).find((r) => r.id === state.item?.id) : undefined;
387
393
  if (!row) {
388
394
  if (fn !== "hub")
@@ -393,7 +399,21 @@ export function osFrame(options) {
393
399
  const landing = locate(homePath);
394
400
  return here.fn === landing.fn && here.item === landing.item ? null : { href: homePath, external: false };
395
401
  }
402
+ if (row.disabled)
403
+ return null; // locked: the frame never reports a click on it, and it goes nowhere
396
404
  const tab = state.tab ? flatTabs(row.tabs).find((t) => t.id === state.tab?.id) : undefined;
405
+ /* A click on the tab or row the frame already shows: its own path, from
406
+ anywhere under it (a draft filed under Requests, the Agent's threads),
407
+ and nothing when the URL is exactly that path. A tab with no path is
408
+ page state, with no page to go back to. A row that carries its own tab
409
+ row in the page (`menu: false`, the Hub's Smart Comms) keeps the rule
410
+ below: its page's tabs are all its own ground. */
411
+ if (again && row.menu !== false) {
412
+ if (tab)
413
+ return tab.path ? goTo(tab.path) : null;
414
+ if (row.path)
415
+ return goTo(row.path);
416
+ }
397
417
  if (tab?.path)
398
418
  return internal(tab.path, { fn, item: row.id, tab: tab.id });
399
419
  if (row.path)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autosolutions-os",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "One sign-in, one company switcher, one app grid. What every AutoSolutions app imports instead of copying.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",