Skip to content

Commit 7a4d689

Browse files
committed
fix(tui): report a confirmed download cancellation
A cancel the engine-manager acknowledged retired the entry but left the status line on "canceling ...", since only a failure updated it. Report the cancellation, and keep it when the pull's own error-free reply settles afterwards. Signed-off-by: Chris Kelsey <ckelsey@nvidia.com>
1 parent 5936d2f commit 7a4d689

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎services/nvpair-tui/ui/engines.go‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ type engineOpMsg struct {
7676
type enginePullDoneMsg struct {
7777
pull enginePull
7878
err error
79+
// canceled marks a cancel the engine-manager acknowledged, which only
80+
// happens once the transfer has stopped.
81+
canceled bool
7982
}
8083

8184
var (
@@ -218,8 +221,11 @@ func (v *enginesView) Update(msg tea.Msg) tea.Cmd {
218221

219222
case enginePullDoneMsg:
220223
v.retire(msg.pull)
221-
if msg.err != nil {
224+
switch {
225+
case msg.err != nil:
222226
v.status = fmt.Sprintf("pull %s %s failed: %s", msg.pull.engine, msg.pull.model, msg.err.Error())
227+
case msg.canceled:
228+
v.status = fmt.Sprintf("pull %s %s: canceled", msg.pull.engine, msg.pull.model)
223229
}
224230
return nil
225231

@@ -340,7 +346,7 @@ func (v *enginesView) decodeCancel(pull enginePull) func(*rpc.Message, error) te
340346
if err != nil {
341347
return engineOpMsg{what: "cancel " + pull.model, engine: pull.engine, err: err}
342348
}
343-
return enginePullDoneMsg{pull: pull}
349+
return enginePullDoneMsg{pull: pull, canceled: true}
344350
}
345351
}
346352

‎services/nvpair-tui/ui/engines_test.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ func TestConfirmedCancelRetiresTheDownload(t *testing.T) {
148148
if _, ok := v.newestPull("ollama"); ok {
149149
t.Error("a confirmed cancel left the download offered as a cancel target")
150150
}
151+
if want := "pull ollama llama3.2: canceled"; v.status != want {
152+
t.Errorf("status = %q, want %q", v.status, want)
153+
}
154+
// The pull's own reply settles after the cancel and carries no error; it
155+
// must not replace the outcome the cancel reported.
156+
v.Update(enginePullDoneMsg{pull: pull})
157+
if want := "pull ollama llama3.2: canceled"; v.status != want {
158+
t.Errorf("status after the pull settled = %q, want %q", v.status, want)
159+
}
151160
}
152161

153162
// A non-terminal frame says the download is still going, so it must leave the

0 commit comments

Comments
 (0)