Fix DB lock error: clear message + instructions, fix passphrase reprompt

Storage:
- Detects sled lock contention, shows actionable error:
  "Database locked by another warzone process"
  with ps command to find the process and rm command to force unlock

TUI:
- Poll loop no longer calls load_seed() (was re-prompting passphrase)
- Seed passed from main.rs to run_tui to poll_loop
- Single passphrase prompt per app launch

Warnings fixed:
- Removed unused `Context` import in tui/app.rs
- Added #[allow(dead_code)] on validate_token (used when auth middleware wired)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-27 08:24:53 +04:00
parent c8b51fa96b
commit d7b71efdbc
4 changed files with 28 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
use std::sync::{Arc, Mutex};
use std::time::Duration;
use anyhow::{Context, Result};
use anyhow::Result;
use crossterm::event::{self, Event, KeyCode, KeyModifiers};
use ratatui::layout::{Constraint, Direction, Layout};
use ratatui::style::{Color, Modifier, Style};
@@ -741,6 +741,7 @@ pub async fn run_tui(
peer_fp: Option<String>,
server_url: String,
identity: IdentityKeyPair,
poll_seed: warzone_protocol::identity::Seed,
db: LocalDb,
) -> Result<()> {
let mut terminal = ratatui::init();
@@ -749,9 +750,8 @@ pub async fn run_tui(
let mut app = App::new(our_fp.clone(), peer_fp, server_url);
// Spawn background poll task
// We need a second IdentityKeyPair for the poll loop — re-derive from seed
let poll_identity = crate::keystore::load_seed()?.derive_identity();
// Derive a second identity for the poll loop (can't clone IdentityKeyPair)
let poll_identity = poll_seed.derive_identity();
let poll_messages = app.messages.clone();
let poll_client = client.clone();
let poll_db = db.clone();