Color-code install preview: red for errors, yellow for warnings, green for ready#4512
Color-code install preview: red for errors, yellow for warnings, green for ready#4512Softer wants to merge 11 commits into
Conversation
…n for ready Add preview_markup opt-in field to MenuItem with automatic Rich markup escaping for all existing previews. Show missing configs and bootloader errors in red, network warning in yellow, "Ready to install" in green. Move network warning from confirmation dialog to install preview so it is visible earlier.
|
Converted into draft because looks like I found an error. Will check a bit later... |
Text.from_markup() replaces Label(markup=True) to avoid MarkupError on strings containing ["
|
Done, now it works correctly :-) |
|
Renamed InputInfoType to MsgLevelType, added PreviewResult dataclass, removed preview_markup from MenuItem. The widget now maps level to color instead of business logic producing Rich markup. preview_action accepts str | PreviewResult | list[PreviewResult] | None so sections with different levels can be mixed in one preview. |
…ture Update imports from archinstall.tui.ui.* to archinstall.tui.* to match the module reorganization in archlinux#4515 (Pull ui module one level up).
|
@Softer when you addressed the comments I will have another review |
|
@svartkanin Both comments addressed in c5d5135. Also merged master to resolve the conflict status. |
|
@Softer my previous comments have not all been addressed |
@svartkanin Could you clarify which comment you feel wasn't addressed? |
| @@ -152,18 +149,10 @@ def get_install_warnings(self) -> list[str]: | |||
There was a problem hiding this comment.
This should be moved into the global_menu.py now as there's no purpose for this here anymore
| errors += '\n'.join(f'- {m}' for m in missing) | ||
|
|
||
| disk_item = self._item_group.find_by_key('disk_config') | ||
| if disk_item.has_value(): |
There was a problem hiding this comment.
This is not the same logic as the existing code, if there is a bug it'd be good to make these changes incremental to understand why they have changed
| @@ -18,7 +33,7 @@ class MenuItem: | |||
| dependencies: list[str | Callable[[], bool]] = field(default_factory=list) | |||
| dependencies_not: list[str] = field(default_factory=list) | |||
| display_action: Callable[[Any], str] | None = None | |||
| preview_action: Callable[[Self], str | None] | None = None | |||
| preview_action: Callable[[Self], str | PreviewResult | list[PreviewResult] | None] | None = None | |||
There was a problem hiding this comment.
This should be changed to only support the new wrapper type via
preview_action: Callable[[Self], PreviewResult | None] | None = None
The PreviewResult should then handle the different chunks or whatever a preview may return. This will have to be updated for all previews, so I recommend to do this in an incremental way with multiple PRs.
To make life easier we can have something like
@dataclass
class PreviewResult:
messages: list[tuple[str, MsgLevelType]]
| from archinstall.tui.ui.result import Result, ResultType | ||
|
|
||
| ValueT = TypeVar('ValueT') | ||
|
|
||
|
|
||
| _LEVEL_STYLE: dict[MsgLevelType, str] = { |
There was a problem hiding this comment.
Please don't create these global variables. This is a component of the type
class MsgLevelType(Enum):
MsgNone = auto()
MsgInfo = auto()
MsgWarning = auto()
MsgError = auto()
def style(self) -> str:
match self:
case MsgLevelType.MsgInfo:
return 'green'
case MsgLevelType.MsgNone:
return 'white'
case MsgLevelType.MsgWarning:
return 'yellow'
case MsgLevelType.MsgError:
return 'red'
|
@Softer apologies, I just realized that I never sent the comments and they all remained in the pending state. |
The method is only used by GlobalMenu._prev_install_invalid_config(), so it belongs there rather than on the serialization class.
Replace the module-level _LEVEL_STYLE dict in components.py with a style() method on the MsgLevelType enum, following the project convention of encapsulating type-bound logic on the type itself.
PreviewResult.messages is now list[tuple[str, MsgLevelType]], allowing a single result to carry multiple sections with different levels. The preview_action signature drops list[PreviewResult] since the dataclass itself handles multiple sections. Existing str-returning previews still work and will be converted in follow-up PRs.
|
@svartkanin Addressed all comments:
|
Summary
Color codes
Examples
Test plan