Bug 471353

Summary: Using ANSI codes to set the title has a delay of one title
Product: [Applications] konsole Reporter: sergio.costas <sergio.costas>
Component: emulationAssignee: Konsole Developer <konsole-devel>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description sergio.costas@canonical.com 2023-06-22 18:58:54 UTC
SUMMARY
***
When using ANSI codes to set the window title, there is a delay of one title. This is: setting once the title doesn't change it; setting it twice shows the first title, not the second; setting it three times shows the second title, not the third one.
***


STEPS TO REPRODUCE
1. Enable showing the terminal title in the window bar (in the settings)
2. Run in Konsole: echo -en "\033]2;New terminal title 1\007"
3. Run in Konsole: echo -en "\033]2;New terminal title 2\007"

OBSERVED RESULT
After running the first echo command, the window title won't change. After running the second command, the title from the first command ("New terminal title 1") will be shown in the window title.

EXPECTED RESULT
After running the first echo command, the window title should change to "New terminal title 1". After running the second echo command, the window title should change to "New terminal title 2".

SOFTWARE/OS VERSIONS
Ubuntu Linux; Konsole 4:22.12.3-0ubuntu1; libqt=5.15.8
ADDITIONAL INFORMATION
Comment 1 sergio.costas@canonical.com 2023-06-22 19:06:50 UTC
Running this script also shows the bug:

    #!/bin/sh

    echo -n "\033]2;New terminal title1\007"
    sleep 2
    echo -n "\033]2;New terminal title2\007"
    sleep 2
    echo -n "\033]2;New terminal title3\007"
    sleep 2

When launching it, the title changes to "New terminal title1", and after six seconds, it changes to "New terminal title3" when it ends and returns to the command line. The "New terminal title2" title is never shown.
Comment 2 sergio.costas@canonical.com 2023-06-22 19:13:56 UTC
This python3 program also reproduces the problem:

    #!/usr/bin/env python3

    import time

    print("\033]2;Window title 1\007", flush=True, end="")
    time.sleep(2)
    print("\033]2;Window title 2\007", flush=True, end="")
    time.sleep(2)
    print("\033]2;Window title 3\007", flush=True, end="")
    time.sleep(2)