Skip to content

Commit 734ce98

Browse files
committed
Ensure border title updates
1 parent c12bed5 commit 734ce98

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/posting/widgets/response/response_area.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class ResponseArea(Vertical):
6060

6161
def on_mount(self) -> None:
6262
self.border_title = "Response"
63+
self._latest_response: httpx.Response | None = None
6364
self.add_class("section")
6465
self.app.theme_change_signal.subscribe(self, self.on_theme_change)
6566

@@ -79,9 +80,11 @@ def compose(self) -> ComposeResult:
7980
yield ResponseTrace()
8081

8182
def on_theme_change(self, _) -> None:
82-
self.refresh()
83+
if self._latest_response:
84+
self.border_title = self._make_border_title(self._latest_response)
8385

8486
def watch_response(self, response: httpx.Response | None) -> None:
87+
self._latest_response = response
8588
if response is None:
8689
return
8790
else:
@@ -130,15 +133,16 @@ def watch_response(self, response: httpx.Response | None) -> None:
130133
else:
131134
self.add_class("error")
132135

133-
style = self.get_component_rich_style("border-title-status")
134-
self.border_title = (
135-
f"Response [{style}] {response.status_code} {response.reason_phrase} [/]"
136-
)
136+
self.border_title = self._make_border_title(response)
137137

138138
settings = SETTINGS.get()
139139
if settings.response.show_size_and_time:
140140
self.border_subtitle = f"{human_readable_size(len(response.content))} in {response.elapsed.total_seconds() * 1000:.2f}[dim]ms[/]"
141141

142+
def _make_border_title(self, response: httpx.Response) -> str:
143+
style = self.get_component_rich_style("border-title-status")
144+
return f"Response [{style}] {response.status_code} {response.reason_phrase} [/]"
145+
142146
@property
143147
def text_editor(self) -> TextEditor:
144148
return self.query_one(TextEditor)

0 commit comments

Comments
 (0)