hh
This commit is contained in:
@@ -2476,6 +2476,43 @@ class PipelineExecutor:
|
||||
stage_args = stage_tokens[1:]
|
||||
|
||||
if cmd_name == "@":
|
||||
# Special-case get-tag tables: `@ | add-tag ...` should target the
|
||||
# underlying file subject once, not each emitted TagItem row.
|
||||
try:
|
||||
next_cmd = None
|
||||
if stage_index + 1 < len(stages) and stages[stage_index + 1]:
|
||||
next_cmd = str(stages[stage_index + 1][0]).replace("_", "-").strip().lower()
|
||||
|
||||
current_table = None
|
||||
try:
|
||||
current_table = ctx.get_current_stage_table() or ctx.get_last_result_table()
|
||||
except Exception:
|
||||
current_table = None
|
||||
|
||||
source_cmd = str(getattr(current_table, "source_command", "") or "").replace("_", "-").strip().lower()
|
||||
is_get_tag_table = source_cmd == "get-tag"
|
||||
|
||||
if is_get_tag_table and next_cmd in {"add-tag"}:
|
||||
subject = ctx.get_last_result_subject()
|
||||
if subject is not None:
|
||||
piped_result = subject
|
||||
try:
|
||||
subject_items = subject if isinstance(subject, list) else [subject]
|
||||
ctx.set_last_items(subject_items)
|
||||
except Exception:
|
||||
logger.exception("Failed to set last_items from get-tag subject during @ handling")
|
||||
if pipeline_session and worker_manager:
|
||||
try:
|
||||
worker_manager.log_step(
|
||||
pipeline_session.worker_id,
|
||||
"@ used get-tag table subject for add-tag"
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("Failed to record pipeline log step for '@ used get-tag table subject for add-tag' (pipeline_session=%r)", getattr(pipeline_session, 'worker_id', None))
|
||||
continue
|
||||
except Exception:
|
||||
logger.exception("Failed to evaluate get-tag @ subject special-case")
|
||||
|
||||
# Prefer piping the last emitted/visible items (e.g. add-file results)
|
||||
# over the result-table subject. The subject can refer to older context
|
||||
# (e.g. a playlist row) and may not contain store+hash.
|
||||
@@ -2870,7 +2907,16 @@ class PipelineExecutor:
|
||||
progress_ui.begin_pipe(pipe_idx, total_items=1)
|
||||
|
||||
# RUN THE CMDLET
|
||||
cmd_fn(piped_result, stage_args, config)
|
||||
ret_code = cmd_fn(piped_result, stage_args, config)
|
||||
if ret_code is not None:
|
||||
try:
|
||||
normalized_ret = int(ret_code)
|
||||
except Exception:
|
||||
normalized_ret = 0
|
||||
if normalized_ret != 0:
|
||||
pipeline_status = "failed"
|
||||
pipeline_error = f"Stage '{cmd_name}' failed with exit code {normalized_ret}"
|
||||
return
|
||||
|
||||
# Pipeline overlay tables (e.g., get-url detail views) need to be
|
||||
# rendered when running inside a pipeline because the CLI path
|
||||
|
||||
@@ -70,6 +70,15 @@ def get_result_table_row_style(row_index: int) -> str:
|
||||
return f"{text_color} on {bg_color}"
|
||||
|
||||
|
||||
def apply_result_table_layout(table: Any) -> None:
|
||||
"""Apply compact, flush column layout options to a Rich table."""
|
||||
table.padding = (0, 1)
|
||||
if hasattr(table, "pad_edge"):
|
||||
table.pad_edge = False
|
||||
if hasattr(table, "collapse_padding"):
|
||||
table.collapse_padding = True
|
||||
|
||||
|
||||
def _sanitize_cell_text(value: Any) -> str:
|
||||
"""Coerce to a single-line, tab-free string suitable for terminal display."""
|
||||
if value is None:
|
||||
@@ -1374,6 +1383,9 @@ class Table:
|
||||
empty,
|
||||
title=Text(str(self.title), style=RESULT_TABLE_HEADER_STYLE),
|
||||
border_style=RESULT_TABLE_BORDER_STYLE,
|
||||
padding=(0, 0),
|
||||
expand=False,
|
||||
style="on #ffffff",
|
||||
)
|
||||
if self.title
|
||||
else empty
|
||||
@@ -1391,10 +1403,14 @@ class Table:
|
||||
show_header=True,
|
||||
header_style=RESULT_TABLE_HEADER_STYLE,
|
||||
border_style=RESULT_TABLE_BORDER_STYLE,
|
||||
box=SIMPLE,
|
||||
expand=True,
|
||||
box=None,
|
||||
expand=False,
|
||||
show_lines=False,
|
||||
padding=(0, 1),
|
||||
pad_edge=False,
|
||||
collapse_padding=True,
|
||||
)
|
||||
apply_result_table_layout(table)
|
||||
|
||||
if not self.interactive:
|
||||
table.add_column("#", justify="right", no_wrap=True)
|
||||
@@ -1410,6 +1426,8 @@ class Table:
|
||||
header = header_by_key.get(name, str(name).upper())
|
||||
if name.lower() == "ext":
|
||||
table.add_column(header, no_wrap=True)
|
||||
elif name.lower() == "tag":
|
||||
table.add_column(header, overflow="fold")
|
||||
else:
|
||||
table.add_column(header)
|
||||
|
||||
@@ -1430,6 +1448,9 @@ class Table:
|
||||
renderable,
|
||||
title=Text(str(self.title), style=RESULT_TABLE_HEADER_STYLE),
|
||||
border_style=RESULT_TABLE_BORDER_STYLE,
|
||||
padding=(0, 0),
|
||||
expand=False,
|
||||
style="on #ffffff",
|
||||
)
|
||||
if self.title
|
||||
else renderable
|
||||
|
||||
@@ -15,6 +15,7 @@ logger = logging.getLogger(__name__)
|
||||
from SYS.result_table import (
|
||||
RESULT_TABLE_BORDER_STYLE,
|
||||
RESULT_TABLE_HEADER_STYLE,
|
||||
apply_result_table_layout,
|
||||
get_result_table_row_style,
|
||||
)
|
||||
from SYS.result_table_api import ColumnSpec, ResultModel, ResultTable, Renderer
|
||||
@@ -39,10 +40,19 @@ class RichRenderer(Renderer):
|
||||
show_header=True,
|
||||
header_style=RESULT_TABLE_HEADER_STYLE,
|
||||
border_style=RESULT_TABLE_BORDER_STYLE,
|
||||
box=None,
|
||||
padding=(0, 1),
|
||||
pad_edge=False,
|
||||
collapse_padding=True,
|
||||
expand=False,
|
||||
)
|
||||
apply_result_table_layout(table)
|
||||
cols = list(columns)
|
||||
for col in cols:
|
||||
table.add_column(col.header)
|
||||
if str(col.header or "").strip().lower() == "tag":
|
||||
table.add_column(col.header, overflow="fold")
|
||||
else:
|
||||
table.add_column(col.header)
|
||||
|
||||
for row_idx, r in enumerate(rows):
|
||||
cells = []
|
||||
|
||||
Reference in New Issue
Block a user