Repository navigation
fix(tui): report autoslice slices that Kite rejected - #7
Merged
Merged
Conversation
mr-karan
force-pushed
the
fix/tui-autoslice-slices
branch
from
November 16, 2026 06:53
9323e08 to
ab385fb
Compare
When an order from the TUI ticket is autosliced, show an error toast if Kite rejects any slice. The toast gives the failed slice count and each failed slice's reason. Slices are numbered as in the CLI: the top-level order is slice 1 and children are slices 2 onwards. Share the CLI's slice reading and wording from src/app/render.rs. The AMO retry reply is read the same way.
mr-karan
force-pushed
the
fix/tui-autoslice-slices
branch
from
November 16, 2026 07:08
ab385fb to
885c85f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows up #5, which fixed this for
kite orders place --autosliceand left the TUI for a separate PR.What was wrong
When an order placed from the TUI order ticket is autosliced, the TUI shows
[ OK ] order placed: <order_id>even if Kite rejected some of the slices.spawn_place_orderkeeps onlyorder_idfrom the reply, sochildrenis never read. The ticket also sendsautoslice=trueby itself when the quantity is above the freeze quantity (autoslice_forced), so this can happen even if the user never turned autoslice on.With
mock_responses/autoslice_response.json, where slice 4 of 5 fails with aMarginException, the toast row at 160 columns was:Fix
spawn_place_ordernow reads the reply's slices with the CLI's code from #5. If a slice failed, or non-nullchildrenisn't an array, the toast becomes an error toast, as for a bulk cancel where some orders failed. It gives the CLI's headline warning, then each failed slice:N of M slices failed,could not read slice results, andfailed: <message> (<error_type>)withsanitize_errorapplied.src/app/render.rs, the CLI headline's count/unreadable check moves intoslice_warning. The newslice_problemsjoins that warning with each failed slice into one line for the TUI. CLI output doesn't change; fix(orders): list autoslice slices and flag failed ones #5's golden files and unit tests pass as they are.Ctrl-L) keeps the full line.place_with_amo_fallbackis read the same way.I also added an
[Unreleased]changelog entry.What this assumes about Kite's reply
data.order_idplusdata.children, and each child has either anorder_idor anerrorwithcode,error_type,messageanddata. Sources:c7a8123("update autoslice response to v2 format").OrderResponse/OrderChild.datais an array.)order_idis slice 1, and children are slices 2..n. Source: your247a063in fix(orders): list autoslice slices and flag failed ones #5, and fix(orders): list autoslice slices and flag failed ones #5's description: "kite-tradereturnsout[0].OrderIDas the top-level ID andout[1:]as children".Open questions
REJECTED? The docs only say that placed slices appear there. If failed slices don't, this toast and the event log are the only places the TUI shows the rejection.POST /orders/amoautoslice, and reply in the same shape? The AMO retry resends the original form, includingautoslice=true. This PR readschildrenfrom whichever reply comes back, so it needs no change either way. The AMO test triggers the retry with the existing tests'switch_to_amoreply, and uses the regular-order fixture as the AMO reply.Testing
a_rejected_autoslice_slice_is_reportedinsrc/tui/app/regressions.rs.test_support(open_and_review, theny), with the Kite client pointed at an httpmock server through a newmock_apphelper.autoslice=true.ee3bf08, it fails:left: (Success, "order placed: 1914227164488687616").an_amo_retry_reports_failed_autoslice_slices_tooinsrc/tui/data.rs. A regular order gets a 400 with theswitch_to_amohint, and the AMO retry, matched onautoslice=trueandtag=switch_to_amo, returns the fixture. The failed slice is still reported.slice_problems_number_failed_slices_from_twoinsrc/app/render.rs. It covers absent, null and empty children, all slices placed, non-array children, and two failed slices numbered 2 and 4.cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,TERM=xterm-256color cargo test --workspace(1,650 + 47 + 12 passed, one ignored) andscripts/test-release-tools.shall pass.Fixes #6