Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

docs, test(agent-tui): keybindings for find stepping and Ctrl-Z, isolate the suspend tests

Akarshan Biswasf80ce8c7ae85
diff --git a/docs/src/pages/docs/agent/keybindings.mdx b/docs/src/pages/docs/agent/keybindings.mdx
index efc25eabe..2f084dd4a 100644
--- a/docs/src/pages/docs/agent/keybindings.mdx
+++ b/docs/src/pages/docs/agent/keybindings.mdx
@@ -95,7 +95,7 @@ Cancelling stops the turn, not the session. See [rewinding](/docs/agent/sessions
| <kbd>↑</kbd> / <kbd>↓</kbd> | Recall sent messages, or scroll the transcript once the input has text |
| <kbd>PgUp</kbd> / <kbd>PgDn</kbd> | Scroll the transcript, always |
| <kbd>Ctrl</kbd>+<kbd>F</kbd> | Search the transcript: starts `/find ` in an empty input (with text typed, it still moves the caret) |
-| <kbd>n</kbd> / <kbd>N</kbd> | Next / previous search match, wrapping. Only while a search is on and the input is empty, so typing is never hijacked |
+| <kbd>Enter</kbd> / <kbd>Shift</kbd>+<kbd>Enter</kbd> | Next / previous search match, wrapping. Only while a search is on and the input is empty, so typing is never hijacked |
| <kbd>Esc</kbd> | Clear the search and its highlight (before it would cancel a run or clear input) |
| <kbd>Ctrl</kbd>+<kbd>O</kbd> | Expand or collapse all tool calls and reasoning blocks |
| Drag | Select text, copied on release (<kbd>Alt</kbd>+drag selects a block) |
@@ -124,3 +124,4 @@ See [Tool permissions](/docs/agent/permissions).
| Key | Action |
| --- | --- |
| <kbd>Ctrl</kbd>+<kbd>C</kbd> / <kbd>Ctrl</kbd>+<kbd>D</kbd> | Quit (press twice) |
+| <kbd>Ctrl</kbd>+<kbd>Z</kbd> | Suspend to the shell; resume with `fg`. Unix only. Refused (with a note) when no job-control shell sits above `jan`, such as `ssh -t host jan` or `docker exec -it`, because nothing could resume it |
diff --git a/src-tauri/jan-cli/tests/tui_suspend.rs b/src-tauri/jan-cli/tests/tui_suspend.rs
index 7eb6ccb45..6d2517fb0 100644
--- a/src-tauri/jan-cli/tests/tui_suspend.rs
+++ b/src-tauri/jan-cli/tests/tui_suspend.rs
@@ -12,6 +12,7 @@ use std::fs::File;
use std::io::{Read, Write};
use std::os::unix::process::CommandExt;
use std::process::{Child, Command, Stdio};
+use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
@@ -131,9 +132,18 @@ fn spawn_with(new_session: bool) -> Session {
let mut reader = File::from(pty.master);
let master = reader.try_clone().expect("clone PTY master");
let slave = File::from(pty.slave);
- let home = std::env::temp_dir().join(format!("jan-tui-suspend-{}", std::process::id()));
+ // Tests run on parallel threads of one process, and each Session removes
+ // its HOME on drop, so the directory needs more than the process id.
+ static NEXT: AtomicUsize = AtomicUsize::new(0);
+ let home = std::env::temp_dir().join(format!(
+ "jan-tui-suspend-{}-{}",
+ std::process::id(),
+ NEXT.fetch_add(1, Ordering::Relaxed)
+ ));
std::fs::create_dir_all(&home).unwrap();
let mut command = if new_session {
+ // util-linux `setsid --ctty`, since a session leader cannot be made
+ // without `unsafe`; the caller checks it exists.
let mut c = Command::new("setsid");
c.arg("--ctty").arg(env!("CARGO_BIN_EXE_jan"));
c
@@ -199,7 +209,12 @@ fn ctrl_z_and_sigtstp_suspend_and_resume_cleanly() {
/// With no job-control shell above it nothing would ever send SIGCONT, so
/// Ctrl-Z must refuse (and say so) rather than stop and hang the terminal.
#[test]
+#[cfg(target_os = "linux")]
fn ctrl_z_in_an_orphaned_group_refuses_instead_of_stopping() {
+ if Command::new("setsid").arg("--version").output().is_err() {
+ eprintln!("skipped: setsid (util-linux) is not installed");
+ return;
+ }
let session = spawn_with(true);
session.wait_for(0, &ENTER, "the TUI to start");
let mut master = session.master.try_clone().expect("clone PTY master");