agent-command-tab 0.1.0__py3-none-any.whl
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.
- agent_command_tab/__init__.py +4 -0
- agent_command_tab/agent_adapters/__init__.py +48 -0
- agent_command_tab/agent_adapters/base.py +162 -0
- agent_command_tab/agent_adapters/claude_code.py +120 -0
- agent_command_tab/agent_adapters/codex.py +102 -0
- agent_command_tab/agent_adapters/generic.py +22 -0
- agent_command_tab/agent_process_tree.py +557 -0
- agent_command_tab/agent_session_pausing.py +254 -0
- agent_command_tab/app_controller.py +947 -0
- agent_command_tab/claude_code_transcript_records.py +75 -0
- agent_command_tab/command_line.py +187 -0
- agent_command_tab/context_window_usage.py +230 -0
- agent_command_tab/dashboard_core_api.py +57 -0
- agent_command_tab/docked_window_frames_store.py +60 -0
- agent_command_tab/global_shortcut_key_filter.py +167 -0
- agent_command_tab/hook_event_forwarder.py +116 -0
- agent_command_tab/hook_event_tracking.py +129 -0
- agent_command_tab/hook_states_store.py +60 -0
- agent_command_tab/hooks_installer.py +300 -0
- agent_command_tab/installed_copy_paths.py +41 -0
- agent_command_tab/iterm2_actions.py +325 -0
- agent_command_tab/iterm2_connection_thread.py +2299 -0
- agent_command_tab/iterm2_snapshot_builder.py +403 -0
- agent_command_tab/list_sorting.py +117 -0
- agent_command_tab/messages_between_agent_sessions.py +78 -0
- agent_command_tab/monitor_assignment.py +109 -0
- agent_command_tab/pause_records_store.py +61 -0
- agent_command_tab/screen_readings.py +108 -0
- agent_command_tab/session_preview_computation.py +228 -0
- agent_command_tab/session_status_computation.py +235 -0
- agent_command_tab/settings_store.py +292 -0
- agent_command_tab/snapshot_data_classes.py +145 -0
- agent_command_tab/start_with_iterm2.py +138 -0
- agent_command_tab/tab_order_computation.py +26 -0
- agent_command_tab/user_interface/__init__.py +1 -0
- agent_command_tab/user_interface/agent_session_outline_view.py +2120 -0
- agent_command_tab/user_interface/agent_tool_icons.py +124 -0
- agent_command_tab/user_interface/app_icon.py +75 -0
- agent_command_tab/user_interface/control_helpers.py +38 -0
- agent_command_tab/user_interface/list_window.py +116 -0
- agent_command_tab/user_interface/menu_bar_status_item.py +193 -0
- agent_command_tab/user_interface/named_colors.py +58 -0
- agent_command_tab/user_interface/pointing_hand_button.py +42 -0
- agent_command_tab/user_interface/popover_container.py +461 -0
- agent_command_tab/user_interface/row_text_rendering.py +342 -0
- agent_command_tab/user_interface/screen_layout.py +91 -0
- agent_command_tab/user_interface/settings_window.py +530 -0
- agent_command_tab/user_interface/sidebar_panel.py +486 -0
- agent_command_tab/user_interface/sidebar_placement.py +105 -0
- agent_command_tab/user_interface/talk_to_each_other_alert.py +130 -0
- agent_command_tab/window_list_ordering.py +44 -0
- agent_command_tab-0.1.0.dist-info/METADATA +85 -0
- agent_command_tab-0.1.0.dist-info/RECORD +57 -0
- agent_command_tab-0.1.0.dist-info/WHEEL +5 -0
- agent_command_tab-0.1.0.dist-info/entry_points.txt +2 -0
- agent_command_tab-0.1.0.dist-info/licenses/LICENSE +21 -0
- agent_command_tab-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""Small icons that tell agent tools apart in the list's icon column.
|
|
2
|
+
|
|
3
|
+
They are drawn in code, Claude Code's from a pixel grid and Codex's from the OpenAI logo's
|
|
4
|
+
outline, so no logo files ship with the project. A tool without an icon here gets its name
|
|
5
|
+
drawn as a small image instead.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from AppKit import (NSAttributedString, NSColor, NSCompositingOperationSourceAtop, NSFontAttributeName,
|
|
9
|
+
NSForegroundColorAttributeName, NSImage, NSMakeRect, NSRectFill, NSRectFillUsingOperation)
|
|
10
|
+
|
|
11
|
+
# One character per point, top row first: "#" body, "E" eye, " " empty.
|
|
12
|
+
# Claude Code's mascot, the four-legged figure in its start-up banner.
|
|
13
|
+
CLAUDE_CODE_MASCOT_PIXEL_ROWS = [
|
|
14
|
+
" ############ ",
|
|
15
|
+
" ############ ",
|
|
16
|
+
" ##E######E## ",
|
|
17
|
+
" ##E######E## ",
|
|
18
|
+
" ############ ",
|
|
19
|
+
"################",
|
|
20
|
+
"################",
|
|
21
|
+
" ############ ",
|
|
22
|
+
" # # # # ",
|
|
23
|
+
" # # # # ",
|
|
24
|
+
]
|
|
25
|
+
# The OpenAI logo for Codex, in place of the ">_" from Codex's start-up banner (user request,
|
|
26
|
+
# 2026-10-27). The outline is Simple Icons' (simpleicons.org), which they release under CC0.
|
|
27
|
+
OPENAI_LOGO_SVG = (
|
|
28
|
+
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="'
|
|
29
|
+
"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9"
|
|
30
|
+
"A6.0651 6.0651 0 0 0 4.9807 4.1818"
|
|
31
|
+
"a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001"
|
|
32
|
+
"A5.9847 5.9847 0 0 0 13.2599 24"
|
|
33
|
+
"a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729z"
|
|
34
|
+
"m-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813"
|
|
35
|
+
"v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944z"
|
|
36
|
+
"m-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0"
|
|
37
|
+
"l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464z"
|
|
38
|
+
"M2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685"
|
|
39
|
+
"a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872z"
|
|
40
|
+
"m16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913"
|
|
41
|
+
"a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667z"
|
|
42
|
+
"m2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974"
|
|
43
|
+
"a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66z"
|
|
44
|
+
"M8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805"
|
|
45
|
+
"L8.704 5.459a.7948.7948 0 0 0-.3927.6813z"
|
|
46
|
+
"m1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"
|
|
47
|
+
'"/></svg>'
|
|
48
|
+
)
|
|
49
|
+
# Points square: a round shape this size looks about as big as the mascot, 10 points high.
|
|
50
|
+
OPENAI_LOGO_SIZE = 12
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def build_pixel_grid_image(pixel_rows, colors_by_character):
|
|
54
|
+
"""Returns an NSImage, one point per grid cell, drawn on demand so it stays sharp at any
|
|
55
|
+
scale and follows light and dark mode when given system colors.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
pixel_rows: Equal-length strings, top row first; a space is transparent.
|
|
59
|
+
colors_by_character: {character: NSColor}.
|
|
60
|
+
"""
|
|
61
|
+
width, height = len(pixel_rows[0]), len(pixel_rows)
|
|
62
|
+
|
|
63
|
+
def draw(destination_rect):
|
|
64
|
+
for row_index, pixel_row in enumerate(pixel_rows):
|
|
65
|
+
for column_index, character in enumerate(pixel_row):
|
|
66
|
+
if character != " ":
|
|
67
|
+
colors_by_character[character].set()
|
|
68
|
+
NSRectFill(NSMakeRect(column_index, height - 1 - row_index, 1, 1)) # bottom-left origin
|
|
69
|
+
return True
|
|
70
|
+
|
|
71
|
+
return NSImage.imageWithSize_flipped_drawingHandler_((width, height), False, draw)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def build_svg_image(svg_text, size, color):
|
|
75
|
+
"""Returns an NSImage of an SVG's shapes filled with one color, drawn on demand so it stays
|
|
76
|
+
sharp at any scale and follows light and dark mode when given a system color, or None
|
|
77
|
+
before macOS 14, which can't read SVG.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
svg_text: The SVG document.
|
|
81
|
+
size: The image's width and height in points.
|
|
82
|
+
color: NSColor.
|
|
83
|
+
"""
|
|
84
|
+
svg_image = NSImage.alloc().initWithData_(svg_text.encode())
|
|
85
|
+
if svg_image is None:
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
def draw(destination_rect):
|
|
89
|
+
svg_image.drawInRect_(destination_rect)
|
|
90
|
+
color.set()
|
|
91
|
+
NSRectFillUsingOperation(destination_rect, NSCompositingOperationSourceAtop) # colors only the shapes
|
|
92
|
+
return True
|
|
93
|
+
|
|
94
|
+
return NSImage.imageWithSize_flipped_drawingHandler_((size, size), False, draw)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def build_text_image(text, font):
|
|
98
|
+
"""Returns an NSImage of text in the secondary label color, for a tool without an icon."""
|
|
99
|
+
attributed_text = NSAttributedString.alloc().initWithString_attributes_(
|
|
100
|
+
text, {NSFontAttributeName: font, NSForegroundColorAttributeName: NSColor.secondaryLabelColor()})
|
|
101
|
+
size = attributed_text.size()
|
|
102
|
+
|
|
103
|
+
def draw(destination_rect):
|
|
104
|
+
attributed_text.drawAtPoint_((0, 0))
|
|
105
|
+
return True
|
|
106
|
+
|
|
107
|
+
return NSImage.imageWithSize_flipped_drawingHandler_((size.width, size.height), False, draw)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def describe_agent_tool_icon(agent_tool_name):
|
|
111
|
+
"""Returns the icon's hover text: the tool's name, with the company for Codex, whose icon is
|
|
112
|
+
the OpenAI logo (user request, 2026-10-27)."""
|
|
113
|
+
return {"Codex": "OpenAI Codex"}.get(agent_tool_name, agent_tool_name)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def build_agent_tool_icons():
|
|
117
|
+
"""Returns {agent tool name: NSImage} for the tools that have a drawn icon."""
|
|
118
|
+
clay_orange = NSColor.colorWithSRGBRed_green_blue_alpha_(215 / 255, 119 / 255, 87 / 255, 1.0)
|
|
119
|
+
icons_by_name = {
|
|
120
|
+
"Claude Code": build_pixel_grid_image(CLAUDE_CODE_MASCOT_PIXEL_ROWS, {"#": clay_orange, "E": NSColor.blackColor()})}
|
|
121
|
+
openai_logo = build_svg_image(OPENAI_LOGO_SVG, OPENAI_LOGO_SIZE, NSColor.labelColor())
|
|
122
|
+
if openai_logo is not None: # before macOS 14, Codex gets its name drawn instead
|
|
123
|
+
icons_by_name["Codex"] = openai_logo
|
|
124
|
+
return icons_by_name
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""The app's own icon (user request, 2026-10-28), drawn in code so no image file ships.
|
|
2
|
+
|
|
3
|
+
The Command key's ⌘, for the Command-Tab that the app's name plays on, white on a dark rounded
|
|
4
|
+
square, with a status dot in each of its loops in the list's colors: background's amber at the
|
|
5
|
+
top left, asking's blue at the top right, idle's gray at the bottom left and done's green at the
|
|
6
|
+
bottom right. The app's dialogs show it in place of Python's rocket: app_controller's
|
|
7
|
+
run_alert_in_front gives each one it, since NSAlert takes Python.app's own icon whatever NSApp's is.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import math
|
|
11
|
+
|
|
12
|
+
from AppKit import (NSBezierPath, NSColor, NSGradient, NSImage, NSMakePoint, NSMakeRect, NSRoundLineCapStyle,
|
|
13
|
+
NSRoundLineJoinStyle)
|
|
14
|
+
|
|
15
|
+
APP_ICON_SIZE = 1024 # points, the size macOS draws app icons at; the drawing stays sharp at any size
|
|
16
|
+
# Apple's macOS icon grid: the rounded square sits this far inside the canvas.
|
|
17
|
+
ICON_BODY_INSET, ICON_BODY_SIZE, ICON_BODY_CORNER_RADIUS = 100, 824, 185
|
|
18
|
+
# The ⌘: a square of this half side whose sides run on into a loop of this radius at each corner.
|
|
19
|
+
COMMAND_KEY_CENTER, COMMAND_KEY_HALF_SIDE, COMMAND_KEY_LOOP_RADIUS, COMMAND_KEY_LINE_WIDTH = 512, 92, 112, 58
|
|
20
|
+
STATUS_DOT_RADIUS = 52
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def make_srgb_color(red, green, blue, alpha=1.0):
|
|
24
|
+
return NSColor.colorWithSRGBRed_green_blue_alpha_(red / 255, green / 255, blue / 255, alpha)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# The status colors as the list draws them in dark mode, by the loop's corner (x and y direction from the center).
|
|
28
|
+
STATUS_DOT_COLOR_BY_CORNER = {
|
|
29
|
+
(-1, 1): make_srgb_color(255, 204, 0), # background's amber, top left
|
|
30
|
+
(1, 1): make_srgb_color(60, 211, 254), # asking's blue, top right
|
|
31
|
+
(-1, -1): make_srgb_color(142, 142, 147), # idle's gray, bottom left
|
|
32
|
+
(1, -1): make_srgb_color(48, 209, 88), # done's green, bottom right
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def build_app_icon():
|
|
37
|
+
"""Returns the icon as an NSImage that draws itself at whatever size it is shown."""
|
|
38
|
+
def draw(destination_rect):
|
|
39
|
+
draw_app_icon()
|
|
40
|
+
return True
|
|
41
|
+
return NSImage.imageWithSize_flipped_drawingHandler_((APP_ICON_SIZE, APP_ICON_SIZE), False, draw)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def draw_app_icon():
|
|
45
|
+
"""Draws the icon into the current graphics context, in a square APP_ICON_SIZE points wide."""
|
|
46
|
+
body = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(
|
|
47
|
+
NSMakeRect(ICON_BODY_INSET, ICON_BODY_INSET, ICON_BODY_SIZE, ICON_BODY_SIZE), ICON_BODY_CORNER_RADIUS, ICON_BODY_CORNER_RADIUS)
|
|
48
|
+
NSGradient.alloc().initWithStartingColor_endingColor_(make_srgb_color(58, 60, 66), make_srgb_color(24, 25, 28)).drawInBezierPath_angle_(body, -90)
|
|
49
|
+
make_srgb_color(255, 255, 255, 0.10).set() # a faint rim, so the square holds its shape on a dark background
|
|
50
|
+
body.setLineWidth_(4)
|
|
51
|
+
body.stroke()
|
|
52
|
+
command_key = NSBezierPath.bezierPath()
|
|
53
|
+
command_key.setLineWidth_(COMMAND_KEY_LINE_WIDTH)
|
|
54
|
+
command_key.setLineCapStyle_(NSRoundLineCapStyle)
|
|
55
|
+
command_key.setLineJoinStyle_(NSRoundLineJoinStyle)
|
|
56
|
+
corner_offset = COMMAND_KEY_HALF_SIDE + COMMAND_KEY_LOOP_RADIUS
|
|
57
|
+
for (sign_x, sign_y), start_angle in (((1, 1), 180), ((-1, 1), 270), ((-1, -1), 0), ((1, -1), 90)):
|
|
58
|
+
# Each loop goes three quarters round, from where one side meets it to where the next side leaves it.
|
|
59
|
+
loop_center = NSMakePoint(COMMAND_KEY_CENTER + sign_x * corner_offset, COMMAND_KEY_CENTER + sign_y * corner_offset)
|
|
60
|
+
command_key.moveToPoint_(NSMakePoint(loop_center.x + COMMAND_KEY_LOOP_RADIUS * math.cos(math.radians(start_angle)),
|
|
61
|
+
loop_center.y + COMMAND_KEY_LOOP_RADIUS * math.sin(math.radians(start_angle))))
|
|
62
|
+
command_key.appendBezierPathWithArcWithCenter_radius_startAngle_endAngle_clockwise_(
|
|
63
|
+
loop_center, COMMAND_KEY_LOOP_RADIUS, start_angle, start_angle - 270, True)
|
|
64
|
+
for sign in (1, -1): # the square's sides, from loop to loop
|
|
65
|
+
command_key.moveToPoint_(NSMakePoint(COMMAND_KEY_CENTER + sign * COMMAND_KEY_HALF_SIDE, COMMAND_KEY_CENTER - corner_offset))
|
|
66
|
+
command_key.lineToPoint_(NSMakePoint(COMMAND_KEY_CENTER + sign * COMMAND_KEY_HALF_SIDE, COMMAND_KEY_CENTER + corner_offset))
|
|
67
|
+
command_key.moveToPoint_(NSMakePoint(COMMAND_KEY_CENTER - corner_offset, COMMAND_KEY_CENTER + sign * COMMAND_KEY_HALF_SIDE))
|
|
68
|
+
command_key.lineToPoint_(NSMakePoint(COMMAND_KEY_CENTER + corner_offset, COMMAND_KEY_CENTER + sign * COMMAND_KEY_HALF_SIDE))
|
|
69
|
+
make_srgb_color(245, 245, 247).set()
|
|
70
|
+
command_key.stroke()
|
|
71
|
+
for (sign_x, sign_y), color in STATUS_DOT_COLOR_BY_CORNER.items():
|
|
72
|
+
color.set()
|
|
73
|
+
NSBezierPath.bezierPathWithOvalInRect_(NSMakeRect(
|
|
74
|
+
COMMAND_KEY_CENTER + sign_x * corner_offset - STATUS_DOT_RADIUS, COMMAND_KEY_CENTER + sign_y * corner_offset - STATUS_DOT_RADIUS,
|
|
75
|
+
2 * STATUS_DOT_RADIUS, 2 * STATUS_DOT_RADIUS)).fill()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Helpers for buttons and pop-ups shared by the list's rows, the panel around the list and the settings window."""
|
|
2
|
+
|
|
3
|
+
from AppKit import NSFontWeightBold, NSImage, NSImageOnly, NSImageSymbolConfiguration
|
|
4
|
+
|
|
5
|
+
# The SF Symbols of the buttons that open or close several rows at once (the top bar's expand or
|
|
6
|
+
# collapse all, a window row's previews), by whether those rows are open: the symbol shows the
|
|
7
|
+
# current state (user request, 2026-10-19).
|
|
8
|
+
ROWS_OPEN_SYMBOL_NAMES = {False: "rectangle.compress.vertical", True: "rectangle.expand.vertical"}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def show_symbol_on_button(button, symbol_name, fallback_title, accessibility_description, point_size=None):
|
|
12
|
+
"""Shows an SF Symbol on the button (at point_size, if given), or the fallback text where the
|
|
13
|
+
symbol doesn't exist."""
|
|
14
|
+
image = NSImage.imageWithSystemSymbolName_accessibilityDescription_(symbol_name, accessibility_description)
|
|
15
|
+
if image is not None and point_size is not None:
|
|
16
|
+
image = image.imageWithSymbolConfiguration_(
|
|
17
|
+
NSImageSymbolConfiguration.configurationWithPointSize_weight_(point_size, NSFontWeightBold))
|
|
18
|
+
button.setImage_(image)
|
|
19
|
+
button.setTitle_("" if image is not None else fallback_title)
|
|
20
|
+
button.setImagePosition_(NSImageOnly if image is not None else 0) # 0: NSNoImage, the title alone
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def add_popup_choices(popup, titles_by_value):
|
|
24
|
+
"""Adds one item to an NSPopUpButton for each setting value, titled from titles_by_value,
|
|
25
|
+
that keeps its value, so a choice is read back by value rather than by its title."""
|
|
26
|
+
for value, title in titles_by_value.items():
|
|
27
|
+
popup.addItemWithTitle_(title)
|
|
28
|
+
popup.lastItem().setRepresentedObject_(value)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def select_popup_choice(popup, value):
|
|
32
|
+
"""Selects the pop-up's item for a setting value (add_popup_choices)."""
|
|
33
|
+
popup.selectItemAtIndex_(popup.indexOfItemWithRepresentedObject_(value))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def read_popup_choice(popup):
|
|
37
|
+
"""Returns the setting value of the pop-up's selected item (add_popup_choices)."""
|
|
38
|
+
return str(popup.selectedItem().representedObject())
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""The list in a regular window, for "Show as: Window" in the settings (user request, 2026-10-19).
|
|
2
|
+
|
|
3
|
+
A titled window you can move, resize and minimize, holding its own list controller and panel
|
|
4
|
+
(the same panel as the dropdown's and the sidebar's). It remembers its frame in the settings.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import objc
|
|
8
|
+
from AppKit import (NSApp, NSBackingStoreBuffered, NSEvent, NSEventMaskLeftMouseDragged, NSEventMaskLeftMouseUp,
|
|
9
|
+
NSEventTrackingRunLoopMode, NSEventTypeLeftMouseUp, NSFloatingWindowLevel, NSMakeRect,
|
|
10
|
+
NSNormalWindowLevel, NSWindow, NSWindowStyleMaskClosable, NSWindowStyleMaskMiniaturizable,
|
|
11
|
+
NSWindowStyleMaskResizable, NSWindowStyleMaskTitled)
|
|
12
|
+
from Foundation import NSDate
|
|
13
|
+
from PyObjCTools import AppHelper
|
|
14
|
+
|
|
15
|
+
from agent_command_tab.settings_store import SMALLEST_WINDOW_SIZES
|
|
16
|
+
from agent_command_tab.user_interface.agent_session_outline_view import AgentSessionListController
|
|
17
|
+
from agent_command_tab.user_interface.popover_container import ListPanelController
|
|
18
|
+
from agent_command_tab.user_interface.screen_layout import (WindowFrameSavingController,
|
|
19
|
+
place_window_at_saved_frame_or_center)
|
|
20
|
+
|
|
21
|
+
FIRST_LIST_WINDOW_SIZE = (480, 560)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ListWindowController(WindowFrameSavingController):
|
|
25
|
+
"""Owns the list window, its own list controller and panel.
|
|
26
|
+
|
|
27
|
+
The owner is the app controller (see AgentSessionListController for the methods it has); the
|
|
28
|
+
window also calls its window_frame_changed("list_window_frame", frame) after it is moved or resized,
|
|
29
|
+
list_window_drag_started(), list_window_is_being_dragged() and list_window_drag_ended() around
|
|
30
|
+
a drag (dropped on the menu bar icon, the window turns back into the dropdown), and
|
|
31
|
+
list_window_closed() after its close button hides it.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
frame_setting_name = "list_window_frame"
|
|
35
|
+
|
|
36
|
+
def initWithOwner_(self, owner):
|
|
37
|
+
self = objc.super(ListWindowController, self).init()
|
|
38
|
+
if self is None:
|
|
39
|
+
return None
|
|
40
|
+
self.owner = owner
|
|
41
|
+
self.list_controller = AgentSessionListController.alloc().initWithOwner_(owner)
|
|
42
|
+
self.list_controller.width_is_set_by_the_user = True # a narrow window drops columns, as the sidebar does
|
|
43
|
+
self.list_panel_controller = ListPanelController.alloc().initWithListController_(self.list_controller)
|
|
44
|
+
self.window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(
|
|
45
|
+
NSMakeRect(0, 0, *FIRST_LIST_WINDOW_SIZE),
|
|
46
|
+
NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable,
|
|
47
|
+
NSBackingStoreBuffered, False)
|
|
48
|
+
self.window.setTitle_("AgentCommandTab")
|
|
49
|
+
self.window.setReleasedWhenClosed_(False) # closing only hides it; the menu bar icon brings it back
|
|
50
|
+
self.window.setMinSize_(SMALLEST_WINDOW_SIZES["list_window_frame"])
|
|
51
|
+
self.window.setAllowsToolTipsWhenApplicationIsInactive_(True) # hover texts while another app is in front
|
|
52
|
+
self.window.setContentView_(self.list_panel_controller.view())
|
|
53
|
+
self.window.setDelegate_(self)
|
|
54
|
+
return self
|
|
55
|
+
|
|
56
|
+
@objc.python_method
|
|
57
|
+
def show(self, saved_frame, takes_keyboard_focus=True, stays_behind_other_windows=False):
|
|
58
|
+
"""Shows the window at its saved frame (x, y, width, height) when that is still on a
|
|
59
|
+
connected screen, else in the middle of the main screen: in front with the keyboard, in
|
|
60
|
+
front without it (the app you are typing in keeps it), or, with
|
|
61
|
+
stays_behind_other_windows (at the app's start, also after each automatic restart while
|
|
62
|
+
iTerm2 can't be reached), behind the other windows."""
|
|
63
|
+
if not self.window.isVisible():
|
|
64
|
+
place_window_at_saved_frame_or_center(self.window, saved_frame)
|
|
65
|
+
self.list_controller.prepare_to_appear() # the list skips redraws while hidden
|
|
66
|
+
if stays_behind_other_windows:
|
|
67
|
+
self.window.orderBack_(None)
|
|
68
|
+
elif takes_keyboard_focus:
|
|
69
|
+
NSApp.activateIgnoringOtherApps_(True)
|
|
70
|
+
self.window.makeKeyAndOrderFront_(None)
|
|
71
|
+
else:
|
|
72
|
+
self.window.orderFrontRegardless()
|
|
73
|
+
|
|
74
|
+
@objc.python_method
|
|
75
|
+
def hide(self):
|
|
76
|
+
self.window.orderOut_(None)
|
|
77
|
+
|
|
78
|
+
@objc.python_method
|
|
79
|
+
def is_in_front(self):
|
|
80
|
+
"""Whether the window shows in front of other windows: it is on the desktop (Space) in
|
|
81
|
+
view, and it has the keyboard or is always on top (a minimized window isn't visible)."""
|
|
82
|
+
return (self.window.isVisible() and self.window.isOnActiveSpace()
|
|
83
|
+
and (self.window.isKeyWindow() or self.window.level() > NSNormalWindowLevel))
|
|
84
|
+
|
|
85
|
+
@objc.python_method
|
|
86
|
+
def apply_settings(self, settings):
|
|
87
|
+
"""Keeps the window above other apps' windows while "Always on top" is checked."""
|
|
88
|
+
self.window.setLevel_(NSFloatingWindowLevel if settings["list_window_is_always_on_top"] else NSNormalWindowLevel)
|
|
89
|
+
|
|
90
|
+
@objc.python_method
|
|
91
|
+
def follow_the_pointer_until_the_button_comes_up(self, pointer_offset):
|
|
92
|
+
"""Moves the window with the pointer, keeping the pointer pointer_offset (x, y) from the
|
|
93
|
+
window's bottom-left corner, until the mouse button comes up: the drag that detached the
|
|
94
|
+
dropdown goes on in this window (user request, 2026-10-19)."""
|
|
95
|
+
while True:
|
|
96
|
+
event = NSApp.nextEventMatchingMask_untilDate_inMode_dequeue_(
|
|
97
|
+
NSEventMaskLeftMouseDragged | NSEventMaskLeftMouseUp, NSDate.distantFuture(), NSEventTrackingRunLoopMode, True)
|
|
98
|
+
pointer = NSEvent.mouseLocation()
|
|
99
|
+
self.window.setFrameOrigin_((pointer.x - pointer_offset[0], pointer.y - pointer_offset[1]))
|
|
100
|
+
self.owner.list_window_is_being_dragged()
|
|
101
|
+
if event.type() == NSEventTypeLeftMouseUp:
|
|
102
|
+
break
|
|
103
|
+
self.report_frame()
|
|
104
|
+
self.owner.list_window_drag_ended()
|
|
105
|
+
|
|
106
|
+
def windowWillMove_(self, notification):
|
|
107
|
+
# Its title bar is being dragged: the owner watches whether it is dropped on the menu bar icon.
|
|
108
|
+
self.owner.list_window_drag_started()
|
|
109
|
+
|
|
110
|
+
def windowWillClose_(self, notification):
|
|
111
|
+
AppHelper.callAfter(self.owner.list_window_closed) # once it is no longer visible
|
|
112
|
+
|
|
113
|
+
def windowDidResignKey_(self, notification):
|
|
114
|
+
# A click in another app ends an open rename without renaming, as in the sidebar; the list
|
|
115
|
+
# would stop updating while the field stays open.
|
|
116
|
+
self.list_controller.cancel_rename()
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"""The menu bar item: a colored "C" followed by the number of asking agent sessions."""
|
|
2
|
+
|
|
3
|
+
import objc
|
|
4
|
+
from AppKit import (NSApp, NSAttributedString, NSColor, NSEventMaskLeftMouseDown, NSEventMaskLeftMouseUp,
|
|
5
|
+
NSEventMaskRightMouseUp, NSEventTypeLeftMouseDown, NSEventTypeRightMouseUp, NSFont,
|
|
6
|
+
NSFontAttributeName, NSFontWeightBold, NSForegroundColorAttributeName, NSMenu, NSMenuItem,
|
|
7
|
+
NSMinYEdge, NSMutableAttributedString, NSStatusBar, NSVariableStatusItemLength, NSWorkspace)
|
|
8
|
+
from Foundation import NSObject, NSProcessInfo
|
|
9
|
+
|
|
10
|
+
from agent_command_tab.session_status_computation import pick_most_urgent_state
|
|
11
|
+
from agent_command_tab.snapshot_data_classes import iterate_agent_session_entries
|
|
12
|
+
from agent_command_tab.user_interface.named_colors import build_color_from_name
|
|
13
|
+
from agent_command_tab.user_interface.row_text_rendering import DOT_GLYPH_AND_COLOR_BY_STATE
|
|
14
|
+
|
|
15
|
+
# The icon color of the most urgent state: the rows' dot color for that state, otherwise green.
|
|
16
|
+
ICON_COLOR_NAME_BY_MOST_URGENT_STATE = {state: DOT_GLYPH_AND_COLOR_BY_STATE[state][1]
|
|
17
|
+
for state in ("asking", "error", "stuck")}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def count_asking_agent_sessions(snapshot):
|
|
21
|
+
"""Returns how many agent sessions in the snapshot are asking."""
|
|
22
|
+
return sum(1 for _, _, agent_session_entry in iterate_agent_session_entries(snapshot)
|
|
23
|
+
if agent_session_entry.status == "asking")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def choose_icon_color_name(snapshot):
|
|
27
|
+
"""Returns the icon's color: light blue while any agent session is asking, else red if any has
|
|
28
|
+
an error, else orange if any is stuck, otherwise green."""
|
|
29
|
+
states = [agent_session_entry.status for _, _, agent_session_entry in iterate_agent_session_entries(snapshot)]
|
|
30
|
+
return ICON_COLOR_NAME_BY_MOST_URGENT_STATE.get(pick_most_urgent_state(states), "green")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def choose_what_a_click_on_the_icon_does_to_the_dropdown(dropdown_is_shown, dropdown_closed_at, button_pressed_at):
|
|
34
|
+
"""Returns "close", "open" or "nothing" for a click on the menu bar icon, at its mouse-up.
|
|
35
|
+
|
|
36
|
+
The dropdown closes by itself as the mouse button goes down outside it, on the icon too,
|
|
37
|
+
before the click's mouse-up arrives. A dropdown that closed during this click stays closed,
|
|
38
|
+
rather than opening again, so every click toggles it (user request, 2026-10-28); before, a
|
|
39
|
+
slow click opened it again, and only a quick one, while it was still closing, closed it.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
dropdown_is_shown: Whether the dropdown is open (or still closing).
|
|
43
|
+
dropdown_closed_at: When it last began to close, in seconds since the Mac started (an
|
|
44
|
+
event's timestamp), or 0.
|
|
45
|
+
button_pressed_at: The click's mouse-down timestamp, or 0 when that wasn't seen (the
|
|
46
|
+
click then opens it, as before).
|
|
47
|
+
"""
|
|
48
|
+
if dropdown_is_shown:
|
|
49
|
+
return "close"
|
|
50
|
+
if button_pressed_at and dropdown_closed_at >= button_pressed_at:
|
|
51
|
+
return "nothing"
|
|
52
|
+
return "open"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class MenuBarStatusItemController(NSObject):
|
|
56
|
+
"""Owns the NSStatusItem. A left click shows the list (the owner decides how: toggle_popover
|
|
57
|
+
for the dropdown); a right click shows a small menu.
|
|
58
|
+
|
|
59
|
+
The owner (the app controller) has menu_bar_icon_clicked(), show_the_list_as(show_as_choice),
|
|
60
|
+
open_settings(), quit() and note_application_in_front_before_dropdown(application).
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
def initWithPopover_owner_(self, popover, owner):
|
|
64
|
+
self = objc.super(MenuBarStatusItemController, self).init()
|
|
65
|
+
if self is None:
|
|
66
|
+
return None
|
|
67
|
+
self.popover = popover
|
|
68
|
+
self.owner = owner
|
|
69
|
+
self.asking_count = 0
|
|
70
|
+
self.icon_color_name = "green"
|
|
71
|
+
self.has_connection_problem = False
|
|
72
|
+
# For choose_what_a_click_on_the_icon_does_to_the_dropdown: event timestamps, 0 until seen.
|
|
73
|
+
self.dropdown_closed_at = 0
|
|
74
|
+
self.left_button_pressed_at = 0
|
|
75
|
+
self.status_item = NSStatusBar.systemStatusBar().statusItemWithLength_(NSVariableStatusItemLength)
|
|
76
|
+
button = self.status_item.button()
|
|
77
|
+
button.setTarget_(self)
|
|
78
|
+
button.setAction_("statusItemClicked:")
|
|
79
|
+
# The mouse-down only notes when the click began; the mouse-up acts.
|
|
80
|
+
button.sendActionOn_(NSEventMaskLeftMouseDown | NSEventMaskLeftMouseUp | NSEventMaskRightMouseUp)
|
|
81
|
+
self.redraw()
|
|
82
|
+
return self
|
|
83
|
+
|
|
84
|
+
@objc.python_method
|
|
85
|
+
def show_snapshot(self, snapshot):
|
|
86
|
+
"""Shows how many agent sessions are asking, in the color of the most urgent agent session."""
|
|
87
|
+
self.asking_count = count_asking_agent_sessions(snapshot)
|
|
88
|
+
self.icon_color_name = choose_icon_color_name(snapshot)
|
|
89
|
+
self.has_connection_problem = False
|
|
90
|
+
self.redraw()
|
|
91
|
+
|
|
92
|
+
@objc.python_method
|
|
93
|
+
def show_connection_problem(self):
|
|
94
|
+
"""Draws the "C" in gray while iTerm2 can't be reached."""
|
|
95
|
+
self.has_connection_problem = True
|
|
96
|
+
self.redraw()
|
|
97
|
+
|
|
98
|
+
@objc.python_method
|
|
99
|
+
def redraw(self):
|
|
100
|
+
"""Draws the "C" in the most urgent agent session's color (gray during a connection problem),
|
|
101
|
+
plus the asking count in light blue (the color of "asking" everywhere)."""
|
|
102
|
+
letter_color = (NSColor.secondaryLabelColor() if self.has_connection_problem
|
|
103
|
+
else build_color_from_name(self.icon_color_name, NSColor.systemGreenColor))
|
|
104
|
+
font = NSFont.menuBarFontOfSize_(0)
|
|
105
|
+
title = NSMutableAttributedString.alloc().init()
|
|
106
|
+
title.appendAttributedString_(NSAttributedString.alloc().initWithString_attributes_(
|
|
107
|
+
"C", {NSFontAttributeName: NSFont.systemFontOfSize_weight_(font.pointSize(), NSFontWeightBold),
|
|
108
|
+
NSForegroundColorAttributeName: letter_color}))
|
|
109
|
+
if self.asking_count and not self.has_connection_problem:
|
|
110
|
+
title.appendAttributedString_(NSAttributedString.alloc().initWithString_attributes_(
|
|
111
|
+
f" {self.asking_count}", {NSFontAttributeName: font, NSForegroundColorAttributeName: build_color_from_name(
|
|
112
|
+
DOT_GLYPH_AND_COLOR_BY_STATE["asking"][1])}))
|
|
113
|
+
self.status_item.button().setAttributedTitle_(title)
|
|
114
|
+
|
|
115
|
+
def statusItemClicked_(self, sender):
|
|
116
|
+
event = NSApp.currentEvent()
|
|
117
|
+
if event.type() == NSEventTypeLeftMouseDown:
|
|
118
|
+
self.left_button_pressed_at = event.timestamp()
|
|
119
|
+
elif event.type() == NSEventTypeRightMouseUp:
|
|
120
|
+
self.show_right_click_menu()
|
|
121
|
+
else:
|
|
122
|
+
self.owner.menu_bar_icon_clicked()
|
|
123
|
+
|
|
124
|
+
@objc.python_method
|
|
125
|
+
def note_dropdown_closing(self):
|
|
126
|
+
"""The dropdown began to close (the app controller is its delegate): noted as the time of
|
|
127
|
+
the event that closed it, often the mouse-down of a click on the icon, so it is in the
|
|
128
|
+
same clock as the click; without an event (a timer), as the time since the Mac started,
|
|
129
|
+
which event timestamps count too."""
|
|
130
|
+
event = NSApp.currentEvent()
|
|
131
|
+
self.dropdown_closed_at = event.timestamp() if event is not None else NSProcessInfo.processInfo().systemUptime()
|
|
132
|
+
|
|
133
|
+
@objc.python_method
|
|
134
|
+
def find_icon_frame_on_screen(self):
|
|
135
|
+
"""Returns the icon's frame in screen coordinates (its status bar window's frame)."""
|
|
136
|
+
return self.status_item.button().window().frame()
|
|
137
|
+
|
|
138
|
+
@objc.python_method
|
|
139
|
+
def highlight(self, is_highlighted):
|
|
140
|
+
"""Highlights the icon as a drop target while the list window is dragged onto it."""
|
|
141
|
+
if bool(self.status_item.button().isHighlighted()) != is_highlighted:
|
|
142
|
+
self.status_item.button().highlight_(is_highlighted)
|
|
143
|
+
|
|
144
|
+
@objc.python_method
|
|
145
|
+
def toggle_popover(self):
|
|
146
|
+
"""Opens the dropdown, or closes it when it is open or closed during this click."""
|
|
147
|
+
what_to_do = choose_what_a_click_on_the_icon_does_to_the_dropdown(
|
|
148
|
+
self.popover.isShown(), self.dropdown_closed_at, self.left_button_pressed_at)
|
|
149
|
+
if what_to_do == "close":
|
|
150
|
+
self.popover.performClose_(None)
|
|
151
|
+
elif what_to_do == "open":
|
|
152
|
+
self.show_popover()
|
|
153
|
+
|
|
154
|
+
@objc.python_method
|
|
155
|
+
def show_popover(self):
|
|
156
|
+
self.owner.note_application_in_front_before_dropdown(NSWorkspace.sharedWorkspace().frontmostApplication())
|
|
157
|
+
NSApp.activateIgnoringOtherApps_(True) # so the list can take typing (rename)
|
|
158
|
+
list_panel_controller = self.popover.contentViewController()
|
|
159
|
+
list_panel_controller.list_controller.prepare_to_appear() # the list skips redraws while closed
|
|
160
|
+
list_panel_controller.fit_size_to_rows()
|
|
161
|
+
button = self.status_item.button()
|
|
162
|
+
self.popover.showRelativeToRect_ofView_preferredEdge_(button.bounds(), button, NSMinYEdge)
|
|
163
|
+
|
|
164
|
+
@objc.python_method
|
|
165
|
+
def show_right_click_menu(self):
|
|
166
|
+
menu = NSMenu.alloc().initWithTitle_("")
|
|
167
|
+
# Each way to show the list, whatever "Show as" is, without changing it (user request,
|
|
168
|
+
# 2026-10-28; "Show the sidebar" alone until then), in sentence case as the other menus are.
|
|
169
|
+
for title, action_name in (("Show popup", "showPopupClicked:"), ("Show sidebar", "showSidebarClicked:"),
|
|
170
|
+
("Show window", "showWindowClicked:"), (None, None), ("Settings…", "settingsClicked:"),
|
|
171
|
+
(None, None), ("Quit AgentCommandTab", "quitClicked:")):
|
|
172
|
+
if title is None:
|
|
173
|
+
menu.addItem_(NSMenuItem.separatorItem())
|
|
174
|
+
continue
|
|
175
|
+
menu_item = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(title, action_name, "")
|
|
176
|
+
menu_item.setTarget_(self)
|
|
177
|
+
menu.addItem_(menu_item)
|
|
178
|
+
self.status_item.popUpStatusItemMenu_(menu)
|
|
179
|
+
|
|
180
|
+
def showPopupClicked_(self, sender):
|
|
181
|
+
self.owner.show_the_list_as("popup")
|
|
182
|
+
|
|
183
|
+
def showSidebarClicked_(self, sender):
|
|
184
|
+
self.owner.show_the_list_as("sidebar")
|
|
185
|
+
|
|
186
|
+
def showWindowClicked_(self, sender):
|
|
187
|
+
self.owner.show_the_list_as("window")
|
|
188
|
+
|
|
189
|
+
def settingsClicked_(self, sender):
|
|
190
|
+
self.owner.open_settings()
|
|
191
|
+
|
|
192
|
+
def quitClicked_(self, sender):
|
|
193
|
+
self.owner.quit()
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""The colors of the menu bar icon and the list's rows, by name: the rows' color names
|
|
2
|
+
(row_text_rendering), which the icon uses too. "light_blue" is the color of "asking" everywhere
|
|
3
|
+
(user request, milestone 2)."""
|
|
4
|
+
|
|
5
|
+
from AppKit import NSAppearanceNameAqua, NSAppearanceNameDarkAqua, NSColor
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def make_srgb_color_maker(red, green, blue):
|
|
9
|
+
"""Returns a function that makes this color, like NSColor.systemRedColor does for red."""
|
|
10
|
+
return lambda: NSColor.colorWithSRGBRed_green_blue_alpha_(red / 255, green / 255, blue / 255, 1)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def appearance_is_dark(appearance):
|
|
14
|
+
"""Returns whether this NSAppearance (a view's effectiveAppearance, for example) is dark mode's."""
|
|
15
|
+
return appearance.bestMatchFromAppearancesWithNames_([NSAppearanceNameAqua, NSAppearanceNameDarkAqua]) == NSAppearanceNameDarkAqua
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def make_light_and_dark_mode_color_maker(light_mode_color_maker, dark_mode_color_maker):
|
|
19
|
+
"""Returns a function that makes a color drawn as light_mode_color_maker's in light mode and
|
|
20
|
+
as dark_mode_color_maker's in dark mode, as the system colors are."""
|
|
21
|
+
def choose_color_for_appearance(appearance):
|
|
22
|
+
if appearance_is_dark(appearance):
|
|
23
|
+
return dark_mode_color_maker()
|
|
24
|
+
return light_mode_color_maker()
|
|
25
|
+
return lambda: NSColor.colorWithName_dynamicProvider_(None, choose_color_for_appearance)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# Purple is a fixed color, since on current macOS the system purple is a magenta.
|
|
29
|
+
COLOR_MAKERS_BY_NAME = {
|
|
30
|
+
"purple": make_srgb_color_maker(150, 95, 255), "red": NSColor.systemRedColor, "orange": NSColor.systemOrangeColor,
|
|
31
|
+
"green": NSColor.systemGreenColor, "light_blue": NSColor.systemCyanColor, "gray": NSColor.secondaryLabelColor,
|
|
32
|
+
"yellow": NSColor.systemYellowColor, # the background task lights
|
|
33
|
+
# The Tokens column's share of the context window from 50% (user request, 2026-10-27). The system
|
|
34
|
+
# yellow is hard to read as text on white (contrast 1.5 to 1), so light mode has a darker amber,
|
|
35
|
+
# 2.8 to 1 (brighter than the first one, 168, 118, 0 at 4 to 1, since 2026-10-28, user request).
|
|
36
|
+
"amber": make_light_and_dark_mode_color_maker(make_srgb_color_maker(205, 145, 0), NSColor.systemYellowColor),
|
|
37
|
+
# The status text (user requests, 2026-10-28). The system green, cyan and orange are hard to
|
|
38
|
+
# read as text on white too (about 2.2 to 1), so light mode has them about two thirds as
|
|
39
|
+
# bright (4.5 to 1). Done is gray in light mode only. Unknown is pure black, or pure white in
|
|
40
|
+
# dark mode, a step past the names' 85% (user request, 2026-10-28).
|
|
41
|
+
"green_text": make_light_and_dark_mode_color_maker(make_srgb_color_maker(35, 135, 61), NSColor.systemGreenColor),
|
|
42
|
+
"light_blue_text": make_light_and_dark_mode_color_maker(make_srgb_color_maker(0, 129, 155), NSColor.systemCyanColor),
|
|
43
|
+
"orange_text": make_light_and_dark_mode_color_maker(make_srgb_color_maker(176, 97, 28), NSColor.systemOrangeColor),
|
|
44
|
+
"gray_in_light_mode_only": make_light_and_dark_mode_color_maker(NSColor.secondaryLabelColor, NSColor.labelColor),
|
|
45
|
+
"pure_black_or_white": NSColor.textColor,
|
|
46
|
+
# Idle's status text, a little closer to the background than the gray (secondaryLabelColor,
|
|
47
|
+
# black at 50% or white at 55%) of done and exited (user request, 2026-10-28).
|
|
48
|
+
"light_gray": make_light_and_dark_mode_color_maker(lambda: NSColor.colorWithSRGBRed_green_blue_alpha_(0, 0, 0, 0.38),
|
|
49
|
+
lambda: NSColor.colorWithSRGBRed_green_blue_alpha_(1, 1, 1, 0.40)),
|
|
50
|
+
# The list's rows' background: a very light gray in light mode rather than controlBackgroundColor's
|
|
51
|
+
# white (user request, 2026-10-28); dark mode keeps it, which the bars around the list are drawn on too.
|
|
52
|
+
"list_background": make_light_and_dark_mode_color_maker(make_srgb_color_maker(247, 247, 247), NSColor.controlBackgroundColor),
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def build_color_from_name(color_name, fallback_color_maker=NSColor.labelColor):
|
|
57
|
+
"""Returns the color with this name, or the fallback's color for a name not in COLOR_MAKERS_BY_NAME."""
|
|
58
|
+
return COLOR_MAKERS_BY_NAME.get(color_name, fallback_color_maker)()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""A button that shows the pointing hand while the pointer is over it (user request, 2026-10-19).
|
|
2
|
+
|
|
3
|
+
Used for the list's icon buttons (a row's arrow, a window's preview button, the "+" row) and the
|
|
4
|
+
top and bottom bars' buttons. The sidebar window turns cursor rects off (they reset its edge's
|
|
5
|
+
left-right arrows), so the hand is set from a tracking area, which also works while another app
|
|
6
|
+
is in front (sidebar_panel.allow_pointer_changes_while_another_app_is_in_front); the cursor rect
|
|
7
|
+
covers the dropdown and the list window, where cursor rects are on.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import objc
|
|
11
|
+
from AppKit import (NSButton, NSCursor, NSTrackingActiveAlways, NSTrackingArea, NSTrackingCursorUpdate,
|
|
12
|
+
NSTrackingInVisibleRect, NSTrackingMouseEnteredAndExited, NSZeroRect)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class PointingHandButton(NSButton):
|
|
16
|
+
"""An NSButton whose pointer is the pointing hand, unless the button is hidden."""
|
|
17
|
+
|
|
18
|
+
def initWithFrame_(self, frame):
|
|
19
|
+
self = objc.super(PointingHandButton, self).initWithFrame_(frame)
|
|
20
|
+
if self is None:
|
|
21
|
+
return None
|
|
22
|
+
self.addTrackingArea_(NSTrackingArea.alloc().initWithRect_options_owner_userInfo_(
|
|
23
|
+
NSZeroRect, NSTrackingCursorUpdate | NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways
|
|
24
|
+
| NSTrackingInVisibleRect, self, None))
|
|
25
|
+
return self
|
|
26
|
+
|
|
27
|
+
def resetCursorRects(self):
|
|
28
|
+
# The visible part only: cursor rects aren't clipped to the scroll view, so a row's button
|
|
29
|
+
# scrolled partly under the top bar would show the hand over the bar.
|
|
30
|
+
if not self.isHiddenOrHasHiddenAncestor():
|
|
31
|
+
self.addCursorRect_cursor_(self.visibleRect(), NSCursor.pointingHandCursor())
|
|
32
|
+
|
|
33
|
+
def cursorUpdate_(self, event):
|
|
34
|
+
if not self.isHiddenOrHasHiddenAncestor():
|
|
35
|
+
NSCursor.pointingHandCursor().set()
|
|
36
|
+
|
|
37
|
+
def mouseEntered_(self, event):
|
|
38
|
+
if not self.isHiddenOrHasHiddenAncestor():
|
|
39
|
+
NSCursor.pointingHandCursor().set()
|
|
40
|
+
|
|
41
|
+
def mouseExited_(self, event):
|
|
42
|
+
NSCursor.arrowCursor().set()
|