Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/dim-cli/src/model/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@ pub struct ViewSnapshot {
pub projection_id: u64,
/// The shown line's history has loaded: its transcript can be laid out.
pub history_complete: bool,
/// The shown line's first window could not be read, with the reason; the
/// line draws it instead of a transcript until the line is opened again.
/// `None` while the window loads, after it loads, and when only a later
/// read (an inventory refresh or an `/earlier` page) failed;
/// `history_complete` separates the first case from the other two.
pub window_error: Option<String>,
/// Whether history older than the loaded window exists, and whether an
/// earlier read is in flight; `/earlier`, PageUp at the drawn top and the
/// load-more row act on it.
Expand Down
17 changes: 16 additions & 1 deletion crates/dim-cli/src/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ pub struct Projection {
owner: String,
/// The lines of the Session, as `main` recorded them (design §14).
lines: Vec<LineView>,
/// Lines whose creation failed. The fact outruns the line's row: a
/// `branch/create-failed` the parent's page has not projected a
/// `branch/create` for is still terminal.
creation_failed: HashSet<String>,
/// Each line's own user messages, by input id and submission sequence,
/// to count where a line was cut (timeline UI §6); a withdrawn message
/// stays, and `withdrawals` decides which cuts still count it.
Expand Down Expand Up @@ -167,7 +171,11 @@ impl Projection {
id: data.branch.clone(),
parent: Some(parent.to_owned()),
purpose,
state: LineState::Waiting,
state: if self.creation_failed.contains(&data.branch) {
LineState::CreationFailed
} else {
LineState::Waiting
},
running: None,
branch_point: Some(sequence),
cut,
Expand All @@ -179,6 +187,7 @@ impl Projection {
BranchCreateFailedData::Failed { branch, .. }
| BranchCreateFailedData::Cancelled { branch, .. } => branch,
};
self.creation_failed.insert(branch.clone());
if let Some(line) = self.lines.iter_mut().find(|line| line.id == *branch) {
line.state = LineState::CreationFailed;
}
Expand Down Expand Up @@ -1474,6 +1483,12 @@ impl Projection {
&self.lines
}

/// Whether `branch`'s creation failed, whether or not its row is
/// projected yet: the line is terminal from the fact.
pub fn creation_failed(&self, branch: &str) -> bool {
self.creation_failed.contains(branch)
}

pub fn approvals(&self) -> Vec<ApprovalView> {
self.approvals.clone()
}
Expand Down
11 changes: 7 additions & 4 deletions crates/dim-cli/src/session_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5413,6 +5413,10 @@ impl Worker {
self.send(Update::Notice(format!("No line {line} in this session")));
return;
}
if line != ROOT_BRANCH_ID && self.projection.creation_failed(&line) {
self.send(Update::Notice(format!("Line creation failed: {line}")));
return;
}
if line != ROOT_BRANCH_ID {
self.line_projection(&line);
}
Expand Down Expand Up @@ -5507,10 +5511,9 @@ impl Worker {
}
snapshot.session_id = self.session_id.clone();
snapshot.projection_id = self.projection_id;
snapshot.history_complete = self
.task_history
.get(&self.focus)
.is_some_and(|branch| branch.window_complete);
let shown = self.task_history.get(&self.focus);
snapshot.history_complete = shown.is_some_and(|branch| branch.window_complete);
snapshot.window_error = shown.and_then(|branch| branch.window_error.clone());
snapshot.earlier = self.earlier_view();
snapshot.task_history_loading = self
.task_history
Expand Down
Loading