fix: CLI spec contradictions from codex AX audit
- Fix paths: relative to agent home dir, not hardcoded /home/agent - Add worker/dream coordination: dream pauses worker to prevent file races - Watch registration via .colony.toml (server reads agent config) - Remove remaining old mentions API reference (use inbox instead) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -97,7 +97,11 @@ impl MessageRow {
|
||||
} else {
|
||||
self.content.clone()
|
||||
},
|
||||
mentions: parse_mentions(&self.content),
|
||||
mentions: if self.deleted_at.is_some() {
|
||||
vec![]
|
||||
} else {
|
||||
parse_mentions(&self.content)
|
||||
},
|
||||
metadata: self
|
||||
.metadata
|
||||
.as_ref()
|
||||
|
||||
@@ -4,9 +4,10 @@ mod state;
|
||||
mod ws;
|
||||
|
||||
use axum::{routing::get, Router};
|
||||
use sqlx::sqlite::SqlitePoolOptions;
|
||||
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
|
||||
use state::AppState;
|
||||
use std::env;
|
||||
use std::str::FromStr;
|
||||
use tower_http::services::{ServeDir, ServeFile};
|
||||
|
||||
#[tokio::main]
|
||||
@@ -14,19 +15,20 @@ async fn main() {
|
||||
let db_url = env::var("DATABASE_URL").unwrap_or_else(|_| "sqlite:colony.db?mode=rwc".into());
|
||||
let port = env::var("PORT").unwrap_or_else(|_| "3001".into());
|
||||
|
||||
let opts = SqliteConnectOptions::from_str(&db_url)
|
||||
.expect("Invalid DATABASE_URL")
|
||||
.create_if_missing(true)
|
||||
.pragma("journal_mode", "WAL")
|
||||
.pragma("foreign_keys", "ON");
|
||||
|
||||
let pool = SqlitePoolOptions::new()
|
||||
.max_connections(5)
|
||||
.connect(&db_url)
|
||||
.connect_with(opts)
|
||||
.await
|
||||
.expect("Failed to connect to database");
|
||||
|
||||
eprintln!("colony: connected to {}", db_url);
|
||||
|
||||
sqlx::query("PRAGMA journal_mode=WAL")
|
||||
.execute(&pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
sqlx::migrate!("./migrations")
|
||||
.run(&pool)
|
||||
.await
|
||||
|
||||
@@ -228,6 +228,11 @@ pub async fn post_message(
|
||||
}
|
||||
}
|
||||
|
||||
// Content length limit (64KB)
|
||||
if body.content.len() > 65_536 {
|
||||
return Err(AppError::BadRequest("Message content exceeds 64KB limit".into()));
|
||||
}
|
||||
|
||||
let id = Uuid::new_v4().to_string();
|
||||
let user_id = resolve_user(&state.db, &user_param).await?;
|
||||
|
||||
@@ -347,9 +352,9 @@ pub async fn restore_message(
|
||||
|
||||
let message = row.to_api_message();
|
||||
|
||||
// Broadcast as new message (restored)
|
||||
// Broadcast as edit (not Message — dedup would ignore same ID)
|
||||
let tx = state.get_sender(&channel_id).await;
|
||||
let _ = tx.send(WsEvent::Message(message.clone()));
|
||||
let _ = tx.send(WsEvent::Edit(message.clone()));
|
||||
|
||||
Ok(Json(message))
|
||||
}
|
||||
|
||||
@@ -79,6 +79,11 @@ async fn handle_socket(socket: WebSocket, channel_id: String, state: AppState) {
|
||||
}
|
||||
Err(tokio::sync::broadcast::error::RecvError::Lagged(n)) => {
|
||||
eprintln!("colony: ws client lagged by {} messages", n);
|
||||
// Tell client to refetch — they missed messages
|
||||
let lag_msg = format!(r#"{{"event":"lag","missed":{}}}"#, n);
|
||||
if sender.send(axum::extract::ws::Message::Text(lag_msg.into())).await.is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Err(_) => break, // Channel closed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user