Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 19 additions & 7 deletions crates/dim-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1360,18 +1360,30 @@ their last validated cursor. Loading or failed history disables stop-all while
known individual targets remain usable. A failure reading main history is a visible
connection failure: submission is disabled and the unsent draft stays in the current UI.
Recovery requires exiting and resuming the Session.
Resuming waits for main's complete initial history before drawing the latest
100 messages and its boundary. Fullscreen tops them with a load-more row: a
click, or `Tab` up to it and `Enter`, draws the previous 100 above and keeps the
oldest drawn message at the top of the view. Scrollback reaches earlier messages
through a `/timeline` jump; a draft typed meanwhile stays editable.
Resuming draws up to 100 messages from main's initial history window. Both modes
mark unread history above the oldest message, never below the transcript. In fullscreen a
click, or `Tab` up to it and `Enter`, shows the preceding page at the join. Scrolling
up or pressing PageUp at the top does the same. `/earlier` reveals one page in fullscreen.
In scrollback, `/earlier` reveals one preceding page and redraws the loaded conversation
in the same terminal, with older messages above newer ones and the draft below.
**This replaces native scrollback, including terminal output from before Dim started.**
The hint above the oldest message warns before you page. At the beginning, `/earlier`
only shows a notice; it does not redraw. See [Loading earlier conversation](../../docs/design/cli-commands.md#loading-earlier-conversation).
`/timeline` still jumps to a specific message; a draft typed meanwhile stays editable.

```text
↑ Earlier messages · /earlier · Clears terminal output from before Dim started
> paged-message-051
...
> paged-message-150
--- resumed paged · 100 messages · earlier history: /timeline ---
[ draft typed while history was loading ]
--- resumed paged · 100 messages ---
[ Ask anything... ]

/earlier (same terminal, after redraw)
> paged-message-001
...
> paged-message-150
[ Ask anything... ]
```

Child-branch failures remain local to the task history and release buffered
Expand Down
20 changes: 12 additions & 8 deletions crates/dim-cli/src/projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct Projection {
/// 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.
messages: HashMap<String, Vec<(String, u64)>>,
messages: HashMap<String, HashMap<String, u64>>,
/// Each line's user messages withdrawn later, by input id and the sequence
/// that withdrew them: a cut before that sequence still counts the
/// message, whichever page carried the input or the withdrawal.
Expand Down Expand Up @@ -141,10 +141,11 @@ impl Projection {
pub fn line_event(&mut self, parent: &str, event: &Event) {
match &event.content {
EventContent::Input(data) if data.user.is_some() => {
let messages = self.messages.entry(parent.to_owned()).or_default();
if !messages.iter().any(|(id, _)| *id == event.id) {
messages.push((event.id.clone(), event.sequence));
}
self.messages
.entry(parent.to_owned())
.or_default()
.entry(event.id.clone())
.or_insert(event.sequence);
}
EventContent::InputDeleted(data) => {
let withdrawals = self.withdrawals.entry(parent.to_owned()).or_default();
Expand Down Expand Up @@ -232,11 +233,11 @@ impl Projection {
messages
.iter()
.filter(|(id, at)| {
*at <= sequence
**at <= sequence
&& self
.withdrawals
.get(branch)
.and_then(|withdrawals| withdrawals.get(id))
.and_then(|withdrawals| withdrawals.get(*id))
.is_none_or(|withdrawn| *withdrawn > sequence)
})
.count()
Expand Down Expand Up @@ -524,7 +525,7 @@ impl Projection {
}
}
EventContent::ModelStart(_) => {}
EventContent::Thinking(data) => {
EventContent::Thinking(data) | EventContent::SettledThinking(data, _) => {
*self
.thinking_characters
.entry(data.request_id.clone())
Expand Down Expand Up @@ -557,6 +558,9 @@ impl Projection {
format!("thinking-{}", event.id),
));
}
if let EventContent::SettledThinking(_, closed_at) = &event.content {
self.close_thinking(&data.request_id, *closed_at);
}
}
EventContent::Text(data) => {
self.showed.insert(data.request_id.clone());
Expand Down
16 changes: 7 additions & 9 deletions crates/dim-cli/src/session_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,12 @@ impl Worker {
}
}
Command::Rename(title) => self.rename(title).await,
Command::Earlier { line, .. } => self.earlier(&line),
Command::Earlier { line, .. } => {
self.earlier(&line);
if self.earlier_view() == Earlier::Reading {
self.publish();
}
}
Command::Goal { request, .. } => self.goal(request).await,
Command::Loop { request, .. } => self.loop_command(request).await,
Command::CheckUpdate if self.options.endpoint.is_some() => {
Expand Down Expand Up @@ -5612,14 +5617,7 @@ impl Worker {
.values()
.any(|line| line.projection.held_input(id).is_some())
});
let mut snapshot = match self
.lines
.get(&self.focus)
.filter(|_| self.focus != ROOT_BRANCH_ID)
{
Some(line) => line.projection.snapshot(),
None => self.projection.snapshot(),
};
let mut snapshot = self.shown().snapshot();
snapshot.lines = self.line_views();
snapshot.unread_lines = snapshot
.lines
Expand Down
13 changes: 9 additions & 4 deletions crates/dim-cli/src/session_host/member.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,17 @@ impl Worker {
}
}
Pending::History(_) => {
let mut at_start = false;
let page = result.map_err(|error| error.to_string()).and_then(|value| {
let page = if self
.client
.supports(&["session.history.display", "session.history.detail"])
{
serde_json::from_value::<dim_client::wire::DisplayPage>(value)
.map(Into::into)
serde_json::from_value::<dim_client::wire::DisplayPage>(value).map(|page| {
at_start = page.done()
&& self.client.offers("session.history.display.transcript");
page.into()
})
} else {
serde_json::from_value(value)
}
Expand All @@ -588,15 +592,16 @@ impl Worker {
Err(error) => self.fail_member(&id, error),
Ok(done) => {
if done {
let events = observation.window.take_transcript(at_start);
if observation.earlier == EarlierRead::Reading {
let mut older = Projection::default();
for event in observation.window.take() {
for event in events {
older.replay(DEFAULT_BRANCH_ID, &event);
}
observation.projection.prepend(older);
observation.earlier = EarlierRead::None;
} else {
for event in observation.window.take() {
for event in events {
observation.event(event, true);
}
observation.cursor =
Expand Down
41 changes: 5 additions & 36 deletions crates/dim-cli/src/session_host/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@ impl Worker {
.map_err(|error| error.to_string())
});
let window_ready = matches!(result, Ok(true));
let mut missing_prefix = false;
match result {
Err(error) => {
if fatal {
Expand All @@ -665,8 +664,8 @@ impl Worker {
.get_mut(&request.branch_id)
.expect("current history");
history.window_error = None;
let events = history.window.take();
missing_prefix =
let events = history.window.take_transcript(at_start);
let missing_prefix =
history.window.dropped_pages() || history.window.before.is_some() && !at_start;
history.window_complete = true;
if history.earlier == EarlierRead::Reading {
Expand Down Expand Up @@ -735,11 +734,6 @@ impl Worker {
if window_ready {
self.publish();
}
if missing_prefix {
self.send(Update::Notice(
"Earlier content not loaded; /earlier to read it".into(),
));
}
Ok(())
}

Expand Down Expand Up @@ -793,9 +787,6 @@ impl Worker {
self.task_event(branch, event);
}
}
if let Some(projection) = transcript_mut(&mut self.projection, &mut self.lines, branch) {
projection.trim(300);
}
self.changed();
}

Expand Down Expand Up @@ -1994,13 +1985,8 @@ mod tests {
);
}

/// A window whose page left out earlier content says so in a notice. The
/// notice is sent after the snapshot that carries the page, so the
/// interface's next frame draws the page's rows before the notice that
/// reports them missing. Both updates share one channel, and the interface
/// applies whatever it drains in that order.
#[tokio::test]
async fn a_missing_prefix_notice_follows_the_page_it_reports() {
async fn a_page_with_missing_history_marks_its_snapshot_unread() {
let (mut worker, receiver, _sent) =
crate::session_host::test_worker(&crate::session_host::TEST_FEATURES).await;
worker.session_id = "s1".into();
Expand All @@ -2016,25 +2002,8 @@ mod tests {
)
.await;

let updates: Vec<Update> = receiver.try_iter().collect();
let page = updates
.iter()
.position(|update| {
matches!(update, Update::Snapshot(view)
if view.rows.iter().any(|row| row.text.contains("the loaded page")))
})
.expect("the page published its rows");
let notice = updates
.iter()
.position(|update| {
matches!(update, Update::Notice(text)
if text == "Earlier content not loaded; /earlier to read it")
})
.expect("the page reports the earlier content it left out");
assert!(
page < notice,
"the page's snapshot is sent before the notice that reports the missing earlier content"
);
assert!(receiver.try_iter().any(|update| matches!(update, Update::Snapshot(view)
if view.earlier == Earlier::Unread && view.rows.iter().any(|row| row.text.contains("the loaded page")))));
}

/// A creation that fails while the line's first window is in flight
Expand Down
6 changes: 5 additions & 1 deletion crates/dim-cli/src/ui/i18n/de/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"y confirm · Esc cancel" => "y bestätigen · Esc abbrechen",
"Enter save · Esc cancel" => "Enter speichern · Esc abbrechen",
"Loading…" => "Wird geladen…",
"Beginning of conversation" => "Anfang der Unterhaltung erreicht",
"Tab / Enter complete" => "Tab / Enter vervollständigen",
"Queue" => "Warteschlange",
"Export session" => "Sitzung exportieren",
Expand Down Expand Up @@ -365,7 +366,10 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"Only in fullscreen (/tui)" => "Nur im Vollbild (/tui)",
"new session" => "neue Session",
"resumed {id} · {count} messages" => "{id} fortgesetzt · {count} Nachrichten",
" · earlier history: /timeline" => " · früherer Verlauf: /timeline",
"Earlier messages · {key}" => "Frühere Nachrichten · {key}",
"Clears terminal output from before Dim started" => {
"Löscht die Terminalausgabe vor dem Start von Dim"
}
"Error: {message}" => "Fehler: {message}",
"working… {elapsed}" => "arbeitet… {elapsed}",
"thinking… {elapsed}" => "denkt… {elapsed}",
Expand Down
6 changes: 5 additions & 1 deletion crates/dim-cli/src/ui/i18n/es/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"y confirm · Esc cancel" => "y confirmar · Esc cancelar",
"Enter save · Esc cancel" => "Enter guardar · Esc cancelar",
"Loading…" => "Cargando…",
"Beginning of conversation" => "Inicio de la conversación",
"Tab / Enter complete" => "Tab / Enter completar",
"Queue" => "Cola",
"Export session" => "Exportar sesión",
Expand Down Expand Up @@ -365,7 +366,10 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"Only in fullscreen (/tui)" => "Solo en pantalla completa (/tui)",
"new session" => "nueva sesión",
"resumed {id} · {count} messages" => "reanudada {id} · {count} mensajes",
" · earlier history: /timeline" => " · historial anterior: /timeline",
"Earlier messages · {key}" => "Mensajes anteriores · {key}",
"Clears terminal output from before Dim started" => {
"Borra la salida del terminal anterior al inicio de Dim"
}
"Error: {message}" => "Error: {message}",
"working… {elapsed}" => "trabajando… {elapsed}",
"thinking… {elapsed}" => "pensando… {elapsed}",
Expand Down
6 changes: 5 additions & 1 deletion crates/dim-cli/src/ui/i18n/fr/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"y confirm · Esc cancel" => "y confirmer · Échap annuler",
"Enter save · Esc cancel" => "Entrée enregistrer · Échap annuler",
"Loading…" => "Chargement…",
"Beginning of conversation" => "Début de la conversation atteint",
"Tab / Enter complete" => "Tab / Enter compléter",
"Queue" => "File d’attente",
"Export session" => "Exporter la session",
Expand Down Expand Up @@ -355,7 +356,10 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"Only in fullscreen (/tui)" => "Plein écran uniquement (/tui)",
"new session" => "nouvelle session",
"resumed {id} · {count} messages" => "{id} repris · {count} messages",
" · earlier history: /timeline" => " · historique antérieur: /timeline",
"Earlier messages · {key}" => "Messages précédents · {key}",
"Clears terminal output from before Dim started" => {
"Efface la sortie du terminal antérieure au lancement de Dim"
}
"Error: {message}" => "Erreur: {message}",
"working… {elapsed}" => "travail… {elapsed}",
"thinking… {elapsed}" => "réflexion… {elapsed}",
Expand Down
6 changes: 5 additions & 1 deletion crates/dim-cli/src/ui/i18n/id/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"y confirm · Esc cancel" => "y konfirmasi · Esc batal",
"Enter save · Esc cancel" => "Enter simpan · Esc batal",
"Loading…" => "Memuat…",
"Beginning of conversation" => "Awal percakapan",
"Tab / Enter complete" => "Tab / Enter lengkapi",
"Queue" => "Antrean",
"Export session" => "Ekspor sesi",
Expand Down Expand Up @@ -355,7 +356,10 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"Only in fullscreen (/tui)" => "Hanya di layar penuh (/tui)",
"new session" => "sesi baru",
"resumed {id} · {count} messages" => "lanjut {id} · {count} pesan",
" · earlier history: /timeline" => " · riwayat lama: /timeline",
"Earlier messages · {key}" => "Pesan sebelumnya · {key}",
"Clears terminal output from before Dim started" => {
"Menghapus keluaran terminal sebelum Dim dimulai"
}
"Error: {message}" => "Error: {message}",
"working… {elapsed}" => "bekerja… {elapsed}",
"thinking… {elapsed}" => "berpikir… {elapsed}",
Expand Down
4 changes: 3 additions & 1 deletion crates/dim-cli/src/ui/i18n/ja/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"y confirm · Esc cancel" => "y 確定 · Esc キャンセル",
"Enter save · Esc cancel" => "Enter 保存 · Esc キャンセル",
"Loading…" => "読み込み中…",
"Beginning of conversation" => "会話の先頭です",
"Tab / Enter complete" => "Tab / Enter 補完",
"Queue" => "キュー",
"Export session" => "セッションをエクスポート",
Expand Down Expand Up @@ -343,7 +344,8 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"Only in fullscreen (/tui)" => "全画面のみ(/tui)",
"new session" => "新規セッション",
"resumed {id} · {count} messages" => "{id} を再開 · {count} 件",
" · earlier history: /timeline" => " · 過去の履歴:/timeline",
"Earlier messages · {key}" => "以前のメッセージ · {key}",
"Clears terminal output from before Dim started" => "Dim 起動前の端末出力は消去されます",
"Error: {message}" => "エラー:{message}",
"working… {elapsed}" => "処理中… {elapsed}",
"thinking… {elapsed}" => "思考中… {elapsed}",
Expand Down
4 changes: 3 additions & 1 deletion crates/dim-cli/src/ui/i18n/ko/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"y confirm · Esc cancel" => "y 확인 · Esc 취소",
"Enter save · Esc cancel" => "Enter 저장 · Esc 취소",
"Loading…" => "불러오는 중…",
"Beginning of conversation" => "대화의 시작입니다",
"Tab / Enter complete" => "Tab / Enter 완성",
"Queue" => "대기열",
"Export session" => "세션 내보내기",
Expand Down Expand Up @@ -329,7 +330,8 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"Only in fullscreen (/tui)" => "전체 화면에서만 가능 (/tui)",
"new session" => "새 세션",
"resumed {id} · {count} messages" => "{id} 재개됨 · 메시지 {count}개",
" · earlier history: /timeline" => " · 이전 기록: /timeline",
"Earlier messages · {key}" => "이전 메시지 · {key}",
"Clears terminal output from before Dim started" => "Dim 시작 전의 터미널 출력을 지웁니다",
"Error: {message}" => "오류: {message}",
"working… {elapsed}" => "작업 중… {elapsed}",
"thinking… {elapsed}" => "생각 중… {elapsed}",
Expand Down
6 changes: 5 additions & 1 deletion crates/dim-cli/src/ui/i18n/pt_br/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"y confirm · Esc cancel" => "y confirmar · Esc cancelar",
"Enter save · Esc cancel" => "Enter salvar · Esc cancelar",
"Loading…" => "Carregando…",
"Beginning of conversation" => "Início da conversa",
"Tab / Enter complete" => "Tab / Enter completar",
"Queue" => "Fila",
"Export session" => "Exportar sessão",
Expand Down Expand Up @@ -361,7 +362,10 @@ pub fn lookup(english: &str) -> Option<&'static str> {
"Only in fullscreen (/tui)" => "Só em tela cheia (/tui)",
"new session" => "nova sessão",
"resumed {id} · {count} messages" => "{id} retomada · {count} mensagens",
" · earlier history: /timeline" => " · histórico anterior: /timeline",
"Earlier messages · {key}" => "Mensagens anteriores · {key}",
"Clears terminal output from before Dim started" => {
"Apaga a saída do terminal anterior ao início do Dim"
}
"Error: {message}" => "Erro: {message}",
"working… {elapsed}" => "trabalhando… {elapsed}",
"thinking… {elapsed}" => "pensando… {elapsed}",
Expand Down
Loading