Skip to content

Commit 8513d68

Browse files
chore(dashboard): remove dead schema-v22 dir:* warning
The warning fired on every read-only/read-write DB open (so ~4x at startup, once per connection) for any schema >= 22 — always true now that the live schema is v49. It was self-defeating: the warning text ('ensure the v2 dashboard is running') only exists in the v2 dashboard, so it can only ever print FROM the v2 dashboard; an actual stale v1 dashboard (the case it warns about) has no such line and stays silent. It never caught its target condition and is pure transition-era noise now that v2 is the only dashboard. Removed the const, the three helpers, both open_readonly/open_readwrite call sites, the AppState field + getter + refresher plumbing, the dead get_dashboard_schema_warning Tauri command (no frontend consumer) + its registration, and the schema_v22_warning test. Gate: cargo check + fmt clean, 53 Rust tests pass, frontend build clean. Co-authored-by: Alfonso [Magic Context] <288211368+alfonso-magic-context@users.noreply.github.com>
1 parent 3096a15 commit 8513d68

5 files changed

Lines changed: 4 additions & 97 deletions

File tree

packages/dashboard/src-tauri/src/commands.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ use tauri::State;
99

1010
// ── Memory commands ─────────────────────────────────────────
1111

12-
#[tauri::command]
13-
pub fn get_dashboard_schema_warning(state: State<'_, AppState>) -> Option<i64> {
14-
state.dashboard_schema_warning_version()
15-
}
16-
1712
// `(async)` runs this synchronous body on a worker thread instead of the
1813
// webview main thread. get_projects is heavy (a GROUP BY over the full
1914
// opencode.db plus a recursive Pi session-dir scan), so on the main thread it

packages/dashboard/src-tauri/src/db.rs

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -66,45 +66,6 @@ pub fn resolve_opencode_db_path() -> Option<PathBuf> {
6666
}
6767
}
6868

69-
const DASHBOARD_DIR_IDENTITY_UNSAFE_SCHEMA_VERSION: i64 = 22;
70-
71-
pub fn dashboard_schema_warning_version(conn: &Connection) -> Result<Option<i64>, rusqlite::Error> {
72-
let has_migrations_table: i64 = conn.query_row(
73-
"SELECT COUNT(*) FROM sqlite_master WHERE type = 'table' AND name = 'schema_migrations'",
74-
[],
75-
|row| row.get(0),
76-
)?;
77-
if has_migrations_table == 0 {
78-
return Ok(None);
79-
}
80-
81-
let version: i64 = conn.query_row(
82-
"SELECT COALESCE(MAX(version), 0) FROM schema_migrations",
83-
[],
84-
|row| row.get(0),
85-
)?;
86-
Ok((version >= DASHBOARD_DIR_IDENTITY_UNSAFE_SCHEMA_VERSION).then_some(version))
87-
}
88-
89-
pub fn dashboard_schema_warning_version_for_path(
90-
path: &PathBuf,
91-
) -> Result<Option<i64>, rusqlite::Error> {
92-
let conn = Connection::open_with_flags(
93-
path,
94-
rusqlite::OpenFlags::SQLITE_OPEN_READ_ONLY | rusqlite::OpenFlags::SQLITE_OPEN_NO_MUTEX,
95-
)?;
96-
conn.pragma_update(None, "busy_timeout", 5000)?;
97-
dashboard_schema_warning_version(&conn)
98-
}
99-
100-
fn warn_if_dashboard_schema_requires_upgrade(conn: &Connection) {
101-
if let Ok(Some(version)) = dashboard_schema_warning_version(conn) {
102-
eprintln!(
103-
"[dashboard] Magic Context schema v{version} uses v2 dir:* identity hashing; ensure the v2 dashboard/frontend is running before trusting dir:* project reads."
104-
);
105-
}
106-
}
107-
10869
/// Opens a read-only connection to the database in WAL mode.
10970
pub fn open_readonly(path: &PathBuf) -> Result<Connection, rusqlite::Error> {
11071
let conn = Connection::open_with_flags(
@@ -114,7 +75,6 @@ pub fn open_readonly(path: &PathBuf) -> Result<Connection, rusqlite::Error> {
11475
// WAL mode is inherited from the plugin's read-write connection — no need to set it here.
11576
// busy_timeout is connection-local and safe on read-only connections.
11677
conn.pragma_update(None, "busy_timeout", 5000)?;
117-
warn_if_dashboard_schema_requires_upgrade(&conn);
11878
Ok(conn)
11979
}
12080

@@ -134,7 +94,6 @@ pub fn open_readwrite(path: &PathBuf) -> Result<Connection, rusqlite::Error> {
13494
conn.pragma_update(None, "busy_timeout", 5000)?;
13595
conn.pragma_update(None, "foreign_keys", "ON")?;
13696
conn.pragma_update(None, "journal_mode", "WAL")?;
137-
warn_if_dashboard_schema_requires_upgrade(&conn);
13897
Ok(conn)
13998
}
14099

packages/dashboard/src-tauri/src/lib.rs

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,51 +12,25 @@ pub mod workspaces;
1212
use std::path::PathBuf;
1313
use std::sync::Mutex;
1414

15-
/// Shared app state holding the resolved database path and dashboard/schema warnings.
15+
/// Shared app state holding the resolved database path.
1616
pub struct AppState {
1717
pub db_path: Mutex<Option<PathBuf>>,
18-
dashboard_schema_warning_version: Mutex<Option<i64>>,
1918
}
2019

2120
impl AppState {
2221
pub fn new() -> Self {
2322
let db_path = db::resolve_db_path();
24-
let state = Self {
23+
Self {
2524
db_path: Mutex::new(db_path),
26-
dashboard_schema_warning_version: Mutex::new(None),
27-
};
28-
if let Ok(path) = state.get_db_path() {
29-
state.refresh_dashboard_schema_warning(&path);
3025
}
31-
state
3226
}
3327

3428
pub fn get_db_path(&self) -> Result<PathBuf, String> {
35-
let path = self
36-
.db_path
29+
self.db_path
3730
.lock()
3831
.map_err(|_| "Lock poisoned".to_string())?
3932
.clone()
40-
.ok_or_else(|| {
41-
"Database not found. Is the Magic Context plugin installed?".to_string()
42-
})?;
43-
self.refresh_dashboard_schema_warning(&path);
44-
Ok(path)
45-
}
46-
47-
pub fn dashboard_schema_warning_version(&self) -> Option<i64> {
48-
self.dashboard_schema_warning_version
49-
.lock()
50-
.ok()
51-
.and_then(|guard| *guard)
52-
}
53-
54-
fn refresh_dashboard_schema_warning(&self, path: &PathBuf) {
55-
if let Ok(Some(version)) = db::dashboard_schema_warning_version_for_path(path) {
56-
if let Ok(mut guard) = self.dashboard_schema_warning_version.lock() {
57-
*guard = Some(version);
58-
}
59-
}
33+
.ok_or_else(|| "Database not found. Is the Magic Context plugin installed?".to_string())
6034
}
6135
}
6236

packages/dashboard/src-tauri/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ fn main() {
9797
commands::promote_user_memory_candidate,
9898
// Health
9999
commands::get_db_health,
100-
commands::get_dashboard_schema_warning,
101100
// Workspaces
102101
commands::workspace_schema_ready,
103102
commands::list_workspaces,

packages/dashboard/src-tauri/tests/db_mutations.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -545,26 +545,6 @@ fn invalidate_all_memory_block_caches_clears_m0_m1_and_mutation_cursor() {
545545
assert_eq!(row, ("".to_string(), "".to_string(), None, None, None));
546546
}
547547

548-
#[test]
549-
fn schema_v22_warning_is_reported_at_open() {
550-
let dir = tempfile::tempdir().expect("tempdir");
551-
let db_path = dir.path().join("context.db");
552-
{
553-
let conn = Connection::open(&db_path).expect("open db file");
554-
conn.execute_batch(
555-
"CREATE TABLE schema_migrations (version INTEGER PRIMARY KEY, description TEXT NOT NULL, applied_at INTEGER NOT NULL);
556-
INSERT INTO schema_migrations (version, description, applied_at) VALUES (22, 'v22', 1);",
557-
)
558-
.expect("seed migrations");
559-
}
560-
561-
let conn = db::open_readonly(&db_path).expect("open readonly");
562-
assert_eq!(
563-
db::dashboard_schema_warning_version(&conn).expect("warning"),
564-
Some(22)
565-
);
566-
}
567-
568548
#[test]
569549
#[cfg(unix)]
570550
fn raw_path_git_resolution_happens_before_immediate_write_transaction() {

0 commit comments

Comments
 (0)