fix(ui): scope spatial tools to scene
This commit is contained in:
@@ -175,10 +175,7 @@ class SessionStore:
|
||||
).fetchone()
|
||||
if cursor_row is None:
|
||||
raise SessionNotFoundError("observation session cursor was not found")
|
||||
where = (
|
||||
"WHERE (COALESCE(started_at_utc, ''), session_id) < "
|
||||
"(COALESCE(?, ''), ?)"
|
||||
)
|
||||
where = "WHERE (COALESCE(started_at_utc, ''), session_id) < (COALESCE(?, ''), ?)"
|
||||
parameters.extend((cursor_row["started_at_utc"], cursor_row["session_id"]))
|
||||
parameters.append(limit + 1)
|
||||
rows = connection.execute(
|
||||
@@ -309,8 +306,7 @@ class SessionStore:
|
||||
_validate_identifier(session_id, "session id")
|
||||
with self._connect() as connection:
|
||||
session = connection.execute(
|
||||
"SELECT allowed_root, session_root FROM observation_sessions "
|
||||
"WHERE session_id = ?",
|
||||
"SELECT allowed_root, session_root FROM observation_sessions WHERE session_id = ?",
|
||||
(session_id,),
|
||||
).fetchone()
|
||||
if session is None:
|
||||
@@ -372,8 +368,8 @@ class SessionStore:
|
||||
layout: dict[str, Any],
|
||||
) -> WorkspaceLayout:
|
||||
_validate_identifier(workspace_id, "workspace id")
|
||||
if schema_version != 1:
|
||||
raise ValueError("only workspace layout schema version 1 is supported")
|
||||
if schema_version not in {1, 2}:
|
||||
raise ValueError("workspace layout schema version is unsupported")
|
||||
if expected_revision < 0:
|
||||
raise ValueError("expected revision must be non-negative")
|
||||
normalized_name = name.strip()
|
||||
@@ -423,9 +419,9 @@ class SessionStore:
|
||||
def _initialize(self) -> None:
|
||||
with self._connect() as connection:
|
||||
connection.executescript(SCHEMA_SQL)
|
||||
self._migrate_transient_tool_windows(connection)
|
||||
session_columns = {
|
||||
row["name"]
|
||||
for row in connection.execute("PRAGMA table_info(observation_sessions)")
|
||||
row["name"] for row in connection.execute("PRAGMA table_info(observation_sessions)")
|
||||
}
|
||||
for name, declaration in (
|
||||
("plugin_id", "TEXT NOT NULL DEFAULT ''"),
|
||||
@@ -441,9 +437,7 @@ class SessionStore:
|
||||
)
|
||||
artifact_columns = {
|
||||
row["name"]
|
||||
for row in connection.execute(
|
||||
"PRAGMA table_info(observation_session_artifacts)"
|
||||
)
|
||||
for row in connection.execute("PRAGMA table_info(observation_session_artifacts)")
|
||||
}
|
||||
if "replay_byte_length" not in artifact_columns:
|
||||
connection.execute(
|
||||
@@ -454,6 +448,29 @@ class SessionStore:
|
||||
with _ignore_os_error():
|
||||
self.database_path.chmod(0o600)
|
||||
|
||||
def _migrate_transient_tool_windows(self, connection: sqlite3.Connection) -> None:
|
||||
"""Remove v1 scene-tool visibility that never belonged in a layout."""
|
||||
|
||||
rows = connection.execute(
|
||||
"SELECT workspace_id, layout_json FROM workspace_layouts "
|
||||
"WHERE workspace_id = ? AND layout_schema_version = 1",
|
||||
("observation.spatial",),
|
||||
).fetchall()
|
||||
for row in rows:
|
||||
try:
|
||||
layout = json.loads(row["layout_json"])
|
||||
except (TypeError, json.JSONDecodeError):
|
||||
continue
|
||||
if not isinstance(layout, dict) or "tool_windows" not in layout:
|
||||
continue
|
||||
layout.pop("tool_windows", None)
|
||||
connection.execute(
|
||||
"UPDATE workspace_layouts "
|
||||
"SET layout_schema_version = 2, layout_json = ? "
|
||||
"WHERE workspace_id = ? AND layout_schema_version = 1",
|
||||
(_serialize_layout(layout), row["workspace_id"]),
|
||||
)
|
||||
|
||||
def _upsert_candidate(
|
||||
self,
|
||||
source: ObservationArchiveSource,
|
||||
|
||||
Reference in New Issue
Block a user