-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
navigable robots table #2140
navigable robots table #2140
Conversation
5435ef4
to
77a20b5
Compare
3a18bb6
to
76277e2
Compare
76277e2
to
7cc7b13
Compare
deb58d0
to
e3d0920
Compare
e3d0920
to
b75438e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is neat. 👍
I have some nitpicks about the refactoring. It would have been nicer if that was a separate Pull Request, so that the changes here were easier to see.
The view seems to work well, but I was initially confused by the controls. It would be nice if there was a hint in UI about which keyboard shortcuts are used to control it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
I agree the controls seem a bit confusing. To be consistent with the rest of the UI, I think Tab should only switch between focus within a single panel, not change which panel is displayed. I suggest having Enter on a highlighted robot open the robot details panel (instead of Tab), then Tab within the robot details panel just switches between the different things to focus in that panel; Esc will close it and return to the list of all robots.
@@ -273,6 +280,10 @@ applyWhen :: Bool -> (a -> a) -> a -> a | |||
applyWhen True f x = f x | |||
applyWhen False _ x = x | |||
|
|||
applyJust :: Maybe (a -> a) -> a -> a | |||
applyJust Nothing x = x | |||
applyJust (Just f) x = f x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple thoughts/observations on applyJust
:
applyJust = fromMaybe id
- It can be generalized to
compose :: Foldable t => t (a -> a) -> a -> a; compose = foldr (.) id
.
I am not sure whether it is worth changing anything based on these observations but I thought they were at least worth mentioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I was also intrigued by this helper function.
Is any variant of this function available in our dependencies? 🤔 The only hoogle hit is thread
from some alternative prelude.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabControlFooter :: Widget Name | ||
tabControlFooter = hCenter $ withAttr italicAttr $ txt "NOTE: [Tab] toggles focus between panes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make this polymorphic in the Name
it could go to Swarm.TUI.View.Util
, I think.
But maybe we will need a common set of shared view parts anyway.
@@ -8,52 +8,14 @@ | |||
-- SPDX-License-Identifier: BSD-3-Clause | |||
module Swarm.TUI.Model.UI ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't follow this consistently (yet), but it might be nice to re-export the whole Swarm.TUI.Model.UI.Gameplay
here, so that there are fewer changes in the imports.
It's a drop of water in the ocean though, so feel free to ignore this suggestion.
* use `watch` to avoid busy-waiting for the bit seed to grow Prompted by #2140, which shows hundreds of `ishere` calls. | Before | After | |--------|--------| | <img width="143" alt="Screenshot 2024-09-15 at 10 02 51 PM" src="https://github.com/user-attachments/assets/174827e4-9371-4405-a6c2-dd20233e4588"> | <img width="143" alt="Screenshot 2024-09-15 at 10 01 32 PM" src="https://github.com/user-attachments/assets/a1d02d16-487c-46d0-b5f1-5aaf4da111cb"> | This should make the testing scenario take 0.1s from previous 0.5s. You can test it with: ```sh cabal run swarm-integration -O0 -- -p '/Testing\/562-lodestone/ ```
479a682
to
cbaaf22
Compare
I have now updated the controls to behave as described. It feels a bit hacky though---perhaps at some point we would introduce the concept of a "stack" of dialogs so that things like the Esc would simply pop the top dialog from the stack, rather than special-casing logic for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works nicely, thanks @kostmo. 👍
Continuing with the replacements started in this discussion: #2140 (comment)
Towards #1341. Should also be useful for #2133.
Uses the
brick-tabular-list
package to render the F2 robots dialog as a navigable list with tabular formatting. Hitting Tab on a selected row shows details for that robot.Also:
Swarm.TUI.Model.UI
intoSwarm.TUI.Model.UI.Gameplay
Name
type fromSwarm.TUI.Model
maximum
with the safermaximum0
applyJust
combinatorTesting
Showing a large robots list
and with extra column:
Showing a small robots list with details view and logs
Log view: