Skip to content

Commit 7b5dddf

Browse files
authored
Fix truncated package metadata in additional packages preview (#3580) (#4510)
* Fix truncated package metadata in additional packages preview (#3580) * Simplify package info fix: use rstrip and CSS wrap instead of env var plumbing * Apply preview text wrap conditionally via wrap_preview parameter * Add missing wrap-preview CSS to OptionListScreen and pass parameter through SelectMenu
1 parent dcc38fe commit 7b5dddf

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

archinstall/lib/menu/helpers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(
2020
preview_location: Literal['right', 'bottom'] | None = None,
2121
multi: bool = False,
2222
enable_filter: bool = False,
23+
wrap_preview: bool = False,
2324
):
2425
self._header = header
2526
self._title = title
@@ -29,6 +30,7 @@ def __init__(
2930
self._preview_location = preview_location
3031
self._multi = multi
3132
self._enable_filter = enable_filter
33+
self._wrap_preview = wrap_preview
3234

3335
async def show(self) -> Result[ValueT]:
3436
if self._multi:
@@ -39,6 +41,7 @@ async def show(self) -> Result[ValueT]:
3941
allow_reset=self._allow_reset,
4042
preview_location=self._preview_location,
4143
enable_filter=self._enable_filter,
44+
wrap_preview=self._wrap_preview,
4245
).run()
4346
else:
4447
result = await OptionListScreen[ValueT](
@@ -49,6 +52,7 @@ async def show(self) -> Result[ValueT]:
4952
allow_reset=self._allow_reset,
5053
preview_location=self._preview_location,
5154
enable_filter=self._enable_filter,
55+
wrap_preview=self._wrap_preview,
5256
).run()
5357

5458
if result.type_ == ResultType.Reset:

archinstall/lib/models/packages.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ class AvailablePackage(BaseModel):
132132
def longest_key(self) -> int:
133133
return max(len(key) for key in self.model_dump().keys())
134134

135-
# return all package info line by line
136135
def info(self) -> str:
137136
output = ''
138137
for key, value in self.model_dump().items():

archinstall/lib/packages/packages.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def installed_package(package: str) -> LocalPackage | None:
1414
try:
1515
package_info = []
1616
for line in Pacman.run(f'-Q --info {package}'):
17-
package_info.append(line.decode().strip())
17+
package_info.append(line.decode().rstrip())
1818

1919
return _parse_package_output(package_info, LocalPackage)
2020
except SysCallError:
@@ -53,7 +53,7 @@ def available_package(package: str) -> AvailablePackage | None:
5353
try:
5454
package_info: list[str] = []
5555
for line in Pacman.run(f'-S --info {package}'):
56-
package_info.append(line.decode().strip())
56+
package_info.append(line.decode().rstrip())
5757

5858
return _parse_package_output(package_info, AvailablePackage)
5959
except SysCallError:
@@ -79,7 +79,7 @@ def list_available_packages(
7979
debug(f'Failed to sync Arch Linux package database: {e}')
8080

8181
for line in Pacman.run('-S --info'):
82-
dec_line = line.decode().strip()
82+
dec_line = line.decode().rstrip()
8383
current_package.append(dec_line)
8484

8585
if dec_line.startswith('Validated'):
@@ -187,6 +187,7 @@ async def select_additional_packages(
187187
multi=True,
188188
preview_location='right',
189189
enable_filter=True,
190+
wrap_preview=True,
190191
).show()
191192

192193
match pck_result.type_:

archinstall/tui/components.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ class OptionListScreen(BaseScreen[ValueT]):
200200
color: white;
201201
text-style: bold;
202202
}
203+
204+
.wrap-preview {
205+
width: 100%;
206+
height: auto;
207+
}
203208
"""
204209

205210
def __init__(
@@ -211,13 +216,15 @@ def __init__(
211216
allow_reset: bool = False,
212217
preview_location: Literal['right', 'bottom'] | None = None,
213218
enable_filter: bool = False,
219+
wrap_preview: bool = False,
214220
):
215221
super().__init__(allow_skip, allow_reset)
216222
self._group = group
217223
self._header = header
218224
self._title = title
219225
self._preview_location = preview_location
220226
self._filter = enable_filter
227+
self._wrap_preview = wrap_preview
221228
self._show_frame = False
222229

223230
self._options = self._get_options()
@@ -280,7 +287,10 @@ def compose(self) -> ComposeResult:
280287
with Container():
281288
yield option_list
282289
yield Rule(orientation=rule_orientation)
283-
yield ScrollableContainer(Label('', id='preview_content', markup=False))
290+
preview_label = Label('', id='preview_content', markup=False)
291+
if self._wrap_preview:
292+
preview_label.add_class('wrap-preview')
293+
yield ScrollableContainer(preview_label)
284294

285295
if self._filter:
286296
yield Input(placeholder='/filter', id='filter-input')
@@ -433,6 +443,11 @@ class SelectListScreen(BaseScreen[ValueT]):
433443
color: white;
434444
text-style: bold;
435445
}
446+
447+
.wrap-preview {
448+
width: 100%;
449+
height: auto;
450+
}
436451
"""
437452

438453
def __init__(
@@ -443,13 +458,15 @@ def __init__(
443458
allow_reset: bool = False,
444459
preview_location: Literal['right', 'bottom'] | None = None,
445460
enable_filter: bool = False,
461+
wrap_preview: bool = False,
446462
):
447463
super().__init__(allow_skip, allow_reset)
448464
self._group = group
449465
self._header = header
450466
self._preview_location = preview_location
451467
self._show_frame = False
452468
self._filter = enable_filter
469+
self._wrap_preview = wrap_preview
453470

454471
self._selected_items: list[MenuItem] = self._group.selected_items
455472
self._options: list[Selection[MenuItem]] = self._get_selections()
@@ -510,7 +527,10 @@ def compose(self) -> ComposeResult:
510527
with Container():
511528
yield selection_list
512529
yield Rule(orientation=rule_orientation)
513-
yield ScrollableContainer(Label('', id='preview_content', markup=False))
530+
preview_label = Label('', id='preview_content', markup=False)
531+
if self._wrap_preview:
532+
preview_label.add_class('wrap-preview')
533+
yield ScrollableContainer(preview_label)
514534

515535
if self._filter:
516536
yield Input(placeholder='/filter', id='filter-input')

0 commit comments

Comments
 (0)