fsanyoto commited on
Commit
4bda856
·
verified ·
1 Parent(s): c1cbe44

Deploy AIOS web (React glide grid + FastAPI slice)

Browse files
RELEASES.json CHANGED
@@ -1,4 +1,4 @@
1
  {
2
- "current": "e2341f6a",
3
  "releases": []
4
  }
 
1
  {
2
+ "current": "1e8b01be",
3
  "releases": []
4
  }
VERSION CHANGED
@@ -1 +1 @@
1
- e2341f6a
 
1
+ 1e8b01be
api/routes_query.py CHANGED
@@ -1692,7 +1692,11 @@ def _public_state(state, session):
1692
 
1693
 
1694
  @router.get("/query")
1695
- def list_queries(session: Session = Depends(require_session)):
 
 
 
 
1696
  return _public_state(_state(session), session)
1697
 
1698
 
@@ -2350,8 +2354,20 @@ def _artifact_actions(item):
2350
  return actions
2351
 
2352
 
2353
- def _artifact_rows(session):
2354
- views = _public_state(_state(session), session)["views"]
 
 
 
 
 
 
 
 
 
 
 
 
2355
  by_ref = {view["id"]: view for view in views}
2356
  seen, rows = set(), []
2357
  for item in _recorded_artifacts(session):
@@ -2383,6 +2399,10 @@ def _artifact_rows(session):
2383
  @router.get("/artifacts")
2384
  def list_artifacts(cursor: str = None, limit: int = 50, session: Session = Depends(require_session)):
2385
  rows = _artifact_rows(session)
 
 
 
 
2386
  if cursor:
2387
  try:
2388
  owner, at, item_id = json.loads(base64.urlsafe_b64decode(cursor.encode()).decode())
@@ -2418,22 +2438,48 @@ def _artifact_item(session, item_id):
2418
  return item
2419
 
2420
 
2421
- @router.get("/artifacts/{id}/snapshot")
2422
- def get_artifact_snapshot(id: str, session: Session = Depends(require_session)):
 
 
 
2423
  import artifact_snapshot
2424
- row = _artifact_item(session, id)
2425
- if row.get("kind") != "snapshot" or row.get("status") != "active":
2426
- raise err(404, "unknown_artifact", "That snapshot does not exist.")
2427
  sources = assistant_artifacts.c7(row)["sources"]
2428
  if sources is None:
2429
  raise err(403, "assistant_forbidden", "Your current permissions do not allow this snapshot.")
2430
  for database in sources:
2431
- if not _source_still_permitted(session, {"database": database}):
2432
  raise err(403, "assistant_forbidden", "Your current permissions do not allow this snapshot.")
2433
  snapshot = assistant_artifacts.read_snapshot(session.runtime, row)
2434
  if snapshot is None:
2435
  raise err(404, "unknown_artifact", "That snapshot does not exist.")
2436
  artifact_snapshot.require_permission(session, sources, snapshot)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2437
  return {"artifact": assistant_artifacts.c7(row),
2438
  "snapshot": {key: value for key, value in snapshot.items() if key != "_authorization"}}
2439
 
 
1692
 
1693
 
1694
  @router.get("/query")
1695
+ def list_queries(session: Session = Depends(require_session), only: str = None):
1696
+ # `?only=views` is the Artifacts page's read: the same visible views, resolving only their own
1697
+ # sources. The default reply stays the full state with every source the picker needs.
1698
+ if only == "views":
1699
+ return {"views": _artifact_rows(session, views_only=True)}
1700
  return _public_state(_state(session), session)
1701
 
1702
 
 
2354
  return actions
2355
 
2356
 
2357
+ def _artifact_rows(session, views_only=False):
2358
+ # ⛔ Resolve only the views' own sources, and none when there are no views: the all-source
2359
+ # batch in `_public_state` opens a mirror cursor per grid. Kept inline because
2360
+ # `verify_loopy_tools` execs this function without its neighbours.
2361
+ stored = list(((_state(session) or {}).get("views") or {}).values())
2362
+ wanted = sorted({row["source"]["database"] for row in stored if isinstance(row.get("source"), dict)
2363
+ and isinstance(row["source"].get("database"), str) and row["source"]["database"]})
2364
+ status = assistant_source_status(session, wanted) if wanted else {}
2365
+ permitted = {key for key, row in status.items() if row["permitted"]}
2366
+ views = sorted((_public_view(row) for row in stored
2367
+ if _source_still_permitted(session, row.get("source"), permitted)),
2368
+ key=lambda row: row["createdAt"], reverse=True)
2369
+ if views_only:
2370
+ return views
2371
  by_ref = {view["id"]: view for view in views}
2372
  seen, rows = set(), []
2373
  for item in _recorded_artifacts(session):
 
2399
  @router.get("/artifacts")
2400
  def list_artifacts(cursor: str = None, limit: int = 50, session: Session = Depends(require_session)):
2401
  rows = _artifact_rows(session)
2402
+ # Never list a snapshot its own route refuses with 403. The filter runs before the page cut.
2403
+ if any(row.get("kind") == "snapshot" for row in rows):
2404
+ refused = _refused_snapshots(session, rows)
2405
+ rows = [row for row in rows if row["id"] not in refused]
2406
  if cursor:
2407
  try:
2408
  owner, at, item_id = json.loads(base64.urlsafe_b64decode(cursor.encode()).decode())
 
2438
  return item
2439
 
2440
 
2441
+ def _snapshot_content(session, row, permitted=None):
2442
+ """Return the sources and frozen content the snapshot route serves for an active snapshot row.
2443
+
2444
+ Raises the route's own 403 or 404. `permitted` is a batch answer from `assistant_source_status`.
2445
+ """
2446
  import artifact_snapshot
 
 
 
2447
  sources = assistant_artifacts.c7(row)["sources"]
2448
  if sources is None:
2449
  raise err(403, "assistant_forbidden", "Your current permissions do not allow this snapshot.")
2450
  for database in sources:
2451
+ if not _source_still_permitted(session, {"database": database}, permitted=permitted):
2452
  raise err(403, "assistant_forbidden", "Your current permissions do not allow this snapshot.")
2453
  snapshot = assistant_artifacts.read_snapshot(session.runtime, row)
2454
  if snapshot is None:
2455
  raise err(404, "unknown_artifact", "That snapshot does not exist.")
2456
  artifact_snapshot.require_permission(session, sources, snapshot)
2457
+ return sources, snapshot
2458
+
2459
+
2460
+ def _refused_snapshots(session, rows):
2461
+ """Ids of the active snapshots in `rows` that the snapshot route answers 403 for."""
2462
+ shots = [row for row in rows if row.get("kind") == "snapshot" and row.get("status") == "active"]
2463
+ wanted = sorted({database for row in shots for database in assistant_artifacts.c7(row)["sources"] or ()})
2464
+ status = assistant_source_status(session, wanted) if wanted else {}
2465
+ permitted = {key for key, row in status.items() if row["permitted"]}
2466
+ refused = set()
2467
+ for row in shots:
2468
+ try:
2469
+ _snapshot_content(session, row, permitted)
2470
+ except Exception as exc: # noqa: BLE001
2471
+ # Only a 403 hides the row. A 404 or a read error leaves it listed, as before.
2472
+ if getattr(exc, "status_code", None) == 403:
2473
+ refused.add(row["id"])
2474
+ return refused
2475
+
2476
+
2477
+ @router.get("/artifacts/{id}/snapshot")
2478
+ def get_artifact_snapshot(id: str, session: Session = Depends(require_session)):
2479
+ row = _artifact_item(session, id)
2480
+ if row.get("kind") != "snapshot" or row.get("status") != "active":
2481
+ raise err(404, "unknown_artifact", "That snapshot does not exist.")
2482
+ _, snapshot = _snapshot_content(session, row)
2483
  return {"artifact": assistant_artifacts.c7(row),
2484
  "snapshot": {key: value for key, value in snapshot.items() if key != "_authorization"}}
2485
 
web/public/AIOS_DEPLOY_RECEIPT CHANGED
@@ -1 +1 @@
1
- fd9f81e8074c49fb460735f53628a3cb93b2e589e5163d90b70473d91cf37bad
 
1
+ 25a1fa4133a390c1d2553844c3a77f32f5464ee841ece6ef7a95439087734a2d
web/src/artifacts/ArtifactsPage.tsx CHANGED
@@ -5,7 +5,7 @@ import { sheetAddressHash } from "../sheet";
5
  import { databaseEntries, dataAddressHash } from "../shell/nav";
6
  import type { NavEntry } from "../shell/nav";
7
  import { QueryRail, queryGroups } from "../query/queryParts";
8
- import { call, deleteArtifact, fetchArtifacts, fetchQueries, pauseArtifact, resumeArtifact, runArtifact } from "../query/queryApi";
9
  import type { ArtifactPendingDelete, ArtifactTurnResult, SavedQuery } from "../query/queryApi";
10
  import { ModuleHomeHead } from "../home/ModuleHomeHead";
11
  import WorklistTable, { worklistFigure } from "./WorklistTable";
@@ -162,8 +162,8 @@ export default function ArtifactsPage({ granted }: { granted: NavEntry[] }) {
162
  } finally { inFlight.current = false; setLoading(false); }
163
  }, []);
164
  const loadQueries = useCallback(async () => {
165
- const result = await fetchQueries();
166
- if (result.ok) setViews(result.value.views);
167
  else setProblem(result.message);
168
  }, []);
169
  const refresh = useCallback(() => {
 
5
  import { databaseEntries, dataAddressHash } from "../shell/nav";
6
  import type { NavEntry } from "../shell/nav";
7
  import { QueryRail, queryGroups } from "../query/queryParts";
8
+ import { call, deleteArtifact, fetchArtifacts, fetchQueryViews, pauseArtifact, resumeArtifact, runArtifact } from "../query/queryApi";
9
  import type { ArtifactPendingDelete, ArtifactTurnResult, SavedQuery } from "../query/queryApi";
10
  import { ModuleHomeHead } from "../home/ModuleHomeHead";
11
  import WorklistTable, { worklistFigure } from "./WorklistTable";
 
162
  } finally { inFlight.current = false; setLoading(false); }
163
  }, []);
164
  const loadQueries = useCallback(async () => {
165
+ const result = await fetchQueryViews();
166
+ if (result.ok) setViews(result.value);
167
  else setProblem(result.message);
168
  }, []);
169
  const refresh = useCallback(() => {
web/src/assistant/OpenInPlace.tsx CHANGED
@@ -1,7 +1,6 @@
1
  // S72-T14 (R113, C3): a link in an answer opens one large centred pop-up that hosts the real
2
  // module. The pop-up never reads or writes `location.hash`, so the chat stays at `#/assistant`.
3
- // ⛔ No CSS import here: NoticeCard and PingCard import this file, and `verify_alerts` loads
4
- // NoticeCard under Node with no `.css` loader. The host's mount point imports the stylesheet.
5
  import {
6
  Component, createContext, lazy, Suspense, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState,
7
  } from "react";
 
1
  // S72-T14 (R113, C3): a link in an answer opens one large centred pop-up that hosts the real
2
  // module. The pop-up never reads or writes `location.hash`, so the chat stays at `#/assistant`.
3
+ // The host's mount point (AssistantPage.tsx) imports `styles/sdlc72/open-in-place.css`.
 
4
  import {
5
  Component, createContext, lazy, Suspense, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState,
6
  } from "react";
web/src/query/queryApi.ts CHANGED
@@ -551,6 +551,16 @@ export function fetchQueries(): Promise<Result<QueryIndex>> {
551
  return call("/query", {}, parseIndex);
552
  }
553
 
 
 
 
 
 
 
 
 
 
 
554
  export function submitChat(body: {
555
  question: string; database: string; sources: string[]; threadId?: string; model: string;
556
  }): Promise<Result<ChatResult>> {
 
551
  return call("/query", {}, parseIndex);
552
  }
553
 
554
+ // The Artifacts page needs only the saved views. `only=views` skips resolving every source.
555
+ export function parseViews(body: unknown): SavedQuery[] {
556
+ const row = body as Record<string, unknown> | null;
557
+ return rows(row?.views).map(saved).filter((v): v is SavedQuery => !!v);
558
+ }
559
+
560
+ export function fetchQueryViews(): Promise<Result<SavedQuery[]>> {
561
+ return call("/query?only=views", {}, parseViews);
562
+ }
563
+
564
  export function submitChat(body: {
565
  question: string; database: string; sources: string[]; threadId?: string; model: string;
566
  }): Promise<Result<ChatResult>> {