Refactor: Dismantle MemoryState into semantic domain sub-structs
This commit is contained in:
1 parent
0e866f2465
commit
a34554b7ff
13 files changed
+186
-158
No files matched your search
+7
-7
@@ -103,16 +103,16 @@ async fn ttl_sweeper_worker(state: Arc<MemoryState>) {
|
||||
.unwrap_or_default()
|
||||
.as_secs();
|
||||
|
||||
state.tasks.modify(|tasks| {
|
||||
state.project.tasks.modify(|tasks| {
|
||||
tasks.retain(|t| t.expires_at.is_none_or(|exp| exp > now));
|
||||
});
|
||||
state.sticky.modify(|notes| {
|
||||
state.code.sticky.modify(|notes| {
|
||||
notes.retain(|n| n.expires_at.is_none_or(|exp| exp > now));
|
||||
});
|
||||
state.handoff_memos.modify(|memos| {
|
||||
state.telemetry.handoff_memos.modify(|memos| {
|
||||
memos.retain(|m| m.expires_at.is_none_or(|exp| exp > now));
|
||||
});
|
||||
state.session_summaries.modify(|summaries| {
|
||||
state.telemetry.session_summaries.modify(|summaries| {
|
||||
summaries.retain(|s| s.expires_at.is_none_or(|exp| exp > now));
|
||||
});
|
||||
}
|
||||
@@ -144,7 +144,7 @@ async fn condense_graph_worker(state: Arc<MemoryState>) {
|
||||
|
||||
// Condense sticky notes
|
||||
let mut condensed_sticky_content = String::new();
|
||||
state.sticky.modify(|notes| {
|
||||
state.code.sticky.modify(|notes| {
|
||||
if notes.len() > threshold {
|
||||
notes.sort_by_key(|n| n.timestamp);
|
||||
let to_remove = notes.len() - (threshold / 2);
|
||||
@@ -174,7 +174,7 @@ async fn condense_graph_worker(state: Arc<MemoryState>) {
|
||||
|
||||
// Condense snippets
|
||||
let mut condensed_snippet_content = String::new();
|
||||
state.snippets.modify(|snippets| {
|
||||
state.code.snippets.modify(|snippets| {
|
||||
if snippets.len() > threshold {
|
||||
snippets.sort_by_key(|s| s.updated_at);
|
||||
let to_remove = snippets.len() - (threshold / 2);
|
||||
@@ -260,7 +260,7 @@ async fn run_server(state: Arc<MemoryState>) -> Result<(), Box<dyn std::error::E
|
||||
if let Ok((len, _addr)) = socket.recv_from(&mut buf).await
|
||||
&& let Ok(payload) = serde_json::from_slice::<crate::models::TerminalHistory>(&buf[..len])
|
||||
{
|
||||
udp_state.handler.state.terminal_history.modify(|history| {
|
||||
udp_state.handler.state.telemetry.terminal_history.modify(|history| {
|
||||
history.push_front(payload.clone());
|
||||
if history.len() > 100 {
|
||||
history.pop_back();
|
||||
|
||||
Reference in new issue
Block a user