fsanyoto commited on
Commit
bc87642
·
verified ·
1 Parent(s): 6f43354

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "current": "v86 (108bd7510dcd)",
3
  "releases": [
4
  {
5
  "version": "v86",
 
1
  {
2
+ "current": "95f9e8c (95f9e8cec7d1)",
3
  "releases": [
4
  {
5
  "version": "v86",
VERSION CHANGED
@@ -1 +1 @@
1
- v86 (108bd7510dcd)
 
1
+ 95f9e8c (95f9e8cec7d1)
api/external_freshness.py CHANGED
@@ -288,6 +288,8 @@ def snapshot(session, databases):
288
  if not user_tables.materialises(key, st=lent, defn=definitions[key])}
289
  mirror = _mirror_refreshes(session, definitions, mirror_keys) if mirror_keys else {}
290
  facts = {}
 
 
291
  for key in wanted:
292
  fact = {"source_synced_at": None, "source_sync": "never_synced"}
293
  definition = definitions.get(key) or {}
@@ -299,7 +301,9 @@ def snapshot(session, databases):
299
  health = definition.get(user_tables.CONNECTOR_HEALTH_FIELD) or {}
300
  job = receipts.get(key) or {}
301
  successes = [health.get("lastSuccess")]
302
- if key in odoo_keys:
 
 
303
  successes.append(odoo.get("lastGoodSyncAt"))
304
  if job.get("state") == "ready":
305
  successes.append(job.get("at"))
@@ -311,7 +315,7 @@ def snapshot(session, databases):
311
  elif synced_on is not None:
312
  fact.update(source_synced_on=synced_on, source_sync="synced_date_only",
313
  source_sync_reason="The source reports only a sync date, without a time.")
314
- elif (health.get("state") == "failed" or job.get("state") == "failed"
315
  or key in odoo_keys and odoo.get("phase") == "error"):
316
  fact["source_sync_reason"] = "The connector's latest sync failed before a successful sync was recorded."
317
  elif (job.get("state") in {"queued", "syncing", "configured", "catalogue-ready"}
 
288
  if not user_tables.materialises(key, st=lent, defn=definitions[key])}
289
  mirror = _mirror_refreshes(session, definitions, mirror_keys) if mirror_keys else {}
290
  facts = {}
291
+ odoo_failed = {str(item.get("key")) for item in (odoo.get("failedDatabases") or ())
292
+ if isinstance(item, dict) and item.get("key")}
293
  for key in wanted:
294
  fact = {"source_synced_at": None, "source_sync": "never_synced"}
295
  definition = definitions.get(key) or {}
 
301
  health = definition.get(user_tables.CONNECTOR_HEALTH_FIELD) or {}
302
  job = receipts.get(key) or {}
303
  successes = [health.get("lastSuccess")]
304
+ # D-2679: a database that failed by itself never borrows the connector's good sync.
305
+ own_failed = health.get("state") == "failed" or key in odoo_failed
306
+ if key in odoo_keys and not own_failed:
307
  successes.append(odoo.get("lastGoodSyncAt"))
308
  if job.get("state") == "ready":
309
  successes.append(job.get("at"))
 
315
  elif synced_on is not None:
316
  fact.update(source_synced_on=synced_on, source_sync="synced_date_only",
317
  source_sync_reason="The source reports only a sync date, without a time.")
318
+ elif (own_failed or job.get("state") == "failed"
319
  or key in odoo_keys and odoo.get("phase") == "error"):
320
  fact["source_sync_reason"] = "The connector's latest sync failed before a successful sync was recorded."
321
  elif (job.get("state") in {"queued", "syncing", "configured", "catalogue-ready"}
api/main.py CHANGED
@@ -1967,6 +1967,7 @@ def _rebuild_odoo_relational(why, previous_meta_fingerprint=None, meta_state_out
1967
  if not reports:
1968
  reports = {default_cid: counts or {}}
1969
  any_connection_failed = False
 
1970
  from datetime import datetime as _datetime, timezone as _timezone
1971
  refreshed_at = _datetime.now(_timezone.utc).isoformat()
1972
  for cid, report in reports.items():
@@ -1980,23 +1981,30 @@ def _rebuild_odoo_relational(why, previous_meta_fingerprint=None, meta_state_out
1980
  _rt, cid, _rel.health_view(report)))
1981
  failure = (routes_connectors._odoo_failure(failed, "materialization")
1982
  if failed else None)
 
 
 
 
 
 
 
 
 
 
 
 
 
1983
  # S67-T19: count drift within tolerance is recorded per database (below) and does not
1984
  # fail the connection; a real failure or a stale mirror's gap still does.
1985
- if not failure and (_rel.blocking_failures(database_failures, report)
1986
- or unmatched_failures):
1987
  failure = routes_connectors._odoo_failure(
1988
  "one or more databases failed", "materialization")
1989
- tables = report.get("tables") if isinstance(report.get("tables"), dict) else {}
1990
  for key, delta in sorted(tables.items()):
1991
  if isinstance(delta, dict):
1992
  print(f"[aios-api] odoo relational table rebuilt ({why}): {key} "
1993
  + str({name: delta.get(name, 0)
1994
  for name in ("added", "updated", "removed")}))
1995
- database_receipts = report.get("databases")
1996
- database_receipts = database_receipts if isinstance(database_receipts, dict) else {}
1997
- canonical_receipts = report.get("canonicalDatabases")
1998
- canonical_receipts = canonical_receipts if isinstance(canonical_receipts, dict) else {}
1999
- all_receipts = {**database_receipts, **canonical_receipts}
2000
  if failure:
2001
  any_connection_failed = True
2002
  _health(cid, "materialization", "failed", failure=failure)
@@ -2007,10 +2015,6 @@ def _rebuild_odoo_relational(why, previous_meta_fingerprint=None, meta_state_out
2007
  # A named connection's rebuild is its pull. The default's source stamp is the published mirror pass.
2008
  _health(cid, "source", "ready")
2009
  _health(cid, "materialization", "ready")
2010
- # A receipt is the authoritative per-database result. ``tables`` alone omits
2011
- # read-through grains and the two compiled canonical databases, which previously
2012
- # made their rich reconciliation evidence disappear at this scheduler boundary.
2013
- database_keys = list(dict.fromkeys([*all_receipts, *tables]))
2014
  for key in database_keys:
2015
  table_counts = tables.get(key)
2016
  if key in database_failures:
@@ -2065,8 +2069,27 @@ def _rebuild_odoo_relational(why, previous_meta_fingerprint=None, meta_state_out
2065
  # S67-T20 / C4: the tenant-wide freshness stamp follows the DEFAULT connection, the
2066
  # one this mirror serves. Best effort: a stamp must never fail the rebuild it records.
2067
  if cid == str(default_cid):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2068
  try:
2069
- _rel.record_sync_outcome(_rt, ok=not safe_errors, at=refreshed_at)
 
2070
  except Exception: # noqa: BLE001
2071
  pass
2072
  meta_state = _rebuild_meta_relational(
@@ -2080,7 +2103,8 @@ def _rebuild_odoo_relational(why, previous_meta_fingerprint=None, meta_state_out
2080
  # The isolated cells/rollups/meta handlers above are deliberately allowed to report and
2081
  # continue. This return value answers the narrower resync-policy question: did the Odoo
2082
  # table refresh itself complete, so a confirmed zero-change pass may be skipped?
2083
- return not any_connection_failed and not rebuild_errors
 
2084
  except Exception as e: # noqa: BLE001
2085
  # ⚠ The TYPE is named here as it is in the two inner handlers. The original printed only
2086
  # `{e}`, and a bare message is exactly what made D-107 unreadable from the outside: a
 
1967
  if not reports:
1968
  reports = {default_cid: counts or {}}
1969
  any_connection_failed = False
1970
+ any_database_failed = False
1971
  from datetime import datetime as _datetime, timezone as _timezone
1972
  refreshed_at = _datetime.now(_timezone.utc).isoformat()
1973
  for cid, report in reports.items():
 
1981
  _rt, cid, _rel.health_view(report)))
1982
  failure = (routes_connectors._odoo_failure(failed, "materialization")
1983
  if failed else None)
1984
+ tables = report.get("tables") if isinstance(report.get("tables"), dict) else {}
1985
+ database_receipts = report.get("databases")
1986
+ database_receipts = database_receipts if isinstance(database_receipts, dict) else {}
1987
+ canonical_receipts = report.get("canonicalDatabases")
1988
+ canonical_receipts = canonical_receipts if isinstance(canonical_receipts, dict) else {}
1989
+ all_receipts = {**database_receipts, **canonical_receipts}
1990
+ # A receipt is the authoritative per-database result. ``tables`` alone omits
1991
+ # read-through grains and the two compiled canonical databases, which previously
1992
+ # made their rich reconciliation evidence disappear at this scheduler boundary.
1993
+ database_keys = list(dict.fromkeys([*all_receipts, *tables]))
1994
+ blocking = _rel.blocking_failures(database_failures, report)
1995
+ succeeded = [key for key in database_keys if key not in database_failures]
1996
+ any_database_failed = any_database_failed or bool(blocking)
1997
  # S67-T19: count drift within tolerance is recorded per database (below) and does not
1998
  # fail the connection; a real failure or a stale mirror's gap still does.
1999
+ # D-2679: a named database failure stays on that database while a sibling succeeded.
2000
+ if not failure and (unmatched_failures or (blocking and not succeeded)):
2001
  failure = routes_connectors._odoo_failure(
2002
  "one or more databases failed", "materialization")
 
2003
  for key, delta in sorted(tables.items()):
2004
  if isinstance(delta, dict):
2005
  print(f"[aios-api] odoo relational table rebuilt ({why}): {key} "
2006
  + str({name: delta.get(name, 0)
2007
  for name in ("added", "updated", "removed")}))
 
 
 
 
 
2008
  if failure:
2009
  any_connection_failed = True
2010
  _health(cid, "materialization", "failed", failure=failure)
 
2015
  # A named connection's rebuild is its pull. The default's source stamp is the published mirror pass.
2016
  _health(cid, "source", "ready")
2017
  _health(cid, "materialization", "ready")
 
 
 
 
2018
  for key in database_keys:
2019
  table_counts = tables.get(key)
2020
  if key in database_failures:
 
2069
  # S67-T20 / C4: the tenant-wide freshness stamp follows the DEFAULT connection, the
2070
  # one this mirror serves. Best effort: a stamp must never fail the rebuild it records.
2071
  if cid == str(default_cid):
2072
+ # D-2679: a good sync still names the databases that failed by themselves.
2073
+ failed_databases = None if safe_errors else [
2074
+ {"key": key, "code": db_failure.get("code"),
2075
+ "stage": db_failure.get("stage"), "at": refreshed_at,
2076
+ "message": routes_connectors._DATABASE_SAFE_ERRORS.get(
2077
+ str(db_failure.get("code") or ""))
2078
+ or routes_connectors._odoo_failure(
2079
+ None, str(db_failure.get("stage") or "materialization"))["message"]}
2080
+ for key, db_failure in blocking.items() if isinstance(db_failure, dict)]
2081
+ if failed_databases is not None and table_keys is not None:
2082
+ # D-2679: a changed-tables pass keeps the failures of databases it did not run.
2083
+ try:
2084
+ prior = (_rt.get(_rel.CONFIG_KEY) or {}).get("failedDatabases") or []
2085
+ except Exception: # noqa: BLE001
2086
+ prior = []
2087
+ failed_databases = [
2088
+ item for item in prior if isinstance(item, dict)
2089
+ and item.get("key") not in database_keys] + failed_databases
2090
  try:
2091
+ _rel.record_sync_outcome(_rt, ok=not safe_errors, at=refreshed_at,
2092
+ failed_databases=failed_databases)
2093
  except Exception: # noqa: BLE001
2094
  pass
2095
  meta_state = _rebuild_meta_relational(
 
2103
  # The isolated cells/rollups/meta handlers above are deliberately allowed to report and
2104
  # continue. This return value answers the narrower resync-policy question: did the Odoo
2105
  # table refresh itself complete, so a confirmed zero-change pass may be skipped?
2106
+ # D-2679: a database that failed alone still forces the next full pass to retry it.
2107
+ return not any_connection_failed and not any_database_failed and not rebuild_errors
2108
  except Exception as e: # noqa: BLE001
2109
  # ⚠ The TYPE is named here as it is in the two inner handlers. The original printed only
2110
  # `{e}`, and a bare message is exactly what made D-107 unreadable from the outside: a
api/odoo_relational.py CHANGED
@@ -5665,20 +5665,50 @@ def _parse_iso(value):
5665
  return at if at.tzinfo else at.replace(tzinfo=_dt.timezone.utc)
5666
 
5667
 
5668
- def record_sync_outcome(rt, ok, at=None):
5669
  """Stamp this tenant's last sync, and its last GOOD sync when `ok`, on the connector's config.
5670
 
5671
  ⛔ ON THE CONFIG DOCUMENT, NOT ON `odoo_sync_status`, because that document is REPLACED whole
5672
  on every phase write (`core.user_tables.record_odoo_sync_status`), so a stamp kept there would
5673
  be erased by the next `syncing`. Every writer of this config document updates it in place.
 
5674
  """
5675
  stamp = at or _utc_now().isoformat()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5676
 
5677
  def _up(cur):
5678
  cur = dict(cur) if isinstance(cur, dict) else {}
5679
  cur["lastSyncAt"] = stamp
5680
  if ok:
5681
  cur["lastGoodSyncAt"] = stamp
 
 
5682
  return cur
5683
 
5684
  rt.update(CONFIG_KEY, _up, flush="sync")
@@ -5888,7 +5918,16 @@ def sync_freshness(rt, now=None):
5888
  code, message = "sync_failed", text
5889
  failure = {"code": code.strip()[:80], "message": message.strip()[:300],
5890
  "at": status.get("lastRun") or None}
 
 
 
 
 
 
 
 
5891
  return {"stale": bool(stale), "lastGoodSyncAt": last_good,
 
5892
  "schedule": cfg["syncEvery"], "staleAfterSeconds": allowed,
5893
  "lastRunAt": status.get("lastRun") or None, "phase": phase,
5894
  "frozen": cfg["frozen"], "failure": failure,
@@ -6205,7 +6244,8 @@ def require_shipments_mirror(cur):
6205
  """Refuse incomplete shipment rows, dependencies or column backfills."""
6206
  from harness import datastore
6207
  spec = datastore.ENTITIES["stock_picking"]
6208
- required = {column.split()[0] for column in datastore._cols(spec)}
 
6209
  if (not required <= datastore.columns_of("stock_picking", cur=cur)
6210
  or not {"id", "name", "date_order"} <= datastore.columns_of("sale_order", cur=cur)
6211
  or not {"entity", "phase", "updated_at"} <= datastore.columns_of("_sync_state", cur=cur)):
 
5665
  return at if at.tzinfo else at.replace(tzinfo=_dt.timezone.utc)
5666
 
5667
 
5668
+ def record_sync_outcome(rt, ok, at=None, failed_databases=None):
5669
  """Stamp this tenant's last sync, and its last GOOD sync when `ok`, on the connector's config.
5670
 
5671
  ⛔ ON THE CONFIG DOCUMENT, NOT ON `odoo_sync_status`, because that document is REPLACED whole
5672
  on every phase write (`core.user_tables.record_odoo_sync_status`), so a stamp kept there would
5673
  be erased by the next `syncing`. Every writer of this config document updates it in place.
5674
+ D-2679: `failedDatabases` is rewritten only when a list is given; `None` keeps the stored one.
5675
  """
5676
  stamp = at or _utc_now().isoformat()
5677
+ labels = {key: label for _bucket, key, label, _fields in TABLES}
5678
+
5679
+ def _label(key):
5680
+ if labels.get(key):
5681
+ return labels[key]
5682
+ try:
5683
+ defn = _ut().get_definition(key, st=rt)
5684
+ except Exception: # noqa: BLE001
5685
+ defn = None
5686
+ return str(defn.get("label") or key) if isinstance(defn, dict) else key
5687
+
5688
+ def _plain(text, limit):
5689
+ # Rule 2: no em or en dash reaches the screen.
5690
+ return " ".join(str(text or "").replace("—", ",").replace("–", ",").split())[:limit]
5691
+
5692
+ failed = []
5693
+ for item in failed_databases or ():
5694
+ item = item if isinstance(item, dict) else {"key": item}
5695
+ key = str(item.get("key") or "").strip()
5696
+ if not key:
5697
+ continue
5698
+ failed.append({"key": key, "label": _plain(item.get("label") or _label(key), 120),
5699
+ "code": _plain(item.get("code") or "materialization_failed", 80),
5700
+ "message": _plain(item.get("message")
5701
+ or "The database could not be materialized.", 300),
5702
+ "stage": _plain(item.get("stage") or "materialization", 40),
5703
+ "at": str(item.get("at") or stamp)})
5704
 
5705
  def _up(cur):
5706
  cur = dict(cur) if isinstance(cur, dict) else {}
5707
  cur["lastSyncAt"] = stamp
5708
  if ok:
5709
  cur["lastGoodSyncAt"] = stamp
5710
+ if failed_databases is not None:
5711
+ cur["failedDatabases"] = failed
5712
  return cur
5713
 
5714
  rt.update(CONFIG_KEY, _up, flush="sync")
 
5918
  code, message = "sync_failed", text
5919
  failure = {"code": code.strip()[:80], "message": message.strip()[:300],
5920
  "at": status.get("lastRun") or None}
5921
+ # D-2679: a database that failed while its siblings synced is reported by itself.
5922
+ failed_databases = []
5923
+ for item in raw.get("failedDatabases") if isinstance(raw.get("failedDatabases"), list) else ():
5924
+ if isinstance(item, dict) and item.get("key"):
5925
+ failed_databases.append({
5926
+ name: (" ".join(str(item.get(name) or "").replace("—", ",")
5927
+ .replace("–", ",").split())[:300] or None)
5928
+ for name in ("key", "label", "code", "message", "stage", "at")})
5929
  return {"stale": bool(stale), "lastGoodSyncAt": last_good,
5930
+ "failedDatabases": failed_databases,
5931
  "schedule": cfg["syncEvery"], "staleAfterSeconds": allowed,
5932
  "lastRunAt": status.get("lastRun") or None, "phase": phase,
5933
  "frozen": cfg["frozen"], "failure": failure,
 
6244
  """Refuse incomplete shipment rows, dependencies or column backfills."""
6245
  from harness import datastore
6246
  spec = datastore.ENTITIES["stock_picking"]
6247
+ # D-2679: `columns_of` lowercases, and `_cols` declares the mixed-case `Store` column.
6248
+ required = {column.split()[0].lower() for column in datastore._cols(spec)}
6249
  if (not required <= datastore.columns_of("stock_picking", cur=cur)
6250
  or not {"id", "name", "date_order"} <= datastore.columns_of("sale_order", cur=cur)
6251
  or not {"entity", "phase", "updated_at"} <= datastore.columns_of("_sync_state", cur=cur)):
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- 1a13c8fe1b5d1438f9fedbe6814f620b6f11294cf546e1b95e0cf286c102c0c8
 
1
+ 933e8dbcdeac5d874c4e75c6e41071e0cb91231d4e925ee7850b24c5940d2ab5
web/src/connectors/ConnectorsPage.tsx CHANGED
@@ -81,6 +81,7 @@ import {
81
  // ⭐ S67-T20 / C4: the freshness READER and its words, never the settings panel. The tombstone
82
  // above still holds: `OdooConfigPanel` stays out of this file.
83
  import {
 
84
  freshnessWarnings,
85
  getOdooFreshness,
86
  nextSyncSlot,
@@ -1434,12 +1435,17 @@ export function ConnectorCard({
1434
  const disabled = row.action === "soon" || row.actionDisabled === true;
1435
  // Every credential action retains the connector identity, including legacy card consumers.
1436
  const open = onOpen ?? onPullReviews ?? (() => onKeychain(row.key));
 
 
1437
  const status = catchUp?.active || catchUp?.behind || catchUpError || catchUpLoading ? (
1438
  <span className="conn-card-status conn-catch-up" role="status">
1439
  {catchUp?.active ? catchUpLabel(catchUp) : catchUpError
1440
  || (catchUp?.behind && !catchUpLoading ? behindLabel(catchUp.behind) : "Checking sync")}
1441
  {catchUp?.active && catchUpError ? `, ${catchUpError}` : ""}
1442
  </span>
 
 
 
1443
  ) : syncWarnings?.length ? (
1444
  <span className="conn-card-status" role="status"
1445
  title={syncWarnings.join(" ").replace(/[\u2013\u2014]/g, ", ")}>Stale</span>
 
81
  // ⭐ S67-T20 / C4: the freshness READER and its words, never the settings panel. The tombstone
82
  // above still holds: `OdooConfigPanel` stays out of this file.
83
  import {
84
+ failedDatabasesStatus,
85
  freshnessWarnings,
86
  getOdooFreshness,
87
  nextSyncSlot,
 
1435
  const disabled = row.action === "soon" || row.actionDisabled === true;
1436
  // Every credential action retains the connector identity, including legacy card consumers.
1437
  const open = onOpen ?? onPullReviews ?? (() => onKeychain(row.key));
1438
+ // D-2679: databases that failed alone are named; a stale connector still reads "Stale".
1439
+ const databasesStale = failedDatabasesStatus(syncWarnings);
1440
  const status = catchUp?.active || catchUp?.behind || catchUpError || catchUpLoading ? (
1441
  <span className="conn-card-status conn-catch-up" role="status">
1442
  {catchUp?.active ? catchUpLabel(catchUp) : catchUpError
1443
  || (catchUp?.behind && !catchUpLoading ? behindLabel(catchUp.behind) : "Checking sync")}
1444
  {catchUp?.active && catchUpError ? `, ${catchUpError}` : ""}
1445
  </span>
1446
+ ) : syncWarnings?.length && databasesStale ? (
1447
+ <span className="conn-card-status" role="status"
1448
+ title={syncWarnings.join("\n").replace(/[\u2013\u2014]/g, ", ")}>{databasesStale}</span>
1449
  ) : syncWarnings?.length ? (
1450
  <span className="conn-card-status" role="status"
1451
  title={syncWarnings.join(" ").replace(/[\u2013\u2014]/g, ", ")}>Stale</span>
web/src/connectors/OdooConfig.tsx CHANGED
@@ -90,6 +90,9 @@ export interface OdooFreshness {
90
  lastRunAt?: string | null;
91
  phase?: string;
92
  failure?: { code?: string; message?: string; at?: string | null } | null;
 
 
 
93
  syncAt?: string | null;
94
  syncTz?: string | null;
95
  nextSyncAt?: string | null;
@@ -125,6 +128,9 @@ export function syncDate(iso: string): string {
125
  });
126
  }
127
 
 
 
 
128
  /** The warning lines for a freshness reading, PURE: none when the data is fresh and the last run
129
  * did not fail, which is the whole of "a fresh sync clears it". */
130
  export function freshnessWarnings(f: OdooFreshness | null | undefined): string[] {
@@ -140,9 +146,28 @@ export function freshnessWarnings(f: OdooFreshness | null | undefined): string[]
140
  }
141
  const reason = (f.failure?.message ?? "").trim();
142
  if (reason) lines.push(`The last Odoo sync failed. ${reason}`);
 
 
 
 
 
143
  return lines;
144
  }
145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  /** One read of the freshness route. Any failure is `null`, never a thrown error: a warning that
147
  * cannot be read must not take the card or the Sync section down with it. */
148
  export async function getOdooFreshness(signal?: AbortSignal): Promise<OdooFreshness | null> {
 
90
  lastRunAt?: string | null;
91
  phase?: string;
92
  failure?: { code?: string; message?: string; at?: string | null } | null;
93
+ /** D-2679: databases that failed while the rest of the sync succeeded. */
94
+ failedDatabases?: { key: string; label?: string | null; code?: string | null; message?: string | null;
95
+ stage?: string | null; at?: string | null }[];
96
  syncAt?: string | null;
97
  syncTz?: string | null;
98
  nextSyncAt?: string | null;
 
128
  });
129
  }
130
 
131
+ /** D-2679: the words that mark a failed database's warning line. */
132
+ const FAILED_DATABASE_LINE = " did not sync.";
133
+
134
  /** The warning lines for a freshness reading, PURE: none when the data is fresh and the last run
135
  * did not fail, which is the whole of "a fresh sync clears it". */
136
  export function freshnessWarnings(f: OdooFreshness | null | undefined): string[] {
 
146
  }
147
  const reason = (f.failure?.message ?? "").trim();
148
  if (reason) lines.push(`The last Odoo sync failed. ${reason}`);
149
+ for (const db of Array.isArray(f.failedDatabases) ? f.failedDatabases : []) {
150
+ const label = (db?.label || db?.key || "").trim();
151
+ const message = (db?.message ?? "").trim();
152
+ if (label) lines.push(`${label}${FAILED_DATABASE_LINE}${message ? ` ${message}` : ""}`);
153
+ }
154
  return lines;
155
  }
156
 
157
+ /** D-2679: the card status when only databases failed, PURE. Empty when any other warning
158
+ * stands, so a stale or failed connector still reads "Stale". */
159
+ export function failedDatabasesStatus(lines: string[] | null | undefined): string {
160
+ const labels: string[] = [];
161
+ for (const line of lines ?? []) {
162
+ const at = line.indexOf(FAILED_DATABASE_LINE);
163
+ if (at <= 0) return "";
164
+ labels.push(line.slice(0, at));
165
+ }
166
+ if (labels.length === 1) return `${labels[0]} stale`;
167
+ if (labels.length === 2) return `${labels[0]} and ${labels[1]} stale`;
168
+ return labels.length ? `${labels.length} databases stale` : "";
169
+ }
170
+
171
  /** One read of the freshness route. Any failure is `null`, never a thrown error: a warning that
172
  * cannot be read must not take the card or the Sync section down with it. */
173
  export async function getOdooFreshness(signal?: AbortSignal): Promise<OdooFreshness | null> {