Open blogmark drafts before semantic indexing finishes.

This commit is contained in:
2026-08-01 11:29:10 +02:00
parent 2fed5371ca
commit b25691ddac
5 changed files with 198 additions and 41 deletions

View File

@@ -102,6 +102,20 @@ pub fn receive_deep_link_with_host(
raw: &str,
control: &ExecutionControl,
host: Arc<dyn HostApi>,
) -> EngineResult<BlogmarkImportResult> {
receive_deep_link_with_host_and_created(conn, data_dir, project_id, raw, control, host, |_| {})
}
/// Import a blogmark while reporting the created draft before secondary
/// embedding work completes.
pub fn receive_deep_link_with_host_and_created(
conn: &Connection,
data_dir: &Path,
project_id: &str,
raw: &str,
control: &ExecutionControl,
host: Arc<dyn HostApi>,
on_created: impl FnOnce(&Post),
) -> EngineResult<BlogmarkImportResult> {
let mut candidate = parse_deep_link(raw)?;
if let Some(target) = &candidate.project_id
@@ -134,7 +148,7 @@ pub fn receive_deep_link_with_host(
}
}
let metadata = crate::engine::meta::read_project_json(data_dir)?;
let post = crate::engine::post::create_post(
let post = crate::engine::post::create_post_with_created_callback(
conn,
data_dir,
project_id,
@@ -145,6 +159,7 @@ pub fn receive_deep_link_with_host(
metadata.default_author.as_deref(),
metadata.main_language.as_deref(),
None,
on_created,
)?;
Ok(BlogmarkImportResult {
post,

View File

@@ -47,6 +47,38 @@ pub fn create_post(
author: Option<&str>,
language: Option<&str>,
template_slug: Option<&str>,
) -> EngineResult<Post> {
create_post_with_created_callback(
conn,
data_dir,
project_id,
title,
content,
tags,
categories,
author,
language,
template_slug,
|_| {},
)
}
#[expect(
clippy::too_many_arguments,
reason = "arguments are the user-supplied post fields"
)]
pub(crate) fn create_post_with_created_callback(
conn: &Connection,
data_dir: &Path,
project_id: &str,
title: &str,
content: Option<&str>,
tags: Vec<String>,
categories: Vec<String>,
author: Option<&str>,
language: Option<&str>,
template_slug: Option<&str>,
on_created: impl FnOnce(&Post),
) -> EngineResult<Post> {
let id = Uuid::new_v4().to_string();
let slug_source = if title.is_empty() { "untitled" } else { title };
@@ -93,6 +125,7 @@ pub fn create_post(
fts_index_post(conn, data_dir, &post)?;
emit_post(&post, NotificationAction::Created);
on_created(&post);
crate::engine::embedding::sync_post_best_effort(conn, data_dir, &post);
Ok(post)