Commit graph

2234 commits

Author SHA1 Message Date
Kovid Goyal
8e5487e9d4
choose-files kitten: Limit the number of entries shown for zip archives
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Previews of tar and rar archives were already limited to 500 entries, but
zip archives listed every entry.
2026-11-14 12:19:17 +05:30
Kovid Goyal
4fa6709910
choose-files kitten: Sanitize untrusted text in the preview panel
File names, archive member names, symlink targets, error messages and
ebook metadata were written to the terminal unsanitized, allowing
crafted names to inject escape codes (e.g. OSC 52 to overwrite the
clipboard) merely by highlighting the entry.
2026-11-14 12:19:09 +05:30
Kovid Goyal
b9e7070cc8
dnd kitten: Fix failure to start in a non-writable directory
Create the temporary directory used for staging drops lazily, on the first
drop, instead of at startup, so the kitten works in directories that are not
writable when nothing is dropped into them.

Fixes #10855
2026-11-12 18:54:46 +05:30
Kovid Goyal
6d8f7ac14f
Cleanup previous PR
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Let preview renderers supply extra cache key data instead of checking for
the cmd_renderer type. Include the command line in the key for custom
previews and the video_preview settings in the key for video thumbnails,
so that changing them no longer shows stale previews. GetPath and AddPath
now take this extra key data, replacing GetPathWithAlias.

Track the entry each path uses per extra key, so that previews of one file
with different settings do not evict each other. Do not remove an entry
while another path, such as another symlink to the same file, still uses
it. Cache hits are now recorded so that such shared entries are known.
Failing to remove an orphaned entry on a cache hit no longer turns the hit
into an error.

Fix ensure_entries() discarding unwritten changes when the entries file
does not exist yet, which lost the first path recorded in a new cache.
Also reset the path map when clearing the cache.
2026-11-11 21:26:01 +05:30
Zhizhen He
a1f5604cc2
choose-files: Keep custom preview caches separate for symlinks
Custom preview commands receive the selected path. Include that path
in their cache key so that symlinks to the same file can have different
previews. Keep the resolved target in the key so retargeting a link
still invalidates its entry.
2026-11-11 23:32:42 +08:00
Kovid Goyal
a95310e8bc
choose-files: Cleanup previous PR
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Always reply from the calibre worker, even when reading metadata raises or
calibre emits stray output, so that the request does not block until it
times out.

Accept cached calibre metadata generated for a different path to the same
file, as the disk cache key resolves symlinks. Otherwise a symlink and its
target keep invalidating each other's cache entry.
2026-11-10 19:29:52 +05:30
Zhizhen He
9777edff79 choose-files: Match calibre preview replies to requests
Dispatch replies by request ID from a single reader so concurrent previews receive their own metadata and late replies cannot interfere with subsequent requests.
2026-11-10 20:53:40 +08:00
Kovid Goyal
0dfd9a832e
choose-files: Cleanup handling of special files in previews
Follow up to the previous commit fixing hangs when previewing named pipes:

- Skip previewing anything that is not a regular file (or a symlink to
  one) in preview_for, before any previewer opens it. This avoids
  unblocking and then breaking writers waiting on a FIFO and covers the
  non-text previewers (images, video, archives, calibre, commands) too.
- Apply the text preview size limit to the symlink target instead of the
  symlink itself, and enforce it while reading so that files growing
  after stat() are also handled.
- Pre-allocate the read buffer based on the file size, as os.ReadFile does.
- Read ignore files during scanning with the same non-blocking reader, so
  a FIFO named .ignore or .gitignore cannot stall the scan.
- Unblock goroutines stuck on FIFOs when tests time out.
2026-11-09 08:42:30 +05:30
Zhizhen He
cdd278ee63
choose-files: Avoid hanging when previewing named pipes
Open text preview files in nonblocking mode and check the type on
the opened descriptor before reading. Reuse the same read for syntax
highlighting because it can reopen a path after the file changes.
2026-11-09 00:21:45 +08:00
Kovid Goyal
e4988b522d
hints: Migrate from regexp2 v1 to v2
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Use Capture.ByteRange() from v2 instead of a hand-rolled rune to byte
offset mapping. The old mapping required capture offsets to be monotonic
across matches, so a capture inside a lookaround overlapping a later match
in non-ASCII text caused all matches to be silently dropped.

Also propagate match errors instead of discarding them. Drops the v1
dependency, v2 was already pulled in by chroma.
2026-11-07 05:54:16 +05:30
devangpratap
f571f41ffb choose-files: Show tags instead of authors on the calibre preview Tags line 2026-11-05 14:57:26 -05:00
Kovid Goyal
d74472bd3c
choose-files: fix video and custom previews notbeing cached 2026-11-05 14:42:27 +05:30
Zhizhen He
c0c31df39c choose-files: Decode video preview thumbnails only once 2026-11-05 16:25:59 +08:00
Zhizhen He
4f689e2777 choose-files: Isolate custom preview command arguments 2026-11-04 10:56:49 +08:00
Kovid Goyal
5a6ea12f29
remote_file: Only reset the terminal when stdout is a tty
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Avoids writing escape codes into piped output and test logs.
2026-11-01 12:00:40 +05:30
Kovid Goyal
a65a01e099
Cleanup previous PR
Keep edit_loop free of side effects: it now reports whether the editor
was started and edit_and_upload decides whether to keep the local copy.
Print the recovery path verbatim instead of Go-quoted.
2026-11-01 11:06:40 +05:30
Zhizhen He
32e6c525f9 remote_file: Preserve local edits after upload failure 2026-11-01 13:29:24 +08:00
Kovid Goyal
fcf697a5e0
Cleanup previous PR
Strip the optional leading = from values attached to short options, matching
rg semantics (-e=foo means the pattern foo). Replace the rg execution based
test with unit tests of the argument rewriting.
2026-11-01 08:23:00 +05:30
Zhizhen He
300f8c58cb hyperlinked-grep: Preserve short option values and stdin paths 2026-10-31 22:10:55 +08:00
Kovid Goyal
c93279d856
Cleanup previous PR
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Move the D-Bus service Exec line generation into a helper with a fast unit
test instead of copying the test binary and re-executing it. Refuse paths
containing a carriage return, since D-Bus decodes \r as a newline and
rejects .service files containing a raw carriage return.
2026-10-31 09:28:45 +05:30
Zhizhen He
b6abbf7655 desktop-ui: Quote portal activation executable paths 2026-10-31 11:43:54 +08:00
Kovid Goyal
f2f7927ec5
Merge branch 'fix-desktop-ui-kitten-path-fallback' of https://github.com/devangpratap/kitty 2026-10-31 08:40:55 +05:30
Kovid Goyal
ccecfa037b
Cleanup previous PR 2026-10-31 08:33:43 +05:30
devangpratap
cab970b015 desktop-ui: Use the kitten path fallback when os.Executable fails
enable_portal checked eerr instead of err after filepath.Abs, so a failing
os.Executable always aborted with a nil error and the Which fallback was
never used, while an Abs error was ignored. Check err, and report the
os.Executable error if kitten is not in PATH either.
2026-10-30 22:34:06 -04:00
Zhizhen He
df02769ed1 themes: Isolate picker cache from unicode_input 2026-10-30 23:05:31 +08:00
Kovid Goyal
9575920aab
Cleanup previous PR
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Track move source identities in drop_status rather than parsed_uri, and
also compare birth times where available, so that a replacement reusing
the inode number of a deleted source is not removed. Clarify the
changelog entry.
2026-10-30 18:28:40 +05:30
Zhizhen He
7629533607 dnd: Only remove original sources after a local move 2026-10-30 20:29:16 +08:00
Kovid Goyal
6adff8efff
Fix hanging dnd kitten test
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
2026-10-30 14:56:32 +05:30
Kovid Goyal
f5c6ad38be
Cleanup previous PR 2026-10-30 14:24:59 +05:30
Zhizhen He
c370368a48 dnd: Reject local moves that merge back into a source 2026-10-30 14:32:13 +08:00
Kovid Goyal
02b2b10d10
Fix flaky test
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
2026-10-29 22:05:37 +05:30
Kovid Goyal
cb88028abd
dnd kitten: Fix filesystem case sensitivity never being detected
is_case_sensitive_filesystem lost its true default when it moved into
the dnd struct, so remote drops always treated names differing only in
case as conflicting. Detect it properly and also probe for Unicode
normalization aliasing, since a case sensitive filesystem can still
treat differently normalized names as the same.
2026-10-29 21:46:25 +05:30
Kovid Goyal
1647103c57
Cleanup previous PR
- List the existing files that will be overwritten under the names they
  are stored as in the destination, not the dropped names
- Treat symlinks to directories in the destination as directories in
  find_overwrites, matching rename_contents, so the files that will be
  overwritten inside the symlink target are listed
- Replace an existing file or dangling symlink with a dropped directory
  instead of failing the drop after the user confirmed the overwrite
- Fail up front when a dropped file would replace an existing directory
- Also fold Unicode normalization when uniqifying remote drop names
- Probe for filesystem aliasing once before running the alias test
2026-10-29 21:41:44 +05:30
Zhizhen He
924dacc955
dnd: Detect filesystem aliases before overwrite confirmation 2026-10-29 23:55:24 +08:00
Kovid Goyal
40562972f4
Cleanup previous PR
Walk up from the drop destination using .. relative to its file
descriptor instead of its path, so the check is not fooled if the
destination is moved or replaced while the kitten is running. Also skip
the staging directory when copying, which guards against routes to it
the up-front check cannot see, such as bind mounts. Use readable
subtest names, check the chmod error in test cleanup and link the PR in
the changelog.
2026-10-29 17:32:35 +05:30
Zhizhen He
1a1495f564 dnd: Reject directory drops into their own descendants 2026-10-29 18:22:19 +08:00
Zhizhen He
ed4d37a9fa dnd: Skip local moves into the source directory 2026-10-28 20:36:04 +08:00
Kovid Goyal
c514311380
dnd: Use the existing conflict name template for local drops
Keeps conflict naming consistent between local and remote drops.
2026-10-28 17:38:44 +05:30
Zhizhen He
b7b29fe444 dnd: Preserve same-named local drop sources
Staging two entries with the same basename could fall back from a hard link to a truncating copy and overwrite the first source. Give each local source an unused staging name and use exclusive file and directory creation. Add regressions for files, directories, repeated paths, case conflicts, existing staging entries and symbolic links.
2026-10-28 19:45:51 +08:00
Zhizhen He
1e273aa289 Docs: Correct protocol references, examples and generated help 2026-10-28 13:24:43 +08:00
Zhizhen He
849c04153c choose-fonts: Fix style ordering for negative axis values 2026-10-27 22:52:24 +08:00
devangpratap
2519974e84 desktop-ui: Fix an invalid accent_color breaking the appearance settings 2026-10-26 14:05:23 -04:00
Kovid Goyal
a2086eb6a4
clipboard: Name both outputs when a case alias is detected
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Identify the colliding output by comparing the probe files, matching the
message used for exact duplicates. Skip creating probe files when fewer
than two file outputs are given, so that a single output does not touch
the destination directory. Check both directories for leftover probes in
the test.
2026-10-26 20:18:48 +05:30
Zhizhen He
f0c67e1b97
clipboard: Reject output files with case aliases 2026-10-26 22:21:29 +08:00
Zhizhen He
4596a9baab
clipboard: Match duplicate checks to atomic write resolution 2026-10-26 13:36:01 +08:00
Zhizhen He
49e5695188
clipboard: Resolve symlinks before cleaning output paths 2026-10-26 13:12:42 +08:00
Kovid Goyal
a082d0b9ab
Fix test failure on macOS 2026-10-26 09:36:39 +05:30
Kovid Goyal
ddeb15b05a
clipboard: Download data once for outputs sharing a MIME type
Rather than every output sharing a remote MIME type writing its own
temporary copy of the data and decoding images separately, store the
data in a single temporary file per MIME type, decode images once and
save all outputs for that MIME type sequentially from it. The temporary
file is created in the directory of the first output where that is
possible, so a missing directory for one output does not affect others.

Also reject output files that resolve to the same path, following
symlinks as the atomic file update does, since saving to them would race
with the last write winning.
2026-10-26 08:53:47 +05:30
Kovid Goyal
3723c447aa
clipboard: Reject duplicate stream outputs for the same MIME type
Stream outputs write data as it arrives, so with fan-out to all outputs
sharing a remote MIME type, two outputs to the same stream would
interleave their data chunk by chunk, or encode two images into the
stream concurrently. Reject such duplicates with an error instead.
Also add a changelog entry for saving all outputs sharing a MIME type.
2026-10-26 08:48:06 +05:30
Zhizhen He
88fc77a5d6
clipboard: Save all outputs sharing a remote MIME type 2026-10-26 11:05:55 +08:00