TUI: persist last-session UI state (active tab, selected instrument, sort, filters, depth preset, etc.)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
Bắt đầu bằng cách xác định mô hình trạng thái TUI, luồng shutdown và helper mutate_tui_toml_at hiện có được dùng cho các round trip của tui.toml. Trước tiên, triển khai Phase 1: lưu bền vững active_tab, selected_instrument, market.sort và market.category trong [session], đồng thời giữ nguyên các khóa không liên quan. Thêm hoặc mở rộng các bài kiểm thử xung quanh điểm nối TOML có thể kiểm thử và xác minh rằng các giá trị bị thiếu, sai định dạng hoặc đã lỗi thời sẽ an toàn quay về giá trị mặc định.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The TUI currently forgets all in-session UI state on quit. Every relaunch drops you on Market tab / default sort / BTC_USDT selected / depth 50 / category Spot, regardless of where you were when you quit. For power users who live in the TUI across many short sessions, this is friction.
Add a best-effort state-restore layer that remembers the last session's UI state and restores it on launch.
What to persist
Navigation
- Active tab (Market / Portfolio / Orders / History / Watchlist / Positions).
- Selected instrument on Market / Watchlist / Positions (falls back gracefully if the instrument is no longer available).
Market tab
- Category filter (Spot / Perpetual / Futures / ...).
- Sort field + direction (Volume / Change / Price / Name, asc/desc).
- Search query? — probably NOT; search feels ephemeral. Up for debate.
- View mode: Table / Detail / Chart / Compare? — probably NOT; rehydrating straight into a Compare view is jarring. Up for debate.
- Timeframe (1m / 5m / ... / 1D).
- Book depth preset (10 / 50 / 150) — from #26.
- Heatmap on/off.
- Volume unit (USD / Notional).
- Split-view state (table + chart).
Help overlay
- Last shortcuts page viewed? — probably NOT; #30 explicitly resets to page 1 every open, and that's the right UX. This one is low-value.
Orders / History / Portfolio
- Sort field + direction on any tab that has sortable columns.
- History pagination position? — probably NOT; data moves forward between sessions, so "resume on page 3" is stale.
Compare view
- List of pinned instruments (if view_mode is persisted).
Where to persist
~/.config/cdcx/tui.toml — same file #23 (watchlist) and settings already round-trip. One new top-level [session] table:
[session]
active_tab = \"market\"
selected_instrument = \"ETH_USDT\"
volume_unit = \"usd\"
split_view = false
[session.market]
category = \"PERPETUAL_SWAP\"
sort_field = \"volume\"
sort_asc = false
timeframe = \"4h\"
book_depth = 50
heatmap = false
Reuse the mutate_tui_toml_at helper from #28 so unrelated keys (theme, tick_rate, watchlist, custom themes) are preserved.
When to persist
Option A — on every change: write on each mutation. Simple, but O(n) disk writes per session.
Option B — on quit only: single write in the shutdown path. Lower-friction, but any crash loses the session.
Option C — debounced (every ~5s if dirty): best of both. Adds complexity.
Recommendation: Option B to start. Fast, simple, one integration point. If we notice state loss from crashes later, upgrade to C.
Scope / sequencing
Land in small increments, each an independently-useful PR:
- Phase 1 (minimum useful): active_tab + selected_instrument + market.sort + market.category. Roughly half the annoyance, small diff.
- Phase 2: timeframe, book_depth, heatmap, volume_unit, split_view.
- Phase 3: sort state on Orders / Portfolio / Positions, compare-view instrument list.
Deliberately NOT in scope for the first cut: search query, help overlay page, history pagination, workflow modals, spotlight.
Non-goals
- Not a full settings-UI-exposed preference system. This is silent state capture; the user doesn't configure it.
- Not a per-profile state store (yet). One global
[session]block. Add per-profile later if someone hits the edge case. - Not a remote-sync system. Local file only.
Risk
- Stale instrument on restore: if
selected_instrumentwas delisted, fall back to index 0 of the filtered list. Don't panic, don't toast. - Schema evolution: treat
[session]as a purely additive, tolerant block. Missing keys → sensible defaults. Unknown keys → ignore. Malformed values → fall through to default and don't error the user. - File-size creep: negligible. Even with all phases, the
[session]block stays under a few hundred bytes.
Related
- #23 — established the
tui.tomlround-trip pattern +save_watchlist_attestable seam. - #26 —
book_depthpreset that would become persisted under[session.market]. - #30 — help overlay pagination (explicitly NOT persisted; called out here to avoid confusion).
- Ngôn ngữ chính
- Rust
- Star
- 27
- Fork
- 9
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của crypto-com/cdcx-cli
-
TUI: orderbook renders unreadable colours on macOS Terminal.app (truecolor RGB not supported)Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
crypto-com/cdcx-cli#36 ·
-
TUI: press Enter on book-cursor level to prefill place-order modalCó thể đã có người làm @llcro đã nhận 183 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
crypto-com/cdcx-cli#34 ·
Tất cả issue của crypto-com/cdcx-cli
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
Maintainer thường phản hồi trong vòng 1 ngày
-
A match arm above the largest i64 is compared as 0Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
DioxusLabs/dioxus#6063 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`nsh-core` fails to compile when taffy's default `calc` feature is enabled elsewhere in the graphĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
longbridge/nsh#966 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Windows docs: pin a tested ConPTY version for Kitty graphics; 1.25.260930003 corrupts large uploadsĐang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
raphamorim/rio#2021 ·
Maintainer thường phản hồi trong vòng 1 ngày