mitmproxy icon indicating copy to clipboard operation
mitmproxy copied to clipboard

mitmproxy may not update macOS Terminal app's window title

Open thisisgk opened this issue 4 months ago • 3 comments

Problem Description

I usually run mitmproxy on macOS Terminal app. At times when I start mitmproxy, Terminal app's window title shows different directory than the one where I start mitmproxy. It turns out that the directory shown is where I previously ran command like man or less which draws on alternate screen. Just a minor issue, but it's a bit confusing.

Steps to reproduce the behavior:

  1. in Terminal app's "Profiles", check the box to show "Working directory or document" in "Window" and select terminal as "xterm-256color" in "Advanced". (Both should be the default.)
  2. run man or less to draw on alternate screen.
  3. cd to somewhere else.
  4. start mitmproxy. Window title should show the directory at step 2.

What I tried and found: I tried the following code in Urwid Tutorial with urwid-mitmproxy and urwid at the above step 4.

import urwid

txt = urwid.Text("Hello World")
fill = urwid.Filler(txt, "top")
loop = urwid.MainLoop(fill)
loop.run()

Window title is shown as expected with urwid. The reason of the difference seems to be urwid PR#556. Using this PR's escape sequence, window title is updated with urwid-mitmproxy as well.

urwid.escape.SWITCH_TO_ALTERNATE_BUFFER = "\x1b[?1049h"
urwid.escape.RESTORE_NORMAL_BUFFER = "\x1b[?1049l"

Will it be possible to take this urwid fix into urwid-mitmproxy? Sorry for the report here, urwid-mitmproxy has no issues section.

System Information

Mitmproxy: 10.2.2 Python: 3.12.2 OpenSSL: OpenSSL 3.1.4 24 Oct 2023 Platform: macOS-10.13.6-x86_64-i386-64bit

urwid-mitmproxy: 2.1.2.1

thisisgk avatar Feb 28 '24 05:02 thisisgk

It looks like urwid is very much maintained again, which is awesome to see! 🎉🎉🎉

Could you test urwid with urwid 2.6.6 and report back if there are any issues with mitmproxy? We'd be super duper happy to switch back to vanilla urwid now that my Windows PR has been merged.

mhils avatar Feb 28 '24 09:02 mhils

I uninstalled urwid-mitmproxy, installed urwid (version 2.6.7 was installed, and typing-extensions and wcwidth were also installed) and used mitmproxy for a while. No problems so far, and needless to say, window title is fine. Of course all I can say is "it seems to be working fine on macOS Terminal app".

thisisgk avatar Feb 28 '24 13:02 thisisgk

Great, thanks! I'll test Windows when I get to it these days, so far it looks like we can switch back to stock urwid thanks to @penguinolog's awesome maintenance efforts there! 🙌

mhils avatar Feb 28 '24 14:02 mhils