hiiro 0.1.371 → 0.1.372

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4910c0070a20706820a27abe45f728d8751da4d9d2297cacd05d26836c96dce1
4
- data.tar.gz: 3173f0e134ef9353383405aff0dfd72ebe502a72ec3a2f149000dd6d221e6116
3
+ metadata.gz: bf0a697dfb88ddd554983d6eed9f0419087da31726ffa0fdade260b393eed0fc
4
+ data.tar.gz: dcf0ce065b625cd1a30b7cc8bf03bbf708be1d9068df677d31e714f332d0a6c4
5
5
  SHA512:
6
- metadata.gz: e0fb10ffa72f026a25c0cba9ebe6f926f7d6c7504ea1d51f729519feed61918cba7fb2cf0da814c322f787c90ec532b667ea22c9e2c3bbfacb414758fb30cbc8
7
- data.tar.gz: 5192581c3c17c73e5d7781f3cfd736e16678d89be171ca1676dfedd7e49c53e007bef1efe5b1f80bf61e827113fad82b07206564ce9779ccc97a1cbec28f4449
6
+ metadata.gz: 262c177d9b2296634b9d23fad53cd5df8e98d38f1230035f55ed9e209e5d918c730ea2bf6bb15226c1103db7902fe43e000d961eb53730861d5e4146d40b1e0f
7
+ data.tar.gz: 4256ab7812cad7cf221bd1d66b2f645ce9d1adb63c561b07fe8a4c30256fb1093120d3271935217b4369c31639cf7e053c1fd5a6b45f38f0e29f479e28a6ae84
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.1.372] - 2026-09-14
6
+
7
+ ### Changed
8
+ - `h bg run` reuses an idle shell pane in the `h-bg` workspace and opens a new tab only when every pane is busy, instead of one tab per command
9
+
5
10
  ## [0.1.371] - 2026-09-14
6
11
 
7
12
  ### Added
data/docs/h-bg.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Run commands in unfocused Herdr tabs with command history tracking.
4
4
 
5
- Inside Herdr, commands run in the `h-bg` workspace, with one tab per command. Outside Herdr, Hiiro falls back to a detached local process. History is stored at `~/.config/hiiro/bg-history.txt`.
5
+ Inside Herdr, commands run in the `h-bg` workspace. Each command reuses the first pane there that is sitting at an idle shell prompt (no agent and no foreground process, as reported by `herdr pane process-info`) and only opens a new unfocused tab when every pane is busy, so the workspace holds at most as many tabs as jobs that ran at the same time. Outside Herdr, Hiiro falls back to a detached local process. History is stored at `~/.config/hiiro/bg-history.txt`.
6
6
 
7
7
  ## Synopsis
8
8
 
@@ -1,23 +1,32 @@
1
+ require 'shellwords'
2
+
1
3
  class Hiiro
2
4
  module Background
3
5
  WORKSPACE = 'h-bg'
4
6
 
5
- # Run cmd asynchronously. Inside Herdr, spins up an unfocused tab in the
6
- # h-bg workspace so you can inspect it later. Outside Herdr,
7
- # falls back to a detached spawn.
7
+ # Run cmd asynchronously. Inside Herdr, reuses an idle shell pane in the
8
+ # h-bg workspace and only opens a new unfocused tab when every pane there is
9
+ # busy, so the workspace never grows past the number of concurrent jobs.
10
+ # Outside Herdr, falls back to a detached spawn.
8
11
  #
9
12
  # dir: optional directory to cd into before running the command.
10
- def self.run(*cmd, dir: nil)
13
+ def self.run(*cmd, dir: nil, client: nil)
11
14
  if inside_herdr?
12
- client = Hiiro::Herdr.client
15
+ client ||= Hiiro::Herdr.client
13
16
  workspace = ensure_workspace(client)
14
- client.new_tab(
15
- name: cmd.first.to_s,
16
- workspace: workspace,
17
- start_directory: dir,
18
- command: cmd.shelljoin,
19
- focus: false
20
- )
17
+ command = cmd.shelljoin
18
+ command = "cd #{dir.shellescape} && #{command}" if dir
19
+ if (pane = idle_pane(client, workspace))
20
+ client.run_in_pane(pane.id, command)
21
+ else
22
+ client.new_tab(
23
+ name: cmd.first.to_s,
24
+ workspace: workspace,
25
+ start_directory: dir,
26
+ command: command,
27
+ focus: false
28
+ )
29
+ end
21
30
  else
22
31
  spawn_opts = dir ? { chdir: dir } : {}
23
32
  Process.detach(spawn(*cmd, **spawn_opts))
@@ -33,5 +42,10 @@ class Hiiro
33
42
  def self.ensure_workspace(client = Hiiro::Herdr.client)
34
43
  client.find_workspace(WORKSPACE) || client.new_workspace(WORKSPACE, focus: false)
35
44
  end
45
+
46
+ # A pane in the workspace sitting at a shell prompt with no foreground command.
47
+ def self.idle_pane(client, workspace)
48
+ client.panes(workspace: workspace).find { |pane| pane.agent.nil? && pane.foreground_command.nil? }
49
+ end
36
50
  end
37
51
  end
data/lib/hiiro/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  class Hiiro
2
- VERSION = "0.1.371"
2
+ VERSION = "0.1.372"
3
3
  SUPPORTED_RUBY_VERSION = ">= 3.2.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.371
4
+ version: 0.1.372
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota