claude-inbox 0.6.1 → 0.7.0
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 +4 -4
- data/README.md +1 -3
- data/lib/claude_inbox/agents_client.rb +1 -11
- data/lib/claude_inbox/app/attaching.rb +77 -0
- data/lib/claude_inbox/app/browsing.rb +29 -0
- data/lib/claude_inbox/app/filtering.rb +37 -0
- data/lib/claude_inbox/app/navigating.rb +91 -0
- data/lib/claude_inbox/app/spawning.rb +62 -0
- data/lib/claude_inbox/app/triaging.rb +76 -0
- data/lib/claude_inbox/app/updating.rb +56 -0
- data/lib/claude_inbox/app.rb +93 -470
- data/lib/claude_inbox/cli.rb +1 -1
- data/lib/claude_inbox/input.rb +65 -0
- data/lib/claude_inbox/keymap.rb +2 -4
- data/lib/claude_inbox/mod.rb +8 -5
- data/lib/claude_inbox/mouse.rb +1 -1
- data/lib/claude_inbox/pull_requests.rb +2 -3
- data/lib/claude_inbox/renderer.rb +12 -39
- data/lib/claude_inbox/slash_commands.rb +6 -7
- data/lib/claude_inbox/store/sections.rb +2 -5
- data/lib/claude_inbox/store.rb +1 -1
- data/lib/claude_inbox/vt_screen.rb +4 -6
- data/lib/claude_inbox.rb +1 -1
- metadata +9 -3
- data/lib/claude_inbox/logs.rb +0 -68
- data/lib/claude_inbox/peek.rb +0 -77
data/lib/claude_inbox/cli.rb
CHANGED
|
@@ -129,7 +129,7 @@ module ClaudeInbox
|
|
|
129
129
|
# Its own token, lock and images, so a test inbox can neither rotate the
|
|
130
130
|
# token phones are paired with nor hold the real inbox's lock.
|
|
131
131
|
dir = File.join(Dir.tmpdir, "claude-inbox-fixture")
|
|
132
|
-
{client: FixtureClient.new(options[:fixture]
|
|
132
|
+
{client: FixtureClient.new(options[:fixture]),
|
|
133
133
|
store: Store.new(path: nil),
|
|
134
134
|
pull_requests: PullRequests.new(cache_path: File.join(fixtures, "gh-pr-status-cache.json"), resolved_path: nil, gh: nil),
|
|
135
135
|
listen: options[:listen]&.merge(fixture: true, pairing: Remote::Pairing.new(path: File.join(dir, "listen.json")),
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "tty-reader"
|
|
4
|
+
require_relative "mouse"
|
|
5
|
+
require_relative "paste"
|
|
6
|
+
|
|
7
|
+
module ClaudeInbox
|
|
8
|
+
# The tty's keypress stream decoded into pastes, mouse reports and named
|
|
9
|
+
# keys. Hides what tty-reader does with ESC, echo and a paste, so App sees
|
|
10
|
+
# events and not the raw bytes.
|
|
11
|
+
class Input
|
|
12
|
+
def initialize(input, out)
|
|
13
|
+
@input = input
|
|
14
|
+
@reader = TTY::Reader.new(input: input, output: out, interrupt: :noop)
|
|
15
|
+
@paste = Paste.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def pasting? = @paste.pasting?
|
|
19
|
+
|
|
20
|
+
# The next raw read, or nil when nothing has arrived.
|
|
21
|
+
def read
|
|
22
|
+
pasting? ? read_pasted : @reader.read_keypress(echo: false, raw: false, nonblock: true)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# `[:paste, text]`, `[:mouse, event]` and `[:key, name, raw]`, in the
|
|
26
|
+
# order they arrived; `name` is the reader's symbol for a key it knows,
|
|
27
|
+
# else the raw string.
|
|
28
|
+
def events(raw)
|
|
29
|
+
@paste.feed(raw).flat_map do |kind, text|
|
|
30
|
+
next [[:paste, text]] if kind == :paste
|
|
31
|
+
mouse = Mouse.events(text)
|
|
32
|
+
next mouse.map { |e| [:mouse, e] } if mouse.any?
|
|
33
|
+
split_keys(text).map { |k| [:key, key_name(k), k] }
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# A paste typed out: `[name, raw]` per character.
|
|
38
|
+
def typed(text) = text.each_char.map { |c| [key_name(c), c] }
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
# As much of an open paste as has arrived, read straight off the tty:
|
|
43
|
+
# the reader switches echo off and back on around every character, and
|
|
44
|
+
# on a long paste that is most of the wait.
|
|
45
|
+
def read_pasted
|
|
46
|
+
return nil unless @input.wait_readable(0.1)
|
|
47
|
+
out = +""
|
|
48
|
+
while out.size < 65_536 && @input.wait_readable(0) && (c = @input.getc)
|
|
49
|
+
out << c
|
|
50
|
+
end
|
|
51
|
+
out
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def key_name(key) = @reader.console.keys[key] || key
|
|
55
|
+
|
|
56
|
+
# tty-reader glues ESC to whatever arrives within 100ms, so a fast
|
|
57
|
+
# "esc gg" comes in as one unknown key "\egg". Vim hands make that
|
|
58
|
+
# constantly. Unknown ESC-prefixed strings become ESC + the rest.
|
|
59
|
+
def split_keys(key)
|
|
60
|
+
return [key] if key.size <= 1 || @reader.console.keys.key?(key)
|
|
61
|
+
return [key] unless key.start_with?("\e")
|
|
62
|
+
["\e"] + key[1..].chars
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
data/lib/claude_inbox/keymap.rb
CHANGED
|
@@ -19,15 +19,13 @@ module ClaudeInbox
|
|
|
19
19
|
"G" => :bottom,
|
|
20
20
|
:ctrl_d => :half_page_down, :ctrl_u => :half_page_up,
|
|
21
21
|
:ctrl_f => :page_down, :ctrl_b => :page_up,
|
|
22
|
-
:ctrl_e => :peek_down, :ctrl_y => :peek_up,
|
|
23
|
-
"J" => :peek_down, "K" => :peek_up,
|
|
24
22
|
# actions
|
|
25
23
|
:return => :activate, :enter => :activate, "l" => :activate,
|
|
26
|
-
"h" => :
|
|
24
|
+
"h" => :fold_close,
|
|
27
25
|
"s" => :snooze, "u" => :wake, "a" => :alias, "x" => :settle, "X" => :stop,
|
|
28
26
|
:ctrl_x => :delete,
|
|
29
27
|
"o" => :open_pr, "P" => :link_pr, "t" => :toggle_pin, "w" => :open_remote,
|
|
30
|
-
"R" => :refresh, "U" => :update, "
|
|
28
|
+
"R" => :refresh, "U" => :update, "n" => :new_session, "N" => :remote_pairing,
|
|
31
29
|
:tab => :next_section, :back_tab => :prev_section,
|
|
32
30
|
"/" => :filter, :escape => :escape,
|
|
33
31
|
"q" => :quit, :ctrl_c => :quit
|
data/lib/claude_inbox/mod.rb
CHANGED
|
@@ -41,9 +41,9 @@ module ClaudeInbox
|
|
|
41
41
|
# rather than rewrite a settings file it cannot read.
|
|
42
42
|
def self.install(settings: SETTINGS, link: LINK, dir: DIR, force: false, command: COMMAND)
|
|
43
43
|
self.link(link: link, dir: dir, force: true)
|
|
44
|
-
json =
|
|
44
|
+
json = read_settings(settings)
|
|
45
45
|
env = json["env"] ||= {}
|
|
46
|
-
dirs = env["CLAUDE_CODE_PLUGIN_DIRS"]
|
|
46
|
+
dirs = plugin_dirs(env["CLAUDE_CODE_PLUGIN_DIRS"])
|
|
47
47
|
kept = dirs.reject { |d| force && d != link && plugin?(d) }
|
|
48
48
|
wanted = kept.include?(link) ? kept : [*kept, link]
|
|
49
49
|
options = json.dig("pluginConfigs", NAME, "options") || {}
|
|
@@ -66,8 +66,7 @@ module ClaudeInbox
|
|
|
66
66
|
# worktree's included. A settings file it cannot read counts as yes, since
|
|
67
67
|
# install would refuse to touch it.
|
|
68
68
|
def self.installed?(settings: SETTINGS)
|
|
69
|
-
|
|
70
|
-
json.dig("env", "CLAUDE_CODE_PLUGIN_DIRS").to_s.split(File::PATH_SEPARATOR).any? { |d| plugin?(d.strip) }
|
|
69
|
+
plugin_dirs(read_settings(settings).dig("env", "CLAUDE_CODE_PLUGIN_DIRS")).any? { |d| plugin?(d) }
|
|
71
70
|
rescue JSON::ParserError, Errno::EACCES
|
|
72
71
|
true
|
|
73
72
|
end
|
|
@@ -101,6 +100,10 @@ module ClaudeInbox
|
|
|
101
100
|
rescue Errno::ENOENT, Errno::ENOTDIR, Errno::EACCES, JSON::ParserError
|
|
102
101
|
false
|
|
103
102
|
end
|
|
104
|
-
|
|
103
|
+
|
|
104
|
+
def self.read_settings(path) = File.exist?(path) ? JSON.parse(File.read(path)) : {}
|
|
105
|
+
|
|
106
|
+
def self.plugin_dirs(value) = value.to_s.split(File::PATH_SEPARATOR).map(&:strip).reject(&:empty?)
|
|
107
|
+
private_class_method :plugin?, :read_settings, :plugin_dirs
|
|
105
108
|
end
|
|
106
109
|
end
|
data/lib/claude_inbox/mouse.rb
CHANGED
|
@@ -11,7 +11,7 @@ module ClaudeInbox
|
|
|
11
11
|
Event = Struct.new(:kind, :row, :col)
|
|
12
12
|
|
|
13
13
|
# A raw keypress can glue several reports together the same way a fast
|
|
14
|
-
# "esc gg" glues onto one read (see
|
|
14
|
+
# "esc gg" glues onto one read (see Input#split_keys), so this scans
|
|
15
15
|
# rather than matching once.
|
|
16
16
|
def self.events(raw)
|
|
17
17
|
raw.scan(SEQUENCE).filter_map do |cb, col, row, type|
|
|
@@ -57,11 +57,10 @@ module ClaudeInbox
|
|
|
57
57
|
class PullRequests
|
|
58
58
|
REFRESH_AFTER = 60
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
CACHE_PATH = File.join(Dir.home, ".claude", "gh-pr-status-cache.json")
|
|
61
61
|
RESOLVED_PATH = File.join(Dir.home, ".config", "claude-inbox", "prs.json")
|
|
62
62
|
|
|
63
|
-
def initialize(cache_path:
|
|
64
|
-
gh: "gh", clock: -> { Time.now })
|
|
63
|
+
def initialize(cache_path: CACHE_PATH, resolved_path: RESOLVED_PATH, gh: "gh", clock: -> { Time.now })
|
|
65
64
|
@cache_path = cache_path
|
|
66
65
|
@resolved_path = resolved_path
|
|
67
66
|
@gh = gh
|
|
@@ -11,18 +11,17 @@ module ClaudeInbox
|
|
|
11
11
|
# `width` columns wide) plus a parallel Array of selectable items.
|
|
12
12
|
# Pure: no terminal, no IO, no clock beyond the `now` it is handed.
|
|
13
13
|
class Renderer
|
|
14
|
-
Frame = Struct.new(:lines, :items, :top
|
|
14
|
+
Frame = Struct.new(:lines, :items, :top)
|
|
15
15
|
|
|
16
16
|
CHROME_ROWS = 2 # header + footer
|
|
17
|
-
MIN_LIST_WIDTH = 44 # with the peek open, the list keeps at least this many columns
|
|
18
17
|
|
|
19
18
|
def self.body_height(height) = height - CHROME_ROWS
|
|
20
19
|
|
|
21
|
-
# What App hands Renderer for one frame. `
|
|
22
|
-
#
|
|
23
|
-
View = Data.define(:width, :height, :now, :selected, :top, :expanded, :
|
|
20
|
+
# What App hands Renderer for one frame. `listening` is a
|
|
21
|
+
# Remote::Listener::Snapshot.
|
|
22
|
+
View = Data.define(:width, :height, :now, :selected, :top, :expanded, :modal, :screen,
|
|
24
23
|
:status, :usage, :filter, :filter_editing, :tick, :loading, :listening) do
|
|
25
|
-
def initialize(width:, height:, now:, selected: nil, top: 0, expanded: {},
|
|
24
|
+
def initialize(width:, height:, now:, selected: nil, top: 0, expanded: {}, modal: nil, screen: nil,
|
|
26
25
|
status: nil, usage: nil, filter: nil, filter_editing: false, tick: 0, loading: nil, listening: nil) = super
|
|
27
26
|
end
|
|
28
27
|
|
|
@@ -60,7 +59,7 @@ module ClaudeInbox
|
|
|
60
59
|
|
|
61
60
|
KEYS = [
|
|
62
61
|
["j/k", "move"], ["⏎", "attach"], ["n", "new"], ["t", "pin"], ["s", "snooze"], ["u", "wake"],
|
|
63
|
-
["a", "alias"], ["o", "PR"], ["x", "settle"], ["
|
|
62
|
+
["a", "alias"], ["o", "PR"], ["x", "settle"], ["⇥", "section"],
|
|
64
63
|
["za", "fold"], ["/", "filter"], ["q", "quit"]
|
|
65
64
|
].freeze
|
|
66
65
|
|
|
@@ -76,13 +75,12 @@ module ClaudeInbox
|
|
|
76
75
|
def frame(sections, view)
|
|
77
76
|
return full_screen(sections, view) if view.screen
|
|
78
77
|
width, height, selected = view.width, view.height, view.selected
|
|
79
|
-
list_w = width_for_list(width, view.peek)
|
|
80
78
|
view_h = Renderer.body_height(height)
|
|
81
79
|
body, items =
|
|
82
80
|
if view.loading
|
|
83
|
-
[loading_state(
|
|
81
|
+
[loading_state(width, view_h, view.loading, view.tick), []]
|
|
84
82
|
else
|
|
85
|
-
body_lines(sections,
|
|
83
|
+
body_lines(sections, width, view)
|
|
86
84
|
end
|
|
87
85
|
|
|
88
86
|
top = clamp_top(view.top, body.size, view_h, items, selected)
|
|
@@ -91,26 +89,13 @@ module ClaudeInbox
|
|
|
91
89
|
visible += [""] * (view_h - visible.size)
|
|
92
90
|
visible_items += [nil] * (view_h - visible_items.size)
|
|
93
91
|
|
|
94
|
-
if view.peek
|
|
95
|
-
peek_w = width - list_w - 1
|
|
96
|
-
peek_lines = peek_pane(view.peek, peek_w, view_h)
|
|
97
|
-
visible = visible.each_with_index.map do |l, i|
|
|
98
|
-
Text.pad(l, list_w) + @p.dim("│") + Text.pad(peek_lines[i] || "", peek_w)
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
92
|
lines = [header(sections, width, view)] + visible.map { |l| Text.pad(l, width) } + [footer(width, view)]
|
|
103
93
|
lines = overlay(lines, view.modal, width) if view.modal
|
|
104
|
-
Frame.new(lines, [nil] + visible_items + [nil], top
|
|
94
|
+
Frame.new(lines, [nil] + visible_items + [nil], top)
|
|
105
95
|
end
|
|
106
96
|
|
|
107
97
|
private
|
|
108
98
|
|
|
109
|
-
def width_for_list(width, peek)
|
|
110
|
-
return width unless peek
|
|
111
|
-
[(width * 0.4).floor, MIN_LIST_WIDTH].max.clamp(0, width)
|
|
112
|
-
end
|
|
113
|
-
|
|
114
99
|
def clamp_top(top, size, view_h, items, selected)
|
|
115
100
|
idx = items.index { |item| item && item.key == selected }
|
|
116
101
|
top = idx - 2 if idx && idx - 2 < top # keep the section title in view
|
|
@@ -124,7 +109,7 @@ module ClaudeInbox
|
|
|
124
109
|
body = view.screen[:lines].first(view_h)
|
|
125
110
|
body += [""] * (view_h - body.size)
|
|
126
111
|
lines = [header(sections, width, view)] + body.map { |l| Text.pad(l, width) } + [Text.pad(" " + view.screen[:footer], width)]
|
|
127
|
-
Frame.new(lines, [nil] * view.height, view.top
|
|
112
|
+
Frame.new(lines, [nil] * view.height, view.top)
|
|
128
113
|
end
|
|
129
114
|
|
|
130
115
|
# ----- chrome -------------------------------------------------------------
|
|
@@ -242,7 +227,7 @@ module ClaudeInbox
|
|
|
242
227
|
return [empty_state(width), []]
|
|
243
228
|
end
|
|
244
229
|
selected = view.selected
|
|
245
|
-
sections.
|
|
230
|
+
sections.each_pair do |name, rows|
|
|
246
231
|
next if rows.empty?
|
|
247
232
|
lines << "" << section_title(name, rows.size, width)
|
|
248
233
|
items << nil << nil
|
|
@@ -391,7 +376,7 @@ module ClaudeInbox
|
|
|
391
376
|
pr ? base + @p.dim(" · ") + pr : base
|
|
392
377
|
end
|
|
393
378
|
|
|
394
|
-
# "#885 open". Only the first PR is shown
|
|
379
|
+
# "#885 open". Only the first PR is shown.
|
|
395
380
|
def pr_badge(s, section)
|
|
396
381
|
pr = s.pr
|
|
397
382
|
return nil unless pr
|
|
@@ -427,18 +412,6 @@ module ClaudeInbox
|
|
|
427
412
|
path.start_with?(@home) ? path.sub(@home, "~") : path
|
|
428
413
|
end
|
|
429
414
|
|
|
430
|
-
# ----- peek ---------------------------------------------------------------
|
|
431
|
-
|
|
432
|
-
def peek_pane(peek, width, height)
|
|
433
|
-
bar = Text.pad(" " + (peek.title || ""), width)
|
|
434
|
-
out = [@p.inverse(bar)]
|
|
435
|
-
out << Text.pad(" " + @p.dim(peek.subtitle.to_s), width) if peek.subtitle
|
|
436
|
-
body_h = height - out.size
|
|
437
|
-
wrapped = peek.lines.flat_map { |l| Text.wrap(l, width - 1) }
|
|
438
|
-
wrapped.last(body_h).each { |l| out << Text.pad(" " + l, width) }
|
|
439
|
-
out
|
|
440
|
-
end
|
|
441
|
-
|
|
442
415
|
# ----- modal --------------------------------------------------------------
|
|
443
416
|
|
|
444
417
|
# Centre a block of lines over the frame.
|
|
@@ -24,13 +24,12 @@ module ClaudeInbox
|
|
|
24
24
|
# The project wins over the home directory when both define the same
|
|
25
25
|
# name, as it does in the CLI.
|
|
26
26
|
def list(cwd:, home:)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
found.values.sort_by(&:name)
|
|
27
|
+
[
|
|
28
|
+
*from_dir(File.join(cwd, ".claude")),
|
|
29
|
+
*from_dir(File.join(home, ".claude")),
|
|
30
|
+
*plugins(home),
|
|
31
|
+
*synced(home)
|
|
32
|
+
].uniq(&:name).sort_by(&:name)
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
def match(commands, query)
|
|
@@ -4,8 +4,6 @@ module ClaudeInbox
|
|
|
4
4
|
class Store
|
|
5
5
|
# The Rows of one poll, grouped and ordered, and where the cursor may land among them.
|
|
6
6
|
Sections = Struct.new(:pinned, :needs_you, :active, :snoozed, :settled) do
|
|
7
|
-
def each_section(&) = each_pair(&)
|
|
8
|
-
|
|
9
7
|
def all = values.flatten(1)
|
|
10
8
|
|
|
11
9
|
def row(selection)
|
|
@@ -20,7 +18,7 @@ module ClaudeInbox
|
|
|
20
18
|
def section_of(selection)
|
|
21
19
|
return nil if selection.nil?
|
|
22
20
|
return selection.key if selection.fold?
|
|
23
|
-
|
|
21
|
+
each_pair { |name, rows| return name if rows.any? { |r| r.key == selection.key } }
|
|
24
22
|
nil
|
|
25
23
|
end
|
|
26
24
|
|
|
@@ -35,8 +33,7 @@ module ClaudeInbox
|
|
|
35
33
|
|
|
36
34
|
# An empty fold is left out, since there is nothing under it to open.
|
|
37
35
|
def stops(expanded)
|
|
38
|
-
|
|
39
|
-
rows = self[name]
|
|
36
|
+
each_pair.filter_map do |name, rows|
|
|
40
37
|
if !Store.folded?(name, expanded) then [name, rows.select(&:selectable?).map { |r| Selection.row(r.key) }]
|
|
41
38
|
elsif rows.any? then [name, [Selection.fold(name)]]
|
|
42
39
|
end
|
data/lib/claude_inbox/store.rb
CHANGED
|
@@ -116,7 +116,7 @@ module ClaudeInbox
|
|
|
116
116
|
def pr_for(id) = @mutex.synchronize { @entries[id] && Entry.new(@entries[id]).pr }
|
|
117
117
|
|
|
118
118
|
def pr_overrides
|
|
119
|
-
@mutex.synchronize { @entries.transform_values { |e| Entry.new(e).pr }.
|
|
119
|
+
@mutex.synchronize { @entries.transform_values { |e| Entry.new(e).pr }.compact }
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
# A copy, not the live entry: the reaper decides a deletion on this row
|
|
@@ -4,12 +4,10 @@ require "strscan"
|
|
|
4
4
|
require "unicode/display_width"
|
|
5
5
|
|
|
6
6
|
module ClaudeInbox
|
|
7
|
-
# A deliberately small cursor-addressed screen model
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
# grid does not. This is not a VT emulator: it handles the handful of
|
|
12
|
-
# sequences the replay actually uses and ignores the rest.
|
|
7
|
+
# A deliberately small cursor-addressed screen model that turns captured
|
|
8
|
+
# terminal output into the lines it would show; bin/screens reads the
|
|
9
|
+
# inbox's own frames through it. This is not a VT emulator: it handles the
|
|
10
|
+
# handful of sequences claude's output actually uses and ignores the rest.
|
|
13
11
|
class VtScreen
|
|
14
12
|
CSI = /\e\[([0-9;?]*)([A-Za-z@`])/
|
|
15
13
|
OSC = /\e\][^\a\e]*(?:\a|\e\\)?/
|
data/lib/claude_inbox.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: claude-inbox
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jordan Byron
|
|
@@ -108,22 +108,28 @@ files:
|
|
|
108
108
|
- lib/claude_inbox/actions.rb
|
|
109
109
|
- lib/claude_inbox/agents_client.rb
|
|
110
110
|
- lib/claude_inbox/app.rb
|
|
111
|
+
- lib/claude_inbox/app/attaching.rb
|
|
112
|
+
- lib/claude_inbox/app/browsing.rb
|
|
113
|
+
- lib/claude_inbox/app/filtering.rb
|
|
114
|
+
- lib/claude_inbox/app/navigating.rb
|
|
115
|
+
- lib/claude_inbox/app/spawning.rb
|
|
116
|
+
- lib/claude_inbox/app/triaging.rb
|
|
117
|
+
- lib/claude_inbox/app/updating.rb
|
|
111
118
|
- lib/claude_inbox/cli.rb
|
|
112
119
|
- lib/claude_inbox/config.rb
|
|
113
120
|
- lib/claude_inbox/debug.rb
|
|
114
121
|
- lib/claude_inbox/dialog.rb
|
|
115
122
|
- lib/claude_inbox/headless.rb
|
|
116
123
|
- lib/claude_inbox/images.rb
|
|
124
|
+
- lib/claude_inbox/input.rb
|
|
117
125
|
- lib/claude_inbox/job_state.rb
|
|
118
126
|
- lib/claude_inbox/keymap.rb
|
|
119
|
-
- lib/claude_inbox/logs.rb
|
|
120
127
|
- lib/claude_inbox/mod.rb
|
|
121
128
|
- lib/claude_inbox/mouse.rb
|
|
122
129
|
- lib/claude_inbox/new_session_form.rb
|
|
123
130
|
- lib/claude_inbox/painter.rb
|
|
124
131
|
- lib/claude_inbox/palette.rb
|
|
125
132
|
- lib/claude_inbox/paste.rb
|
|
126
|
-
- lib/claude_inbox/peek.rb
|
|
127
133
|
- lib/claude_inbox/poller.rb
|
|
128
134
|
- lib/claude_inbox/pull_requests.rb
|
|
129
135
|
- lib/claude_inbox/rate_limits.rb
|
data/lib/claude_inbox/logs.rb
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "vt_screen"
|
|
4
|
-
|
|
5
|
-
module ClaudeInbox
|
|
6
|
-
# The `claude logs <id>` replay of each session as readable lines, fetched
|
|
7
|
-
# off the main thread, debounced and cached.
|
|
8
|
-
class Logs
|
|
9
|
-
DEBOUNCE = 0.25
|
|
10
|
-
TTL = 10
|
|
11
|
-
MAX_LINES = 400
|
|
12
|
-
|
|
13
|
-
def initialize(client, clock: -> { Time.now })
|
|
14
|
-
@client = client
|
|
15
|
-
@clock = clock
|
|
16
|
-
@cache = {}
|
|
17
|
-
@mutex = Mutex.new
|
|
18
|
-
@pending = nil
|
|
19
|
-
@pending_at = nil
|
|
20
|
-
@requests = Queue.new
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def start
|
|
24
|
-
return if @thread&.alive?
|
|
25
|
-
@thread = Thread.new { worker }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def cached(id)
|
|
29
|
-
@mutex.synchronize { @cache[id]&.first }
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def want(id)
|
|
33
|
-
@pending = id
|
|
34
|
-
@pending_at = @clock.call
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Promotes a request that has sat still for DEBOUNCE to the worker,
|
|
38
|
-
# unless the cache already has a fresh answer.
|
|
39
|
-
def tick
|
|
40
|
-
return unless @pending && @clock.call - @pending_at >= DEBOUNCE
|
|
41
|
-
id = @pending
|
|
42
|
-
@pending = nil
|
|
43
|
-
fresh = @mutex.synchronize { (e = @cache[id]) && @clock.call - e[1] < TTL }
|
|
44
|
-
@requests << id unless fresh
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def stop = @thread&.kill
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
|
|
51
|
-
def worker
|
|
52
|
-
loop do
|
|
53
|
-
id = @requests.pop
|
|
54
|
-
id = @requests.pop until @requests.empty? # only the latest matters
|
|
55
|
-
lines = fetch(id)
|
|
56
|
-
@mutex.synchronize { @cache[id] = [lines, @clock.call] }
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def fetch(id)
|
|
61
|
-
raw = @client.logs(id)
|
|
62
|
-
return ["(no output available — the session's process is not running)"] if raw.nil?
|
|
63
|
-
VtScreen.new.feed(raw).lines.last(MAX_LINES)
|
|
64
|
-
rescue => e
|
|
65
|
-
["(logs failed: #{e.message})"]
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
data/lib/claude_inbox/peek.rb
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module ClaudeInbox
|
|
4
|
-
# The peek pane: whether it is open, which row it is on, how far back it
|
|
5
|
-
# is scrolled, and what to paint for that. The lines themselves come from
|
|
6
|
-
# Logs, which it asks on every selection change so that opening the pane
|
|
7
|
-
# lands on a warm cache. Main-thread state only.
|
|
8
|
-
class Peek
|
|
9
|
-
TERMINAL_NOTE = "This is a claude you opened in a terminal yourself. The daemon can't attach to it, read its output, or stop it from outside. Switch to that window."
|
|
10
|
-
REMOTE_NOTE = "This is a Remote Control session driven from claude.ai/code. The daemon can't attach to it or read its output from here. Enter pulls it into the daemon; w opens it in the web or mobile app."
|
|
11
|
-
|
|
12
|
-
# What Renderer paints: the body lines, the title bar, the dim line under it.
|
|
13
|
-
View = Struct.new(:lines, :title, :subtitle)
|
|
14
|
-
|
|
15
|
-
def initialize(logs)
|
|
16
|
-
@logs = logs
|
|
17
|
-
@open = false
|
|
18
|
-
@offset = 0
|
|
19
|
-
@session = nil
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def open? = @open
|
|
23
|
-
|
|
24
|
-
def toggle
|
|
25
|
-
@open = !@open
|
|
26
|
-
@logs.want(@session.id) if @open && @session&.actionable?
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def close = @open = false
|
|
30
|
-
|
|
31
|
-
# Called on every selection change; a fold has no session.
|
|
32
|
-
def select(session)
|
|
33
|
-
@session = session
|
|
34
|
-
@offset = 0
|
|
35
|
-
@logs.want(session.id) if session&.actionable?
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Positive scrolls back into history, negative towards the tail.
|
|
39
|
-
def scroll(delta)
|
|
40
|
-
@offset = [@offset + delta, 0].max
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# `row` is the selected row as the frame shows it, or nil on a fold or
|
|
44
|
-
# with nothing selected. Answers nil when there is no pane to paint.
|
|
45
|
-
def view(row, body_h)
|
|
46
|
-
return nil unless @open && row
|
|
47
|
-
View.new(scrolled(body(row), body_h), row.label, subtitle(row))
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
def body(row)
|
|
53
|
-
return interactive_note(row.session) if row.session.interactive?
|
|
54
|
-
@logs.cached(row.session.id) || ["(loading…)"]
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def interactive_note(s)
|
|
58
|
-
[s.remote? ? REMOTE_NOTE : TERMINAL_NOTE, "", "pid #{s.pid} · #{s.cwd}", "session #{s.session_id}", s.remote_url].compact
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def subtitle(row)
|
|
62
|
-
s = row.session
|
|
63
|
-
parts = [s.effective_state, s.status, s.waiting_for, s.id, s.started_at&.strftime("started %b %-d %H:%M")].compact
|
|
64
|
-
parts += s.prs.map { |pr| "#{pr.short} #{pr.state&.downcase || "?"}" }
|
|
65
|
-
parts.join(" · ")
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Lines are shown tail-first; the offset scrolls back into history and is
|
|
69
|
-
# clamped to however much history there is.
|
|
70
|
-
def scrolled(lines, view_h)
|
|
71
|
-
return lines if @offset.zero?
|
|
72
|
-
max_off = [lines.size - view_h, 0].max
|
|
73
|
-
@offset = [@offset, max_off].min
|
|
74
|
-
lines[0, lines.size - @offset]
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|