https://blogs.gnome.org/chergert/2023/12/14/prompt/ Skip to content Happenings in GNOME Details of Christian's work on GNOME Menu and widgets Search for: [ ] [Search] Recent Posts * Prompt * Toby is Recovering in ER ICU * VTE performance improvements * What have frame-pointers given us anyway * Flamegraphs for Sysprof Recent Comments * antoniof on Builder GTK 4 Porting, Part II * chergert on Private Flatpak installations in Builder * Alexander Mikhaylenko on Private Flatpak installations in Builder * chergert on How to use Sysprof to... * Alexander Mikhaylenko on How to use Sysprof to... Archives * December 2023 * October 2023 * August 2023 * July 2023 * June 2023 * March 2023 * February 2023 * December 2022 * November 2022 * September 2022 * July 2022 * June 2022 * May 2022 * April 2022 * March 2022 * February 2022 * January 2022 * December 2021 * November 2021 * October 2021 * August 2021 * July 2021 * June 2021 * March 2021 * February 2021 * December 2020 * September 2020 * March 2020 * February 2020 * January 2020 * August 2019 * July 2019 * June 2019 * May 2019 * April 2019 * March 2019 * January 2019 * October 2018 * August 2018 * July 2018 * June 2018 * May 2018 * April 2018 * March 2018 * February 2018 * January 2018 * December 2017 * November 2017 * October 2017 * September 2017 * August 2017 * July 2017 * June 2017 * May 2017 * March 2017 * February 2017 * November 2016 * October 2016 * September 2016 * August 2016 * July 2016 * May 2016 * April 2016 * February 2016 * January 2016 * December 2015 * October 2015 * August 2015 Categories * Bonsai * Builder * Flatpak * GNOME Shell * gtk+ * GtkSourceView * Pets * Rust * Security * Sysprof * Uncategorized * Xdg-App Meta * Register * Log in * Entries feed * Comments feed * WordPress.org Prompt Prompt is a terminal that marries the best of GNOME Builder's seamless container support, the beauty of GNOME Text Editor, and the robustness of VTE. I like to think of it as a companion terminal to Builder. Though it's also useful for immutable/container-oriented desktops like Fedora Silverblue or Project Bluefin where containers are front-and-center. A screenshot of Prompt with a menu open showing a list of available containers to spawn a new terminal shell within. This came out of a prototype I made for the GNOME Builder IDE nearly a decade ago. We already had all the container abstractions so why not expose them as a Terminal Workspace? Prompt extracts the container portion of the code-foundry into a standalone program. My prototype didn't go anywhere in recent years because I was conflicted. I have a high performance bar for software I ship and VTE wasn't there yet on Wayland-based compositors which I use. But if you frequent this blog you already know that I reached out to the meticulous VTE maintainers and helped them pick the right battles to nearly double performance this GNOME cycle. I also ported gnome-terminal to GTK 4 which provided me ample opportunity to see where and how containers would integrate from an application perspective. I designed Prompt to be Flatpak-first. That has design implications if you want a robust feature-set. Typically an application is restricted to the PID and PTY namespace within the Flatpak sandbox even if you're capable of executing processes on the host. That means using TTY API like tcgetpgrp() becomes utterly useless when the kernel ioctl() returns you a PID of 0 (as it's in a different namespace). Notably, 0 is the one value tcgetpgrp() is not documented to return. How fun! To give Prompt the best chance at tracking containers and foreground processes a prompt-agent runs from the host system. It is restricted to very old versions of GLib/GObject/GIO and JSON-GLib because we know that /usr/bin/flatpak will already require them. Using those libraries instead of certain GLibc API helps us in situations where GLibc is only forward-compatible and not backwards-compatible. Combined with point-to-point D-Bus serialization on top of a socketpair() we have a robust way to pass file-descriptors between the agent and the UI process and we'll use that a bunch. There are a lot of little tricks in here to keep things fast and avoid energy-drain. For example, process tracking is done with a combination of exponential-backoff and re-triggering based on either new content arriving or certain key-presses. It gives a very low-latency feeling to the sudo/ssh feature I love from Console, albeit with less overhead. One thing I find helpful with Builder is that when I come back to it my project session is right there. So this has session support too. It will restore your tabs/containers how they were before. So if you have a similar workflow you might find that useful. If not? Just turn it off in Preferences. I want to have a bit of fun because right now I'm stuck indoors caring for my young, paraplegic dog. So it's packed full of palettes you can play with. Who doesn't like a little color! A screenshot of Prompt with the preferences window open allowing the selection of numerous palettes with diverse color sets. The terminal window is recolored using colors from the palette. There are some subtle performance choices that make for a better experience in Prompt. For example, I do like having a small amount of padding around the terminal so that rounded corners look nice and also avoids an extra framebuffer when rendering on the GPU. However, that looks odd with scrollback. So Prompt rewrites the snapshot from VTE to remove the background and extraneous clipping. We already have a background from window recoloring anyway. It's a small detail that just feels good when using it. Another subtle improvement is detecting when we are entering the tab overview. Currently, libadwaita uses a GtkWidgetPaintable to represent the tab contents. This works great for the likes of Epiphany where the contents are backed by GL textures. But for a terminal application we have a lot of text and we don't want to redraw it scaled as would happen in this case. That puts a lot of pressure on the glyph cache. So instead, we create a single texture upfront and scale that texture. Much smoother. For people writing terminal applications there is a little inspector you can popup to help you out. It can be difficult to know if you're doing the right thing or getting the right behavior so this might be something we can extend going forward to make that easier for you. GTK's inspector already does so much so this is just an extension of what you could do there. A terminal window open with a secondary "inspector" window open. The inspector shows what column and row the mouse is positioned as well as the cursor and what non-visible OSC hyperlink is under the pointer. Creating Prompt has elevated problems we should fix. * Podman creates an additional PTY which sort of breaks the whole notion of foreground processes. Filed an issue upstream and it seems likely we can get that addressed for personal containers. That will improve what happens when you close your terminal tab with something running or if you SSH'd into another host from the container. * Container tracking is currently limited to Fedora hosts because toolbox only emits the container-tracking escape sequences when the host is Fedora. The current goal I've discussed with VTE maintainers is that we'll use a new "termprop" feature in VTE that will be silently dropped on terminal applications not interested in it. That way toolbox and the likes can safely emit the escape sequence. * Currently podman will exit if you pass a --user or --workdir that does not exist in the container. That isn't a problem with toolbox as it is always your user and fails gracefully for directories. So we need a good strategy to see if both of those are available to inherit when creating new tabs. * This does have transparency support, but it's hidden in a GSetting for now. Once we have libadwaita with CSS variable support we can probably make this look better during transitions which is where it falls down now. We also need some work on how AdwTabOverview does snapshots of tabs and inserts a background. * I have a .bashrc snippet to treat jhbuild as a container which is helpful for those of us GNOME developers still using it. * Accessibility is an extremely important piece of our infrastructure in GNOME. So part of this work will inevitably tie into making sure the a11y portion of VTE works with the soon-to-land a11y improvements in GTK. That has always been missing on GTK 4-based VTE and therefore every terminal based upon it. $ flatpak install --user --from https://nightly.gnome.org/repo/appstream/org.gnome.Prompt.Devel.flatpakref If you like software that I write, consider donating to a pet shelter near you this holiday season. We're so lucky to have great pet care in Oregon but not everywhere is so lucky. Happy Holiday Hacking! Posted on December 14, 2023December 15, 2023Author chergertCategories Uncategorized Leave a Reply Cancel reply Only people in my network can comment. This site uses Akismet to reduce spam. Learn how your comment data is processed. Post navigation Previous Previous post: Toby is Recovering in ER ICU Proudly powered by WordPress