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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ quieter, and Fleet runs can be checked before they spend anything.
- **[@cenab](https://github.com/cenab)** — requested the Tsubasa provider row and supplied its endpoint, key and model values ([#6695](https://github.com/Hmbown/Codewhale/issues/6695)).
- **[@BX166](https://github.com/BX166)** — reported the AICraft provider row missing its key console, docs link and guidance, and supplied the values ([#6616](https://github.com/Hmbown/Codewhale/issues/6616)).
- **[@Water-Run](https://github.com/Water-Run)** — ingested namespaced model-only catalog entries so models present only in the canonical `models` map reach the offering list ([#6400](https://github.com/Hmbown/Codewhale/pull/6400)), and retired the blanket dead-code allowance with its unused feature stages, tightening the budget to match ([#6402](https://github.com/Hmbown/Codewhale/pull/6402)).
- **[@SparkofSpike](https://github.com/SparkofSpike)** — let making room survive a provider request-body limit (HTTP 413) by shrinking, then replacing, inline images for that one summary pass ([#6642](https://github.com/Hmbown/Codewhale/pull/6642)).

### Added

Expand Down
1 change: 1 addition & 0 deletions crates/tui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ quieter, and Fleet runs can be checked before they spend anything.
- **[@cenab](https://github.com/cenab)** — requested the Tsubasa provider row and supplied its endpoint, key and model values ([#6695](https://github.com/Hmbown/Codewhale/issues/6695)).
- **[@BX166](https://github.com/BX166)** — reported the AICraft provider row missing its key console, docs link and guidance, and supplied the values ([#6616](https://github.com/Hmbown/Codewhale/issues/6616)).
- **[@Water-Run](https://github.com/Water-Run)** — ingested namespaced model-only catalog entries so models present only in the canonical `models` map reach the offering list ([#6400](https://github.com/Hmbown/Codewhale/pull/6400)), and retired the blanket dead-code allowance with its unused feature stages, tightening the budget to match ([#6402](https://github.com/Hmbown/Codewhale/pull/6402)).
- **[@SparkofSpike](https://github.com/SparkofSpike)** — let making room survive a provider request-body limit (HTTP 413) by shrinking, then replacing, inline images for that one summary pass ([#6642](https://github.com/Hmbown/Codewhale/pull/6642)).

### Added

Expand Down
537 changes: 535 additions & 2 deletions crates/tui/src/compaction.rs

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions crates/tui/src/core/engine/compaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ pub(super) struct CompactionPass {
pub usage: Usage,
}

/// Engine-side sink for compaction downgrade notices.
///
/// Delivered as `Event::Status`, the same channel other engine status lines
/// use, so a long recovery says what it is doing while it runs. A full event
/// channel drops the notice instead of stalling the pass; the same sentence
/// is already in the log via `logging::warn`.
#[derive(Debug)]
struct EngineCompactionNoticeSink {
tx: mpsc::Sender<Event>,
}

impl crate::compaction::CompactionNoticeSink for EngineCompactionNoticeSink {
fn notice(&self, message: String) {
let _ = self.tx.try_send(Event::Status { message });
}
}

impl Engine {
pub(super) async fn emit_compaction_started(
&mut self,
Expand Down Expand Up @@ -183,6 +200,9 @@ impl Engine {
.get_or_insert_with(|| self.config.workspace.clone());
let mut prepared = PreparedCompactionEnvelope::new(config);
prepared.session_id = Some(self.session.id.clone());
prepared.notice_sink = Some(std::sync::Arc::new(EngineCompactionNoticeSink {
tx: self.tx_event.clone(),
}));
// The summary request must carry the reasoning tier the turn sends:
// reasoning routes render it at the head of the prompt, so omitting
// it forfeited the whole cached history prefix (#6540).
Expand Down Expand Up @@ -709,3 +729,25 @@ pub(super) fn is_provider_rejection(err: &anyhow::Error) -> bool {
| ErrorCategory::Timeout
)
}

#[cfg(test)]
mod tests {
use super::*;
use crate::compaction::CompactionNoticeSink as _;

/// The engine sink is the one link between a compaction downgrade and the
/// person watching: the notice must land on the status line, not only in
/// the log.
#[tokio::test]
async fn compaction_notice_sink_delivers_a_status_event() {
let (tx, mut rx) = mpsc::channel(4);
let sink = EngineCompactionNoticeSink { tx };
sink.notice("Making room re-encoded 2 inline image(s)".to_string());
match rx.recv().await {
Some(Event::Status { message }) => {
assert!(message.contains("re-encoded"), "{message}");
}
other => panic!("expected a Status event, got {other:?}"),
}
}
}
Loading
Loading