fsanyoto commited on
Commit
63c0713
·
verified ·
1 Parent(s): dbefc92

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "ac66dbd61035",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "2327609f7652",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- ac66dbd61035
 
1
+ 2327609f7652
api/odoo_relational.py CHANGED
@@ -5945,28 +5945,52 @@ def _slot_on(day, slot, zone):
5945
  return _dt.datetime(day.year, day.month, day.day, hour, minute, tzinfo=zone).timestamp()
5946
 
5947
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5948
  def slot_before(now, slot):
5949
- """The latest occurrence of the slot at or before epoch `now`."""
5950
- zone = sync_zone(slot["tz"])
5951
- day = _dt.datetime.fromtimestamp(float(now), zone).date()
5952
  for back in range(4):
5953
- at = _slot_on(day - _dt.timedelta(days=back), slot, zone)
5954
  if at <= float(now):
5955
  return at
5956
  raise ValueError("no slot occurrence found")
5957
 
5958
 
5959
  def slot_after(now, slot):
5960
- """The first occurrence of the slot strictly after epoch `now`."""
5961
- zone = sync_zone(slot["tz"])
5962
- day = _dt.datetime.fromtimestamp(float(now), zone).date()
5963
  for ahead in range(4):
5964
- at = _slot_on(day + _dt.timedelta(days=ahead), slot, zone)
5965
  if at > float(now):
5966
  return at
5967
  raise ValueError("no slot occurrence found")
5968
 
5969
 
 
 
 
 
 
 
 
 
 
 
5970
  #: A first-load continuation does not start this close to the next slot, so it cannot delay the slot.
5971
  FIRST_LOAD_SLOT_QUIET_SECONDS = 2 * 3600
5972
 
 
5945
  return _dt.datetime(day.year, day.month, day.day, hour, minute, tzinfo=zone).timestamp()
5946
 
5947
 
5948
+ #: ⛔ A staging Space runs every scheduled pass this long after the configured slot, so staging and
5949
+ #: live never call Odoo or SP-API together. A code rule: a staging store reseeded from live keeps it.
5950
+ STAGING_SLOT_OFFSET_SECONDS = 3600
5951
+
5952
+
5953
+ def slot_offset_seconds():
5954
+ """The scheduled-pass shift for this deployment: the staging offset on staging, 0 on live or local."""
5955
+ try:
5956
+ import sync_alerts
5957
+ return STAGING_SLOT_OFFSET_SECONDS if sync_alerts.environment() == "STAGING" else 0
5958
+ except Exception: # noqa: BLE001
5959
+ return 0
5960
+
5961
+
5962
  def slot_before(now, slot):
5963
+ """The latest occurrence of the slot at or before epoch `now`, after this deployment's offset."""
5964
+ zone, shift = sync_zone(slot["tz"]), slot_offset_seconds()
5965
+ day = _dt.datetime.fromtimestamp(float(now) - shift, zone).date()
5966
  for back in range(4):
5967
+ at = _slot_on(day - _dt.timedelta(days=back), slot, zone) + shift
5968
  if at <= float(now):
5969
  return at
5970
  raise ValueError("no slot occurrence found")
5971
 
5972
 
5973
  def slot_after(now, slot):
5974
+ """The first occurrence of the slot strictly after epoch `now`, after this deployment's offset."""
5975
+ zone, shift = sync_zone(slot["tz"]), slot_offset_seconds()
5976
+ day = _dt.datetime.fromtimestamp(float(now) - shift, zone).date()
5977
  for ahead in range(4):
5978
+ at = _slot_on(day + _dt.timedelta(days=ahead), slot, zone) + shift
5979
  if at > float(now):
5980
  return at
5981
  raise ValueError("no slot occurrence found")
5982
 
5983
 
5984
+ def slot_run_clock(at):
5985
+ """The `HH:MM` a configured slot `at` runs at on this deployment, or `at` unchanged when unreadable."""
5986
+ try:
5987
+ hour, minute = (int(part) for part in str(at).split(":"))
5988
+ total = (hour * 60 + minute + slot_offset_seconds() // 60) % 1440
5989
+ return f"{total // 60:02d}:{total % 60:02d}"
5990
+ except Exception: # noqa: BLE001
5991
+ return at
5992
+
5993
+
5994
  #: A first-load continuation does not start this close to the next slot, so it cannot delay the slot.
5995
  FIRST_LOAD_SLOT_QUIET_SECONDS = 2 * 3600
5996
 
api/routes_keychain.py CHANGED
@@ -1856,7 +1856,7 @@ def odoo_config_put(body: dict = Body(default=None),
1856
  notes.append(f"the daily time {saved['syncAt']} {saved['syncTz']} is saved and "
1857
  f"applies when the sync interval is daily")
1858
  else:
1859
- notes.append(f"the Odoo sync runs once a day at {saved['syncAt']} {saved['syncTz']}")
1860
 
1861
  # ⭐⭐ W33-T65 / W30-R6's SECOND SENTENCE — THE CADENCE IS SET AND ONLY PARTLY OBEYED, AND THE
1862
  # PERSON SETTING IT IS THE ONE WHO HAS TO BE TOLD. Measured, not guessed:
 
1856
  notes.append(f"the daily time {saved['syncAt']} {saved['syncTz']} is saved and "
1857
  f"applies when the sync interval is daily")
1858
  else:
1859
+ notes.append(f"the Odoo sync runs once a day at {rel.slot_run_clock(saved['syncAt'])} {saved['syncTz']}")
1860
 
1861
  # ⭐⭐ W33-T65 / W30-R6's SECOND SENTENCE — THE CADENCE IS SET AND ONLY PARTLY OBEYED, AND THE
1862
  # PERSON SETTING IT IS THE ONE WHO HAS TO BE TOLD. Measured, not guessed:
api/test_odoo_rank_refresh.py CHANGED
@@ -1474,6 +1474,45 @@ class RankRefreshTests(unittest.TestCase):
1474
  self.assertEqual(store.docs[key]['phase'], phase)
1475
  self.assertEqual(len(confirmed), 2)
1476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1477
 
1478
  if __name__ == '__main__':
1479
  unittest.main()
 
1474
  self.assertEqual(store.docs[key]['phase'], phase)
1475
  self.assertEqual(len(confirmed), 2)
1476
 
1477
+ def test_staging_runs_every_slot_sixty_minutes_after_live(self):
1478
+ """Owner 11-10: staging's next slot is the configured slot + 60 min, live's is the slot itself"""
1479
+ from datetime import datetime, timezone
1480
+ import odoo_relational as rel
1481
+ now = datetime(2026, 10, 24, 2, 30, tzinfo=timezone.utc)
1482
+ bare = {k: v for k, v in os.environ.items() if k not in ('SPACE_ID', 'APP_BASE_URL')}
1483
+
1484
+ def next_at(**env):
1485
+ with patch.dict(os.environ, {**bare, **env}, clear=True):
1486
+ return (rel.sync_freshness(self.SlotStore('royal-imports'), now=now)['nextSyncAt'],
1487
+ rel.slot_run_clock('13:00'))
1488
+
1489
+ self.assertEqual(next_at(SPACE_ID='fsanyoto/runloopable'), ('2026-10-24T06:00:00Z', '13:00'))
1490
+ self.assertEqual(next_at(), ('2026-10-24T06:00:00Z', '13:00'))
1491
+ self.assertEqual(next_at(SPACE_ID='fsanyoto/loopable'), ('2026-10-24T07:00:00Z', '14:00'))
1492
+ self.assertEqual(next_at(APP_BASE_URL='https://fsanyoto-loopable.hf.space'),
1493
+ ('2026-10-24T07:00:00Z', '14:00'))
1494
+ # A slot near midnight crosses the day on staging and is never skipped.
1495
+ late = self.SlotStore('acme', {rel.CONFIG_KEY: {'syncAt': '23:30', 'syncTz': 'UTC'}})
1496
+ with patch.dict(os.environ, {**bare, 'SPACE_ID': 'fsanyoto/loopable'}, clear=True):
1497
+ self.assertEqual(rel.sync_freshness(late, now=datetime(2026, 10, 25, 0, 10, tzinfo=timezone.utc))
1498
+ ['nextSyncAt'], '2026-10-25T00:30:00Z')
1499
+ self.assertEqual(rel.slot_before(self.utc('2026-10-25T00:10:00Z'), rel.sync_slot(
1500
+ late.docs[rel.CONFIG_KEY] | {'syncEvery': 'daily'})), self.utc('2026-10-24T00:30:00Z'))
1501
+ # The real loop booted at 05:50Z on each Space: live's first Odoo pass is 06:00Z, staging's 07:00Z.
1502
+ import process_role
1503
+ last, firsts = self.utc('2026-10-23T07:05:00Z'), {}
1504
+ for space in ('fsanyoto/runloopable', 'fsanyoto/loopable'):
1505
+ with patch.dict(os.environ, {**bare, 'SPACE_ID': space}, clear=True), \
1506
+ patch.object(process_role, 'may_write', return_value=True):
1507
+ _events, _sleeps, odoo = self.run_slot_loop(
1508
+ {'passAt': last, 'fullRebuildAt': last, 'fingerprints': {'res_partner': (3, 7)}},
1509
+ boot=self.utc('2026-10-24T05:50:00Z'), max_sleeps=90)
1510
+ firsts[space] = odoo[0][1] if odoo else None
1511
+ self.assertTrue(firsts['fsanyoto/runloopable'] is not None and
1512
+ 0 <= firsts['fsanyoto/runloopable'] - self.utc('2026-10-24T06:00:00Z') <= 1, firsts)
1513
+ self.assertTrue(firsts['fsanyoto/loopable'] is not None and
1514
+ 0 <= firsts['fsanyoto/loopable'] - self.utc('2026-10-24T07:00:00Z') <= 1, firsts)
1515
+
1516
 
1517
  if __name__ == '__main__':
1518
  unittest.main()
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 25fc10c1d8940fd073f8cd9ca18c3d5c620eae250c96963b2892518f75c59f50
 
1
+ 00bbfce124d0d2cb5f43ff31efb36f82850e24bc6b42e669cfc26d6a376a8d96
web/src/connectors/OdooConfig.tsx CHANGED
@@ -140,10 +140,25 @@ export function syncSlotLabel(syncAt?: string | null, syncTz?: string | null): s
140
  return `${clock} (${city})`;
141
  }
142
 
143
- /** The slot label only while a next sync is scheduled, so a manual tenant reads today's copy. */
 
144
  export function nextSyncSlot(f: { syncAt?: string | null; syncTz?: string | null; nextSyncAt?: string | null }
145
  | null | undefined): string {
146
- return f && typeof f.nextSyncAt === "string" && f.nextSyncAt ? syncSlotLabel(f.syncAt, f.syncTz) : "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  }
148
 
149
  /** A sync time the way a person reads it: "Sep 27, 2026, 6:25 AM". An unreadable value is shown
@@ -373,7 +388,7 @@ export function OdooSyncEvery() {
373
  const storedAt = slotValue(cfg?.syncAt);
374
  const storedTz = cfg?.syncTz ?? "";
375
  const dirty = daily && (draftAt !== storedAt || draftTz !== storedTz);
376
- const summary = syncSlotLabel(cfg?.syncAt, cfg?.syncTz);
377
  const zones = useMemo(() => zoneOptions(cfg?.syncTz, draftTz), [cfg?.syncTz, draftTz]);
378
  const locked = !cfg || busy || !!cfg.frozen;
379
 
 
140
  return `${clock} (${city})`;
141
  }
142
 
143
+ /** The slot label only while a next sync is scheduled, so a manual tenant reads today's copy.
144
+ * Reads the clock of `nextSyncAt` in the slot's zone, so a staging pass run an hour late reads true. */
145
  export function nextSyncSlot(f: { syncAt?: string | null; syncTz?: string | null; nextSyncAt?: string | null }
146
  | null | undefined): string {
147
+ if (!f || typeof f.nextSyncAt !== "string" || !f.nextSyncAt) return "";
148
+ const at = new Date(f.nextSyncAt);
149
+ const zone = (f.syncTz ?? "").trim();
150
+ if (zone && !Number.isNaN(at.getTime())) {
151
+ try {
152
+ const clock = new Intl.DateTimeFormat("en-GB", {
153
+ timeZone: zone, hour: "2-digit", minute: "2-digit", hourCycle: "h23",
154
+ }).format(at);
155
+ const label = syncSlotLabel(clock, zone);
156
+ if (label) return label;
157
+ } catch {
158
+ // A zone the browser cannot read keeps the stored clock.
159
+ }
160
+ }
161
+ return syncSlotLabel(f.syncAt, f.syncTz);
162
  }
163
 
164
  /** A sync time the way a person reads it: "Sep 27, 2026, 6:25 AM". An unreadable value is shown
 
388
  const storedAt = slotValue(cfg?.syncAt);
389
  const storedTz = cfg?.syncTz ?? "";
390
  const dirty = daily && (draftAt !== storedAt || draftTz !== storedTz);
391
+ const summary = nextSyncSlot(cfg) || syncSlotLabel(cfg?.syncAt, cfg?.syncTz);
392
  const zones = useMemo(() => zoneOptions(cfg?.syncTz, draftTz), [cfg?.syncTz, draftTz]);
393
  const locked = !cfg || busy || !!cfg.frozen;
394