Add `current_artifact_id` to the branch detail data model
Intent: Expose the current artifact's database ID in `BranchDetailRecord` so that downstream layers (web handler, template) can reference the specific artifact version the user should chat against.
Affected files: crates/pika-news/src/branch_store.rs
@@ -69,6 +69,7 @@ pub struct BranchFeedItem {
#[allow(dead_code)]
pub struct BranchDetailRecord {
pub branch_id: i64,
+ pub current_artifact_id: Option<i64>,
@@ -545,6 +546,7 @@ impl Store {
self.with_connection(|conn| {
conn.query_row(
"SELECT br.id,
+ ba_current.id,
@@ -588,21 +590,22 @@ impl Store {
|row| {
Ok(BranchDetailRecord {
branch_id: row.get(0)?,
- repo: row.get(1)?,
+ current_artifact_id: row.get(1)?,
+ repo: row.get(2)?,
The BranchDetailRecord struct gains a new field current_artifact_id: Option<i64>. The SQL query in the detail-fetch function is updated to select ba_current.id as the second column (index 1), and every subsequent column index is shifted by one to accommodate the insertion.
This field is Option<i64> because a branch may not yet have a ready artifact (e.g., the tutorial is still generating). Downstream consumers can check for None to decide whether to enable or disable the chat UI.