Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[ensu][desktop] Fix Notes follow-up regressions

setalp512933ef9187
diff --git a/rust/apps/ensu/src-tauri/src/commands/llm.rs b/rust/apps/ensu/src-tauri/src/commands/llm.rs
index 564abbe89c..b682f751b5 100644
--- a/rust/apps/ensu/src-tauri/src/commands/llm.rs
+++ b/rust/apps/ensu/src-tauri/src/commands/llm.rs
@@ -157,9 +157,9 @@ pub(crate) fn replace_state(
*model_guard = model;
*context_guard = context;
+ state.mark_model_state_changed();
drop(context_guard);
drop(model_guard);
- state.mark_model_state_changed();
Ok(())
}
@@ -536,8 +536,8 @@ pub async fn llm_create_context(
.lock()
.map_err(|_| ApiError::new("lock", "Failed to lock LLM context store"))?;
*context_guard = Some(context);
- drop(context_guard);
state.mark_model_state_changed();
+ drop(context_guard);
logging::log("LLM", "create context succeeded");
Ok(())
@@ -551,8 +551,8 @@ pub async fn llm_free_context(state: TauriState<'_, State>) -> Result<(), ApiErr
.lock()
.map_err(|_| ApiError::new("lock", "Failed to lock LLM context store"))?;
*context_guard = None;
- drop(context_guard);
state.mark_model_state_changed();
+ drop(context_guard);
Ok(())
}
@@ -668,18 +668,3 @@ pub(crate) fn clear_for_exit(app: &AppHandle) {
logging::log("App", "LLM state unavailable during exit");
}
}
-
-#[cfg(test)]
-mod tests {
- use super::{State, replace_state};
-
- #[test]
- fn replacing_model_state_advances_epoch() {
- let state = State::default();
- let before = state.model_state_epoch();
-
- replace_state(&state, None, None).expect("replace empty model state");
-
- assert_eq!(state.model_state_epoch(), before + 1);
- }
-}
diff --git a/rust/apps/ensu/src-tauri/src/commands/notes/watcher.rs b/rust/apps/ensu/src-tauri/src/commands/notes/watcher.rs
index 405cdab3f1..127f08e6cd 100644
--- a/rust/apps/ensu/src-tauri/src/commands/notes/watcher.rs
+++ b/rust/apps/ensu/src-tauri/src/commands/notes/watcher.rs
@@ -5,6 +5,7 @@ use std::sync::PoisonError;
use ente_ensu::notes::{
NotesCollectionIndex, NotesError, NotesIndexWriter, notes_content_revision,
+ prepare_notes_document,
};
use notify::event::{CreateKind, ModifyKind, RemoveKind};
use notify::{Config, Event, EventKind, RecommendedWatcher, RecursiveMode, Watcher};
@@ -211,9 +212,23 @@ pub(super) fn inspect_startup_freshness(
.iter()
.map(String::as_str)
.collect::<BTreeSet<_>>();
+ let mut changed = !plan.deleted_document_ids.is_empty();
let mut forced_document_ids = BTreeSet::new();
for source in &inventory {
if planned.contains(source.document_id.as_str()) {
+ if writer.indexed_revision(&source.document_id).is_some() {
+ changed = true;
+ continue;
+ }
+ match read_collection_source(&canonical_root, &source.document_id) {
+ Ok((_, bytes, _)) => {
+ changed |= prepare_notes_document(&source.document_id, &bytes).is_ok();
+ }
+ Err(error) if error.name == Some("source_changed") => {
+ changed = true;
+ }
+ Err(error) => return Err(error),
+ }
continue;
}
let Some(indexed_revision) = writer.indexed_revision(&source.document_id) else {
@@ -242,7 +257,7 @@ pub(super) fn inspect_startup_freshness(
};
Ok(StartupInspection {
initial_complete,
- changed: !plan.is_up_to_date() || !forced_document_ids.is_empty(),
+ changed: changed || !forced_document_ids.is_empty(),
forced_document_ids,
opened_index,
})
@@ -678,7 +693,7 @@ fn notify_error(_: notify::Error) -> ApiError {
mod tests {
use super::super::TestDirectory;
use super::*;
- use ente_ensu::notes::{NotesSourceDocument, prepare_notes_document};
+ use ente_ensu::notes::NotesSourceDocument;
use notify::event::RenameMode;
const COLLECTION_ID: &str = "123e4567-e89b-12d3-a456-426614174000";
diff --git a/web/apps/ensu/src/components/chat/ChatDialogs.tsx b/web/apps/ensu/src/components/chat/ChatDialogs.tsx
index 70b2fbb6f1..72043ffbd0 100644
--- a/web/apps/ensu/src/components/chat/ChatDialogs.tsx
+++ b/web/apps/ensu/src/components/chat/ChatDialogs.tsx
@@ -837,9 +837,7 @@ export const ChatDialogs = memo(
: collection.activity ===
"waitingForModel"
? "Indexing will start when the model is ready."
- : collection.activity === "scheduled"
- ? "Indexing is scheduled after recent changes settle."
- : null;
+ : null;
return (
<Stack
key={collection.id}
diff --git a/web/apps/ensu/src/hooks/use-notes-collections.ts b/web/apps/ensu/src/hooks/use-notes-collections.ts
index 929770ac0a..a1a0b09af6 100644
--- a/web/apps/ensu/src/hooks/use-notes-collections.ts
+++ b/web/apps/ensu/src/hooks/use-notes-collections.ts
@@ -394,7 +394,12 @@ export const useNotesCollections = ({
collection.id,
);
let activity: NotesCollectionActivity;
- if (lifecycleActivity === "failed") {
+ if (
+ collection.status === "indexing" ||
+ collection.status === "updating"
+ ) {
+ activity = null;
+ } else if (lifecycleActivity === "failed") {
activity = "failed";
} else if (lifecycleActivity === "starting") {
activity = "starting";
@@ -404,12 +409,8 @@ export const useNotesCollections = ({
: isGenerating || isGenerationActive()
? "waitingForGeneration"
: "starting";
- } else if (
- collection.updateDueAtMs != null &&
- (collection.status === "ready" ||
- collection.status === "pending")
- ) {
- activity = "scheduled";
+ } else if (collection.updateDueAtMs != null) {
+ activity = null;
} else if (collection.status !== "pending") {
activity = null;
} else if (!modelReady) {
diff --git a/web/apps/ensu/src/services/notes-lifecycle.ts b/web/apps/ensu/src/services/notes-lifecycle.ts
index 1faec2bac2..114ea887fd 100644
--- a/web/apps/ensu/src/services/notes-lifecycle.ts
+++ b/web/apps/ensu/src/services/notes-lifecycle.ts
@@ -12,7 +12,6 @@ export type NotesCollectionActivity =
| "starting"
| "waitingForGeneration"
| "waitingForModel"
- | "scheduled"
| "failed"
| null;