fix: stabilize request retry table
This commit is contained in:
@@ -640,6 +640,26 @@ def request_retry_wave_summary(row: dict[str, Any]) -> str:
|
|||||||
return "; ".join(summaries)
|
return "; ".join(summaries)
|
||||||
|
|
||||||
|
|
||||||
|
def request_retry_firsts_compact_text(row: dict[str, Any]) -> str:
|
||||||
|
parts = []
|
||||||
|
for first in row.get("reasoning_retry_current_firsts") or []:
|
||||||
|
if not isinstance(first, dict):
|
||||||
|
continue
|
||||||
|
delay = format_duration_ms_as_seconds(first.get("first_delay_ms"))
|
||||||
|
if delay == "-":
|
||||||
|
delay = str(first.get("outcome") or "-").strip() or "-"
|
||||||
|
slot = parse_int_value(first.get("slot"))
|
||||||
|
parts.append(f"{slot if slot is not None else '?'}:{delay}")
|
||||||
|
return " ".join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
def request_first_text(row: dict[str, Any]) -> str:
|
||||||
|
retry_firsts = request_retry_firsts_compact_text(row)
|
||||||
|
if retry_firsts:
|
||||||
|
return retry_firsts
|
||||||
|
return format_duration_ms_as_seconds(row["first_response_delay_ms"])
|
||||||
|
|
||||||
|
|
||||||
def request_retry_note(row: dict[str, Any]) -> str:
|
def request_retry_note(row: dict[str, Any]) -> str:
|
||||||
attempts = as_int(row.get("upstream_attempt_count"))
|
attempts = as_int(row.get("upstream_attempt_count"))
|
||||||
if attempts <= 1:
|
if attempts <= 1:
|
||||||
@@ -670,7 +690,7 @@ def request_row_cells(row: dict[str, Any], text_limits: dict[str, int] | None =
|
|||||||
format_bytes(row.get("request_body_bytes")),
|
format_bytes(row.get("request_body_bytes")),
|
||||||
format_bytes(row.get("response_bytes_received")),
|
format_bytes(row.get("response_bytes_received")),
|
||||||
request_chunk_progress(row),
|
request_chunk_progress(row),
|
||||||
format_duration_ms_as_seconds(row["first_response_delay_ms"]),
|
short_text(request_first_text(row), limits.get("first", 10)),
|
||||||
format_duration_ms_as_seconds(row["duration_ms"]),
|
format_duration_ms_as_seconds(row["duration_ms"]),
|
||||||
request_updated_elapsed(row),
|
request_updated_elapsed(row),
|
||||||
short_text(retry_note, note_width),
|
short_text(retry_note, note_width),
|
||||||
@@ -1067,7 +1087,7 @@ def render_request_detail(row: dict[str, Any]) -> str:
|
|||||||
f"status {row['status_code'] or '-'}",
|
f"status {row['status_code'] or '-'}",
|
||||||
f"upstream {row['upstream_status_code'] or '-'}",
|
f"upstream {row['upstream_status_code'] or '-'}",
|
||||||
f"attempts {row['upstream_attempt_count'] or 0}",
|
f"attempts {row['upstream_attempt_count'] or 0}",
|
||||||
f"first {format_duration_ms_as_seconds(row['first_response_delay_ms'])}",
|
f"first {request_first_text(row)}",
|
||||||
f"duration {format_duration_ms_as_seconds(row['duration_ms'])}",
|
f"duration {format_duration_ms_as_seconds(row['duration_ms'])}",
|
||||||
f"request {format_bytes(row.get('request_body_bytes'))}",
|
f"request {format_bytes(row.get('request_body_bytes'))}",
|
||||||
f"response {format_bytes(row.get('response_bytes_received'))}",
|
f"response {format_bytes(row.get('response_bytes_received'))}",
|
||||||
@@ -1469,8 +1489,8 @@ def run_textual(
|
|||||||
("3", "show_logs", "Logs"),
|
("3", "show_logs", "Logs"),
|
||||||
("4", "show_profiles", "Profiles"),
|
("4", "show_profiles", "Profiles"),
|
||||||
("m", "toggle_request_table_density", "Wide/Compact"),
|
("m", "toggle_request_table_density", "Wide/Compact"),
|
||||||
(",", "select_previous_request_column", "Prev Column"),
|
("comma", "select_previous_request_column", "Prev Column"),
|
||||||
(".", "select_next_request_column", "Next Column"),
|
("full_stop", "select_next_request_column", "Next Column"),
|
||||||
("v", "toggle_request_column_visibility", "Show/Hide Column"),
|
("v", "toggle_request_column_visibility", "Show/Hide Column"),
|
||||||
("c", "sort_requests_by_selected_column", "Sort Column"),
|
("c", "sort_requests_by_selected_column", "Sort Column"),
|
||||||
("shift+c", "toggle_request_sort_direction", "Sort Asc/Desc"),
|
("shift+c", "toggle_request_sort_direction", "Sort Asc/Desc"),
|
||||||
|
|||||||
@@ -249,6 +249,7 @@ class CodexRetryGatewayTUITests(unittest.TestCase):
|
|||||||
self.assertEqual(row["reasoning_retry_current_width"], 2)
|
self.assertEqual(row["reasoning_retry_current_width"], 2)
|
||||||
self.assertEqual(len(row["reasoning_retry_current_firsts"]), 2)
|
self.assertEqual(len(row["reasoning_retry_current_firsts"]), 2)
|
||||||
self.assertEqual(mod.request_retry_round_text(row), "3(2)")
|
self.assertEqual(mod.request_retry_round_text(row), "3(2)")
|
||||||
|
self.assertIn("1:1.2s", mod.request_first_text(row))
|
||||||
self.assertIn("slot 1", mod.request_retry_wave_summary(row))
|
self.assertIn("slot 1", mod.request_retry_wave_summary(row))
|
||||||
self.assertIn("retry round 3(2)", mod.render_request_detail(row))
|
self.assertIn("retry round 3(2)", mod.render_request_detail(row))
|
||||||
self.assertIn("current wave slot 1 first 1.2s", mod.render_request_detail(row))
|
self.assertIn("current wave slot 1 first 1.2s", mod.render_request_detail(row))
|
||||||
|
|||||||
Reference in New Issue
Block a user