@unson/brainbase-mcp 0.50.13 → 0.50.14

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.
@@ -27,12 +27,12 @@
27
27
  */
28
28
 
29
29
  import { THREE, MapControls } from './world-vendor.js';
30
- import { changesSince, cityMeasures, districtChanges, districtLots, districtSnapshot, districtStage, groupJudgmentPlaces, skyAt, UNPLACED_REASON_TEXT } from './world-placement.js';
30
+ import { changesSince, cityMeasures, cityPulse, districtChanges, districtLots, districtPulse, districtSnapshot, districtStage, groupJudgmentPlaces, skyAt, UNPLACED_REASON_TEXT, worldPulse } from './world-placement.js';
31
31
  import { createDistrictView, DISTRICT_LEGEND } from './world-district.js';
32
32
  import { createWorldCanvasUI, SKY_MODES, skyModeLabel, skyModeIconSvg } from './world-canvas-ui.js';
33
33
  import { workCanvasNotes } from './world-canvas-notes.js';
34
34
  import { canvasTexture, drawFacade, FACADE_SIZES, FACADE_UNITS, gableRoof, hashUnit, muted, paintVertices, roundedPlate, valueNoise } from './world-scenery.js';
35
- import { WORK_STATES, readReasonShort, workCityBlocks, workGrowthBlock, workPickBlock, workSign, workSignBlocks, workSigns, workSiteBlocks } from './world-work-rail.js';
35
+ import { WORK_STATES, cityPulseChips, createPulsePanel, readReasonShort, workCityBlocks, workGrowthBlock, workPickBlock, workSign, workSignBlocks, workSigns, workSiteBlocks } from './world-work-rail.js';
36
36
  import { exitHrefKind, exitLegend, exitsRailBlock, normalizeBusinessExits } from './world-exits.js';
37
37
  import {
38
38
  makeWorkspaceElement as el,
@@ -1117,6 +1117,10 @@ function createScene({ doc, stage, labelsLayer, reducedMotion, onPick, onClear,
1117
1117
  const summary = summaries?.[code];
1118
1118
  if (entry.label) entry.label.size = null;
1119
1119
  entry.label?.node.querySelectorAll('.bb-world-badge').forEach((badge) => badge.remove());
1120
+ entry.label?.node.querySelectorAll('.bb-world-pulse-chips').forEach((chips) => chips.remove());
1121
+ // How the business's work stands, in the record's words (story-world-three-scales-v1): the world's scale.
1122
+ const chips = entry.label ? cityPulseChips(doc, cityPulse(summary)) : null;
1123
+ if (chips?.children.length) entry.label.node.append(chips);
1120
1124
  const signal = workSign(summary);
1121
1125
  if (!signal) continue;
1122
1126
  const unreadable = signal.kind === 'unreadable';
@@ -1231,10 +1235,21 @@ function createScene({ doc, stage, labelsLayer, reducedMotion, onPick, onClear,
1231
1235
  height = rect.height;
1232
1236
  renderer.setSize(width, height, false);
1233
1237
  const aspect = width / height;
1234
- const span = Math.max((worldExtent * 0.9) / Math.min(aspect, 1.25), 24);
1238
+ // A host panel over the left of the stage: the world is fitted to, and centred in, the part left clear.
1239
+ const inset = width > 760 ? Math.min(viewInset, width * 0.45) : 0;
1240
+ const span = Math.max((worldExtent * 0.9) / Math.min((width - inset) / height, 1.25), 24);
1235
1241
  Object.assign(camera, { left: -span * aspect, right: span * aspect, top: span, bottom: -span });
1242
+ if (inset) camera.setViewOffset(width, height, -inset / 2, 0, width, height);
1243
+ else camera.clearViewOffset();
1236
1244
  camera.updateProjectionMatrix();
1237
1245
  }
1246
+ let viewInset = 0;
1247
+ function setViewInset(left) {
1248
+ const next = Number.isFinite(left) && left > 0 ? left : 0;
1249
+ if (next === viewInset) return;
1250
+ viewInset = next;
1251
+ if (width > 0) resize();
1252
+ }
1238
1253
  function fitExtent(extent) {
1239
1254
  worldExtent = extent;
1240
1255
  if (width > 0) resize();
@@ -1242,8 +1257,22 @@ function createScene({ doc, stage, labelsLayer, reducedMotion, onPick, onClear,
1242
1257
  const observer = typeof ResizeObserver === 'function' ? new ResizeObserver(resize) : null;
1243
1258
  observer?.observe(stage);
1244
1259
 
1260
+ // The host's own controls over the stage (the toolbar, the notices): a name never sits under them.
1261
+ let overlayRects = [];
1262
+ let overlayAge = 0;
1263
+ function overlays() {
1264
+ if (overlayAge-- > 0) return overlayRects;
1265
+ overlayAge = 20;
1266
+ const origin = stage.getBoundingClientRect();
1267
+ overlayRects = [...(stage.ownerDocument?.querySelectorAll?.('.bb-world-canvas-toolbar, .bb-world-canvas-quests, .bb-world-pulse') ?? [])]
1268
+ .map((node) => node.getBoundingClientRect())
1269
+ .filter((rect) => rect.width > 0 && rect.height > 0)
1270
+ .map((rect) => ({ x: rect.left - origin.left, y: rect.top - origin.top, w: rect.width, h: rect.height }));
1271
+ return overlayRects;
1272
+ }
1273
+
1245
1274
  function placeLabels() {
1246
- const placed = [];
1275
+ const placed = [...overlays()];
1247
1276
  const selectedBusiness = selected?.userData?.business ?? null;
1248
1277
  const visibleLabels = [];
1249
1278
  for (const label of labels) {
@@ -1263,7 +1292,9 @@ function createScene({ doc, stage, labelsLayer, reducedMotion, onPick, onClear,
1263
1292
  for (const label of visibleLabels) {
1264
1293
  label.node.hidden = false;
1265
1294
  label.size ??= { w: label.node.offsetWidth, h: label.node.offsetHeight };
1266
- const rect = { x: label.screen.x - label.size.w / 2, y: label.screen.y - label.size.h, w: label.size.w, h: label.size.h };
1295
+ // A name whose anchor is near an edge slides inward instead of being cut off by it.
1296
+ const x = Math.min(Math.max(label.screen.x - label.size.w / 2, 6), Math.max(width - label.size.w - 6, 6));
1297
+ const rect = { x, y: Math.max(label.screen.y - label.size.h, 6), w: label.size.w, h: label.size.h };
1267
1298
  const clash = placed.some((other) => rect.x < other.x + other.w + 2 && rect.x + rect.w + 2 > other.x && rect.y < other.y + other.h + 2 && rect.y + rect.h + 2 > other.y);
1268
1299
  if (clash && label.rank > LABEL_PRIORITY.selected) {
1269
1300
  label.node.hidden = true;
@@ -1393,6 +1424,7 @@ function createScene({ doc, stage, labelsLayer, reducedMotion, onPick, onClear,
1393
1424
  },
1394
1425
  flyTo,
1395
1426
  resetView,
1427
+ setViewInset,
1396
1428
  clearSelection() {
1397
1429
  select(null);
1398
1430
  },
@@ -1450,18 +1482,20 @@ function addressSelection() {
1450
1482
  read() {
1451
1483
  try {
1452
1484
  const params = new URLSearchParams(globalThis.location?.search ?? '');
1453
- return { business: params.get('world_business'), site: params.get('world_site') };
1485
+ return { business: params.get('world_business'), site: params.get('world_site'), street: params.has('world_street') ? params.get('world_street') : null };
1454
1486
  } catch {
1455
- return { business: null, site: null };
1487
+ return { business: null, site: null, street: null };
1456
1488
  }
1457
1489
  },
1458
- write({ business, site }) {
1490
+ write({ business, site, street = null }) {
1459
1491
  try {
1460
1492
  const url = new URL(globalThis.location.href);
1461
1493
  if (business) url.searchParams.set('world_business', business);
1462
1494
  else url.searchParams.delete('world_business');
1463
1495
  if (site) url.searchParams.set('world_site', site);
1464
1496
  else url.searchParams.delete('world_site');
1497
+ if (business && street !== null) url.searchParams.set('world_street', street);
1498
+ else url.searchParams.delete('world_street');
1465
1499
  globalThis.history?.replaceState(globalThis.history.state, '', `${url.pathname}${url.search}${url.hash}`);
1466
1500
  } catch {
1467
1501
  // Without an address the selection simply is not kept.
@@ -1481,7 +1515,8 @@ function addressSelection() {
1481
1515
  * the list) opens in the host's 判断の履歴. The local web opens `#value-proofs?decision=<id>`; an organization
1482
1516
  * web passes its own route.
1483
1517
  * @param {'standard' | 'canvas'} [options.presentation] Canvas owns its accessible overlays and ignores the host rail.
1484
- * @param {{ read(): { business: string | null, site: string | null }, write(selection): void }} [options.selection]
1518
+ * @param {{ read(): { business: string | null, site: string | null, street?: string | null }, write(selection): void }} [options.selection]
1519
+ * `street` is the gathering of work the viewer came close to (its purpose; '' for the unlabelled), or null.
1485
1520
  * @param {(business: object) => (BusinessExitsAnswer | Promise<BusinessExitsAnswer>)} [options.businessExits] The tools
1486
1521
  * a business uses (story-world-business-exits-v1). The answer is
1487
1522
  * `{ status: 'complete'|'partial'|'failed'|'not_connected', read_at?, reason?, exits: [{ id, label, href,
@@ -1733,7 +1768,8 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
1733
1768
  onDismissTask: () => dismissTask(),
1734
1769
  });
1735
1770
  const help = el(doc, 'div');
1736
- help.append(el(doc, 'p', { text: 'ドラッグで移動、ホイールで寄る・離れる、右ドラッグで回転。都市を選ぶと区画に入ります。右端から詳細と絞り込みを開けます。Escで詳細を閉じ、その後は区画・全体の順に戻ります。ここから記録は書き換えません。' }));
1771
+ help.append(el(doc, 'p', { text: 'ドラッグで移動、ホイールで寄る・離れる、右ドラッグで回転。都市を選ぶと区画に入ります。右端から詳細と絞り込みを開けます。Escで詳細を閉じ、その後は通り・区画・全体の順に戻ります。ここから記録は書き換えません。' }));
1772
+ help.append(el(doc, 'p', { text: '左下の「いまの動き」は、見ている階層で中身が変わります。世界では仕事が進行中の事業、事業の中では仕事の進みと通り(仕事の集まり)ごとの様子、通りに寄ると、どのAIがどの仕事にいてどうしているかを出します。「進行中」「待ち」はタスクの記録の言葉です。AIを「動いている」と出すのは、進行中のタスクと5分以内の稼働の知らせが一致したときだけです。' }));
1737
1773
  help.append(legend, workLegend);
1738
1774
  workLegend.hidden = false;
1739
1775
  const list = el(doc, 'ul');
@@ -1748,7 +1784,7 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
1748
1784
  // behaviour as the canvas help button. The information is kept, just tucked away.
1749
1785
  const legendPanel = el(doc, 'div', { className: 'bb-world-legend-panel', attrs: { id: `bb-world-legend-${++worldLegendSequence}` } });
1750
1786
  legendPanel.hidden = true;
1751
- legendPanel.append(el(doc, 'p', { text: '事業を都市、案件を区画、判断の種類を広場の建物として描いています。都市を選ぶとその事業の区画に入り、仕事(タスク)が通りに面した現場として建ち、記録から把握できていないことが街の様子で見えます。' }), legend, workLegend);
1787
+ legendPanel.append(el(doc, 'p', { text: '事業を都市、案件を区画、判断の種類を広場の建物として描いています。都市を選ぶとその事業の区画に入り、仕事(タスク)が通りに面した現場として建ち、記録から把握できていないことが街の様子で見えます。' }), legend, workLegend, el(doc, 'p', { className: 'bb-world-legend-pulse', text: '左下の「いまの動き」は、世界・事業・通り(仕事の集まり)の順に、見ている階層の動きを出します。「進行中」「待ち」はタスクの記録の言葉で、AIを「動いている」と出すのは、進行中のタスクと5分以内の稼働の知らせが一致したときだけです。' }));
1752
1788
  const legendToggle = workspaceButton(doc, {
1753
1789
  text: '?',
1754
1790
  variant: 'quiet',
@@ -1764,6 +1800,73 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
1764
1800
  wrap.append(header, stage);
1765
1801
  }
1766
1802
 
1803
+ // --- the pulse panel: what moves at the scale the viewer is at (story-world-three-scales-v1) ------
1804
+ const pulsePanel = createPulsePanel(doc, {
1805
+ onWorld: () => { goToWorld(); clearAll(); },
1806
+ onCity: () => leaveStreet(),
1807
+ onEnterCity: (code) => {
1808
+ const business = businessOf(code);
1809
+ if (business) enterFromRail(business);
1810
+ },
1811
+ onStreet: (key) => {
1812
+ const business = businessOf(current.code);
1813
+ if (business) showStreet(business, key);
1814
+ },
1815
+ onSite: (taskId) => {
1816
+ const business = businessOf(current.code);
1817
+ if (business) openSiteById(business, taskId, { focus: true });
1818
+ },
1819
+ onFold: () => applyPulseInset(),
1820
+ });
1821
+ pulsePanel.hide();
1822
+ stage.append(pulsePanel.node);
1823
+ let pulseReady = false;
1824
+ let pulseShown = null;
1825
+ const NOT_CONNECTED_PULSE = 'この画面は仕事の記録につながっていないため、動きは出していません(動きが無いとは確認できません)。';
1826
+ /** Draws the panel for where the viewer is; a redraw with nothing changed is skipped (focus and scroll stay). */
1827
+ function refreshPulse() {
1828
+ if (disposed || !pulseReady) return;
1829
+ const business = current.level !== 'world' && current.code ? businessOf(current.code) : null;
1830
+ let view;
1831
+ if (!business) {
1832
+ view = { level: 'world', world: worldPulse(knownBusinesses, workSummaries), connected: workConnected };
1833
+ } else {
1834
+ const work = workCache.get(business.code);
1835
+ if (workConnected === false || work?.status === 'not_connected') view = { level: 'city', state: NOT_CONNECTED_PULSE };
1836
+ else if (!work) view = { level: 'city', state: null };
1837
+ else if (work.status !== 'ok' || !['complete', 'partial'].includes(work.reads.tasks.state)) view = { level: 'city', state: '仕事の記録を読めないため、動きは出していません(動きが無いとは確認できません)。' };
1838
+ else {
1839
+ const pulse = districtPulse(work.sites);
1840
+ const street = current.street !== null ? pulse.streets.find((entry) => entry.key === current.street) ?? null : null;
1841
+ if (current.street !== null && !street) {
1842
+ // The street is gone from the records read now: back to the whole district.
1843
+ current.street = null;
1844
+ current.focus = null;
1845
+ }
1846
+ const partial = work.reads.tasks.state === 'partial';
1847
+ view = street ? { level: 'street', street, sites: work.sites, partial } : { level: 'city', pulse, partial };
1848
+ }
1849
+ }
1850
+ const key = JSON.stringify([business?.code ?? null, view, business ? null : knownBusinesses.length]);
1851
+ if (key === pulseShown) return;
1852
+ pulseShown = key;
1853
+ if (view.level === 'world') pulsePanel.showWorld(view);
1854
+ else if (view.level === 'street') pulsePanel.showStreet({ business, ...view });
1855
+ else pulsePanel.showCity({ business, ...view });
1856
+ applyPulseInset();
1857
+ }
1858
+ function applyPulseInset() {
1859
+ scene?.setViewInset(pulseInset());
1860
+ }
1861
+ // A heartbeat grows old while the panel is open.
1862
+ const pulseTimer = setInterval(() => { if (current.level !== 'world') refreshPulse(); }, 30000);
1863
+ pulseTimer.unref?.();
1864
+ /** How much of the stage's left the open panel covers, so the district is framed clear of it. */
1865
+ const pulseInset = () => {
1866
+ const rect = pulsePanel.node.getBoundingClientRect?.();
1867
+ return pulsePanel.node.hidden || !rect?.width || rect.height < 80 ? 0 : rect.width + 40;
1868
+ };
1869
+
1767
1870
  const onRootEscape = (event) => {
1768
1871
  if (!canvasMode || event.key !== 'Escape' || event.defaultPrevented) return;
1769
1872
  event.preventDefault();
@@ -1924,13 +2027,14 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
1924
2027
  let workConnected = null;
1925
2028
  const workCache = new Map();
1926
2029
  const workRequests = new Map();
1927
- const current = { code: null, siteId: null, level: 'world', focus: null, pendingSite: null, detachedSiteId: null, exitId: null };
2030
+ const current = { code: null, siteId: null, level: 'world', focus: null, pendingSite: null, detachedSiteId: null, exitId: null, street: null, pendingStreet: null };
1928
2031
 
1929
2032
  /** Inside a city the notices fold away (they would cover it); its rail carries the sources and times. */
1930
2033
  function setLevel(level) {
1931
2034
  current.level = level;
1932
2035
  notices.hidden = level !== 'world';
1933
2036
  if (canvasMode && level === 'world') updateDistrictNotes(null);
2037
+ refreshPulse();
1934
2038
  }
1935
2039
 
1936
2040
  function setCurrent(code, siteId) {
@@ -1938,7 +2042,8 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
1938
2042
  current.siteId = siteId;
1939
2043
  if (!siteId) current.detachedSiteId = null;
1940
2044
  canvasUI?.setCity(code);
1941
- selection?.write?.({ business: code, site: siteId });
2045
+ // The street is passed only while the viewer is close to one, so a host's own selection sees what it always did.
2046
+ selection?.write?.({ business: code, site: siteId, ...(code && current.street !== null ? { street: current.street } : {}) });
1942
2047
  }
1943
2048
 
1944
2049
  function businessOf(code) {
@@ -2119,9 +2224,56 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2119
2224
  }
2120
2225
 
2121
2226
  function showFocus(business, focus) {
2227
+ // Another way of picking work (a kind of gap, a state, or all of it) steps back from the street.
2228
+ if (current.street !== null) {
2229
+ current.street = null;
2230
+ district?.leaveStreet();
2231
+ setCurrent(current.code, current.siteId);
2232
+ }
2122
2233
  current.focus = focus;
2123
2234
  district?.focus(focusIdsFor(workCache.get(business.code), focus));
2124
2235
  renderCityRail(business, { revealFocus: true });
2236
+ refreshPulse();
2237
+ }
2238
+
2239
+ /** Back from a work's details to its district or street, without leaving either. */
2240
+ function closeSite() {
2241
+ if (current.level !== 'site') return;
2242
+ canvasUI?.closeTask();
2243
+ district?.clearSelection();
2244
+ setCurrent(current.code, null);
2245
+ setLevel('city');
2246
+ }
2247
+
2248
+ /**
2249
+ * The third scale: comes close to one gathering of work (a street; '' is the unlabelled lots). Its work
2250
+ * stays vivid and the rest fades, and the panel says which agent is on which work and how.
2251
+ */
2252
+ function showStreet(business, key) {
2253
+ const work = workCache.get(business.code);
2254
+ if (work?.status !== 'ok' || !work.sites.some((site) => site.work.status !== 'cancelled' && (purposeOf(site) ?? '') === key)) return false;
2255
+ closeSite();
2256
+ current.street = key;
2257
+ current.focus = { purpose: key || null };
2258
+ setCurrent(business.code, null);
2259
+ district?.focus(focusIdsFor(work, current.focus));
2260
+ district?.enterStreet(key);
2261
+ renderCityRail(business);
2262
+ refreshPulse();
2263
+ return true;
2264
+ }
2265
+
2266
+ function leaveStreet() {
2267
+ const business = current.code ? businessOf(current.code) : null;
2268
+ if (!business || current.street === null) return;
2269
+ closeSite();
2270
+ current.street = null;
2271
+ current.focus = null;
2272
+ setCurrent(business.code, null);
2273
+ district?.focus(null);
2274
+ district?.leaveStreet();
2275
+ renderCityRail(business);
2276
+ refreshPulse();
2125
2277
  }
2126
2278
 
2127
2279
  // --- the district grows (AC-22〜24): what changed since this viewer was last inside -------------
@@ -2174,6 +2326,7 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2174
2326
  if (current.code !== code || current.level === 'world') return;
2175
2327
  updateDistrictNotes(work);
2176
2328
  scene?.showWork(code, work);
2329
+ refreshPulse();
2177
2330
  if (districtCode === code && district?.isOpen()) {
2178
2331
  district.refresh(business, work, { neighbours: new Map(knownBusinesses.map((entry) => [entry.code, entry.name])), exits: stationsFor(business.code) });
2179
2332
  const growth = noteGrowth(code, work, previous);
@@ -2220,12 +2373,9 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2220
2373
  else if (!anchor.visible && !current.siteId) canvasUI?.setTaskAnchor({ visible: false });
2221
2374
  },
2222
2375
  // A street's sign lists its work; the hall and its plaza open what the business is for.
2223
- onPickStreet: ({ label }) => {
2376
+ onPickStreet: ({ key }) => {
2224
2377
  const owner = businessOf(current.code);
2225
- if (!owner) return;
2226
- if (current.level === 'site') goUp();
2227
- showFocus(owner, { purpose: label });
2228
- canvasUI?.openRail();
2378
+ if (owner) showStreet(owner, key);
2229
2379
  },
2230
2380
  onPickHall: () => {
2231
2381
  if (current.level === 'site') goUp();
@@ -2242,8 +2392,10 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2242
2392
  district.setSky(SKY_MODES[skyIndex].value);
2243
2393
  scene.setPaused(true);
2244
2394
  if (districtCode !== business.code || !district.isOpen()) {
2395
+ district.setViewInset({ left: pulseInset() });
2245
2396
  district.show(business, work, { neighbours: new Map(knownBusinesses.map((entry) => [entry.code, entry.name])), exits: stationsFor(business.code) });
2246
2397
  districtCode = business.code;
2398
+ if (current.street !== null) district.enterStreet(current.street);
2247
2399
  const growth = growthFor(business.code) ?? noteGrowth(business.code, work, readSnapshot(business.code));
2248
2400
  district.celebrate(growth?.changes ?? null);
2249
2401
  }
@@ -2270,12 +2422,18 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2270
2422
  if (current.code !== business.code) return work;
2271
2423
  if (current.level !== 'world') updateDistrictNotes(work);
2272
2424
  scene?.showWork(business.code, work);
2425
+ refreshPulse();
2273
2426
  if (current.level !== 'world') {
2274
2427
  if (districtCode === business.code && district?.isOpen()) {
2275
2428
  district.refresh(business, work, { neighbours: new Map(knownBusinesses.map((entry) => [entry.code, entry.name])), exits: stationsFor(business.code) });
2276
2429
  district.focus(focusIdsFor(work, current.focus));
2277
2430
  } else enterDistrict(business, work);
2278
2431
  }
2432
+ if (current.pendingStreet !== null && current.level !== 'world') {
2433
+ const street = current.pendingStreet;
2434
+ current.pendingStreet = null;
2435
+ showStreet(business, street);
2436
+ }
2279
2437
  if (current.pendingSite && current.level !== 'world') {
2280
2438
  const siteId = current.pendingSite;
2281
2439
  current.pendingSite = null;
@@ -2290,8 +2448,10 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2290
2448
  function openCity(business, center, { zoom = 2.8 } = {}) {
2291
2449
  canvasUI?.closeTask();
2292
2450
  current.pendingSite = null;
2451
+ current.pendingStreet = null;
2293
2452
  if (current.code !== business.code) {
2294
2453
  current.focus = null;
2454
+ current.street = null;
2295
2455
  current.exitId = null;
2296
2456
  leaveDistrict();
2297
2457
  }
@@ -2300,8 +2460,10 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2300
2460
  const work = workCache.get(business.code);
2301
2461
  updateDistrictNotes(work ?? null);
2302
2462
  if (districtCode === business.code && district?.isOpen()) {
2303
- if (!canvasMode) district.home();
2304
- else district.clearSelection();
2463
+ // Close to a street the view stays there; otherwise the standard presentation steps back to the gate.
2464
+ if (current.street !== null || canvasMode) district.clearSelection();
2465
+ else district.home();
2466
+ if (current.street !== null && !canvasMode) district.enterStreet(current.street);
2305
2467
  district.focus(focusIdsFor(work, current.focus));
2306
2468
  } else {
2307
2469
  if (center) scene?.flyTo(new THREE.Vector3(center.x, 0, center.z), zoom);
@@ -2362,6 +2524,11 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2362
2524
  function goToWorld() {
2363
2525
  canvasUI?.closeTask();
2364
2526
  current.pendingSite = null;
2527
+ current.pendingStreet = null;
2528
+ if (current.street !== null) {
2529
+ current.street = null;
2530
+ current.focus = null;
2531
+ }
2365
2532
  leaveDistrict();
2366
2533
  setLevel('world');
2367
2534
  if (current.code) {
@@ -2380,6 +2547,8 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2380
2547
  scene?.clearSelection();
2381
2548
  canvasUI?.closeTask();
2382
2549
  current.pendingSite = null;
2550
+ current.pendingStreet = null;
2551
+ current.street = null;
2383
2552
  setCurrent(null, null);
2384
2553
  setLevel('world');
2385
2554
  current.focus = null;
@@ -2387,7 +2556,7 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2387
2556
  showEmptyRail();
2388
2557
  }
2389
2558
 
2390
- /** One level up: a work site → its district, a district → the whole world (city kept), the world → nothing selected. */
2559
+ /** One level up: a work site → its street or district, a street → its district, a district → the whole world (city kept), the world → nothing selected. */
2391
2560
  function goUp() {
2392
2561
  const business = current.code ? businessOf(current.code) : null;
2393
2562
  if (business && current.level === 'site') {
@@ -2396,6 +2565,10 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2396
2565
  openCity(business, null);
2397
2566
  return;
2398
2567
  }
2568
+ if (business && current.level === 'city' && current.street !== null) {
2569
+ leaveStreet();
2570
+ return;
2571
+ }
2399
2572
  if (business && current.level === 'city') {
2400
2573
  goToWorld();
2401
2574
  return;
@@ -2411,6 +2584,8 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2411
2584
  if (!business) return;
2412
2585
  const picked = scene?.selectKey({ code: business.code });
2413
2586
  openCity(business, picked?.center ?? null);
2587
+ current.pendingStreet = typeof saved.street === 'string' ? saved.street : null;
2588
+ if (current.pendingStreet !== null && showStreet(business, current.pendingStreet)) current.pendingStreet = null;
2414
2589
  current.pendingSite = saved.site ?? null;
2415
2590
  if (current.pendingSite && openSiteById(business, current.pendingSite)) current.pendingSite = null;
2416
2591
  }
@@ -2424,6 +2599,7 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2424
2599
  }
2425
2600
  if (result.data?.status === 'not_connected') {
2426
2601
  workConnected = false;
2602
+ refreshPulse();
2427
2603
  note('仕事', 'この画面はタスクの正本に接続していないため、都市の中の仕事は描いていません(0件とは確認できません)。', 'warning', '仕事:未接続(0件とは確認できません)');
2428
2604
  return;
2429
2605
  }
@@ -2438,6 +2614,7 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2438
2614
  if (!summaries[business.code]) summaries[business.code] = { state: 'unavailable', reason: 'summary_missing', open: null, needs_check: null };
2439
2615
  }
2440
2616
  workSummaries = summaries;
2617
+ refreshPulse();
2441
2618
  if (current.level === 'world' && !current.code) showEmptyRail();
2442
2619
  scene?.setWorkSigns(summaries);
2443
2620
  const entries = Object.values(summaries);
@@ -2689,6 +2866,8 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2689
2866
  const exitSlot = exitsEnabled ? fallbackExitSlot : null;
2690
2867
  if (canvasMode) {
2691
2868
  renderFallbackList(doc, stage, businesses, rows, exitSlot);
2869
+ pulseReady = true;
2870
+ refreshPulse();
2692
2871
  showEmptyRail();
2693
2872
  restoreSelection();
2694
2873
  void loadWorkSummary(note);
@@ -2705,6 +2884,9 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2705
2884
  scene.buildCities(layoutWorld(businesses), placement.byBusiness);
2706
2885
  showChangesSinceLastVisit(note, businesses, rows);
2707
2886
  knownBusinesses = businesses;
2887
+ pulseReady = true;
2888
+ refreshPulse();
2889
+ applyPulseInset();
2708
2890
  if (!current.code) showEmptyRail();
2709
2891
  restoreSelection();
2710
2892
  void loadWorkSummary(note);
@@ -2753,6 +2935,7 @@ export function createWorldView({ root, rail, page, presentation = 'standard', d
2753
2935
  return {
2754
2936
  dispose() {
2755
2937
  disposed = true;
2938
+ clearInterval(pulseTimer);
2756
2939
  doc.removeEventListener?.('visibilitychange', onVisible);
2757
2940
  wrap.removeEventListener?.('keydown', onRootEscape, true);
2758
2941
  canvasUI?.dispose();