@vibelord/lanes 1.9.0 → 1.9.3
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.
- package/package.json +1 -1
- package/payload/lanes/VERSION +1 -1
- package/payload/lanes/bin/lanes +7 -0
- package/payload/lanes/bin-rs/BINARIES.json +1 -1
- package/payload/lanes/client/lanes-launch +2 -0
- package/payload/lanes/container/lane +13 -1
- package/payload/lanes/container/lane_core.py +22 -4
- package/payload/lanes/docs/PLAN-1.9.1-SIDEBAR-CODEX.md +128 -0
- package/payload/lanes/docs/RUNBOOK.md +19 -0
- package/payload/lanes/docs/USERGUIDE.md +1 -0
- package/payload/lanes/holders/tmux.sh +3 -3
- package/payload/lanes/libexec/docsd.py +23 -0
- package/payload/lanes/libexec/lanes_lib.py +5 -0
- package/payload/lanes/libexec/registrations.py +5 -0
- package/payload/lanes/libexec/session_actions.py +5 -0
- package/payload/lanes/libexec/sidebar.py +99 -7
- package/payload/lanes/libexec/site_hooks.py +65 -0
- package/payload/lanes/libexec/statusd.py +5 -0
- package/payload/lanes/libexec/workspace_keys.py +54 -0
- package/payload/lanes/web/mobile.js +22 -18
- package/payload/lanes/web/workspace-keys.js +65 -0
- package/payload/manifest.json +3 -3
package/package.json
CHANGED
package/payload/lanes/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.9.
|
|
1
|
+
1.9.2
|
package/payload/lanes/bin/lanes
CHANGED
|
@@ -1094,6 +1094,8 @@ def viewports_arg(args, default=1):
|
|
|
1094
1094
|
LOOK_KEYS = {'--theme': ('theme', ('dark', 'light', 'auto')), '--color': ('color', ('truecolor', '256', '16', 'none')),
|
|
1095
1095
|
'--glyphs': ('glyphs', ('unicode', 'ascii', 'emoji')), '--notify': ('notify', ('1', '0')),
|
|
1096
1096
|
'--dim': ('dim', ('90', '2')),
|
|
1097
|
+
'--sidebar-order': ('sidebar_order', ('attention', 'coordinator', 'pinned')),
|
|
1098
|
+
'--workspace-keys': ('workspace_keys', ('on', 'off')),
|
|
1097
1099
|
# The editor quick edit (`lanes edit`, W9 E2) hands lane-edit as LANES_EDITOR; `auto` takes the choice back.
|
|
1098
1100
|
# Per device, like notify/dim: never a profile key (users.LOOK), never read by a sidebar.
|
|
1099
1101
|
'--editor': ('editor', ('micro', 'hx', 'nvim', 'vim', 'auto'))}
|
|
@@ -6973,6 +6975,11 @@ COMMANDS = {'rebuilt': cmd_rebuilt, 'hello': cmd_hello, 'client-config': cmd_cli
|
|
|
6973
6975
|
'version': cmd_version, 'update': cmd_update, 'docs': cmd_docs,
|
|
6974
6976
|
'address': cmd_address, 'names': cmd_names, 'migrate': cmd_migrate, 'message': cmd_message}
|
|
6975
6977
|
|
|
6978
|
+
|
|
6979
|
+
# lanes site-hook loader (FLE-388)
|
|
6980
|
+
import site_hooks
|
|
6981
|
+
site_hooks.apply('cli', COMMANDS, globals())
|
|
6982
|
+
|
|
6976
6983
|
if __name__ == '__main__':
|
|
6977
6984
|
if len(sys.argv) < 2 or sys.argv[1] not in COMMANDS:
|
|
6978
6985
|
sys.exit(__doc__)
|
|
@@ -349,6 +349,8 @@ if [ "$mode" = attach ] && [ $# -gt 1 ]; then
|
|
|
349
349
|
--glyphs) case "${2:-}" in unicode|ascii|emoji) extra="$extra --glyphs $2"; shift ;; *) echo '--glyphs takes unicode, ascii or emoji' >&2; exit 64 ;; esac ;;
|
|
350
350
|
--color) case "${2:-}" in truecolor|256|16|none) extra="$extra --color $2"; shift ;; *) echo '--color takes truecolor, 256, 16 or none' >&2; exit 64 ;; esac ;;
|
|
351
351
|
--notify) case "${2:-}" in 1|0) extra="$extra --notify $2"; shift ;; *) echo '--notify takes 1 or 0' >&2; exit 64 ;; esac ;;
|
|
352
|
+
--sidebar-order) case "${2:-}" in attention|coordinator|pinned) extra="$extra --sidebar-order $2"; shift ;; *) echo '--sidebar-order takes attention, coordinator or pinned' >&2; exit 64 ;; esac ;;
|
|
353
|
+
--workspace-keys) case "${2:-}" in on|off) extra="$extra --workspace-keys $2"; shift ;; *) echo '--workspace-keys takes on or off' >&2; exit 64 ;; esac ;;
|
|
352
354
|
--dim) case "${2:-}" in 90|2) extra="$extra --dim $2"; shift ;; *) echo '--dim takes 90 or 2' >&2; exit 64 ;; esac ;;
|
|
353
355
|
--device-only) extra="$extra --device-only" ;;
|
|
354
356
|
--mosh) asked=mosh ;; # this client's own: never spliced into the remote command line
|
|
@@ -914,7 +914,19 @@ def cmd_outbox(args):
|
|
|
914
914
|
print(f"{row['id']} {row['at'] or '-'} @{row['to'] or '-'} {row['delivered_by'] or 'on its way'} {said}")
|
|
915
915
|
|
|
916
916
|
|
|
917
|
-
|
|
917
|
+
def cmd_codex_shadow(args):
|
|
918
|
+
if args and (len(args) != 2 or args[0] != '--probe' or not Path(args[1]).is_absolute()):
|
|
919
|
+
sys.exit('usage: lane codex-status-shadow [--probe /path/to/lanes-codex-shadow]')
|
|
920
|
+
probe = Path(args[1]) if args else ROOT / 'bin' / 'lanes-codex-shadow'
|
|
921
|
+
try:
|
|
922
|
+
facts = C.codex_shadow_facts(ROOT, PROC, time.time())
|
|
923
|
+
completed = subprocess.run([str(probe)], input=json.dumps(facts), text=True, timeout=5)
|
|
924
|
+
except (C.LaneError, OSError, subprocess.TimeoutExpired) as error:
|
|
925
|
+
sys.exit(f'lane: shadow comparison unavailable: {error}')
|
|
926
|
+
sys.exit(completed.returncode)
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
COMMANDS = {'codex-status-shadow': cmd_codex_shadow, 'new': cmd_new, 'open': cmd_open, 'attach': cmd_attach, 'send': cmd_send, 'capture': cmd_capture, 'ls': cmd_ls,
|
|
918
930
|
'status': cmd_status, 'kill': cmd_kill, 'gc': cmd_gc, 'mcp': cmd_mcp, 'publish': cmd_publish,
|
|
919
931
|
'address': cmd_address, 'message': cmd_message, 'inbox': cmd_inbox, 'outbox': cmd_outbox}
|
|
920
932
|
|
|
@@ -1667,10 +1667,16 @@ def _codex_handles(root, home, proc):
|
|
|
1667
1667
|
threads = codex_threads(home)
|
|
1668
1668
|
if not threads:
|
|
1669
1669
|
return {lane: {'thread_id': None, 'why': threads.why or 'no_match'} for lane in wanted}
|
|
1670
|
-
lanes = registry_export(root)['lanes']
|
|
1671
|
-
ghosts = {row['id']: row for row in status['unregistered']}
|
|
1672
1670
|
taken = {row['agent']['session_id'] for row in status['lanes'].values() if isinstance(row.get('agent'), dict)
|
|
1673
1671
|
and row['agent'].get('harness') == 'codex' and isinstance(row['agent'].get('session_id'), str)}
|
|
1672
|
+
facts = _codex_lane_facts(root, status, wanted, proc)
|
|
1673
|
+
assigned = codex_assign(facts, threads, taken)
|
|
1674
|
+
return {lane: {'thread_id': found, 'why': why} for lane, (found, why) in assigned.items()}
|
|
1675
|
+
|
|
1676
|
+
|
|
1677
|
+
def _codex_lane_facts(root, status, wanted, proc):
|
|
1678
|
+
lanes = registry_export(root)['lanes']
|
|
1679
|
+
ghosts = {row['id']: row for row in status['unregistered']}
|
|
1674
1680
|
panes, facts = {}, {}
|
|
1675
1681
|
for lane, agent in wanted.items():
|
|
1676
1682
|
pid = codex_pid(proc, agent.get('pid')) if isinstance(agent.get('pid'), int) else None
|
|
@@ -1685,8 +1691,20 @@ def _codex_handles(root, home, proc):
|
|
|
1685
1691
|
if found), None)
|
|
1686
1692
|
facts[lane] = {'cwd': _cwd(proc, pid) if pid else None, 'name': agent.get('name'),
|
|
1687
1693
|
'source': agent.get('source')}
|
|
1688
|
-
|
|
1689
|
-
|
|
1694
|
+
return facts
|
|
1695
|
+
|
|
1696
|
+
|
|
1697
|
+
def codex_shadow_facts(root, proc, now):
|
|
1698
|
+
status = container_status(root, now)
|
|
1699
|
+
if not status['fresh'] or not 0 <= now - status['at'] <= STATUS_FRESH:
|
|
1700
|
+
raise LaneError('fresh container status unavailable')
|
|
1701
|
+
wanted = {lane: row['agent'] for lane, row in status['lanes'].items()
|
|
1702
|
+
if isinstance(row.get('agent'), dict) and row['agent'].get('harness') == 'codex'}
|
|
1703
|
+
facts = _codex_lane_facts(root, status, wanted, proc)
|
|
1704
|
+
for lane, fact in facts.items():
|
|
1705
|
+
agent = wanted[lane]
|
|
1706
|
+
fact.update(status=agent.get('status'), thread=agent.get('session_id'), at=status['at'])
|
|
1707
|
+
return facts
|
|
1690
1708
|
|
|
1691
1709
|
|
|
1692
1710
|
# ------------------------------------------------------------------------------------------------ atomic files
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Lanes 1.9.1 sidebar and Codex reliability plan
|
|
2
|
+
|
|
3
|
+
Status: planned for the 1.9.1 candidate. The default sidebar order remains unchanged until the experiment has a
|
|
4
|
+
measured result.
|
|
5
|
+
|
|
6
|
+
## Sidebar experiment
|
|
7
|
+
|
|
8
|
+
The candidate should offer an explicit per-device trial mode for the desktop terminal, laptop browser and phone. The
|
|
9
|
+
mode is opt-in and reversible, and it is read from the same profile that already carries workspace order and lane
|
|
10
|
+
pins. The server projection remains the authority for row identity, status and role, so every surface makes the same
|
|
11
|
+
choice.
|
|
12
|
+
|
|
13
|
+
The first trial order is coordinator first within the current workspace, followed by lanes the person pinned, followed
|
|
14
|
+
by lanes that need the person's attention, then working, done-not-seen and the remaining lanes. A coordinator keeps
|
|
15
|
+
its top position when its status changes. A pinned lane keeps its relative order and does not displace a coordinator.
|
|
16
|
+
The existing attention queue remains the default mode and remains available as the immediate fallback.
|
|
17
|
+
|
|
18
|
+
The trial must preserve the current queue's guarantees.
|
|
19
|
+
|
|
20
|
+
- A `needs_approval`, error or explicit input request remains visible and retains its urgency mark.
|
|
21
|
+
- Stable entry times continue to debounce section changes. A status flap must not reorder a lane repeatedly.
|
|
22
|
+
- Cursor identity, scroll position, last workspace and last lane survive a refresh, reconnect and a device-mode change.
|
|
23
|
+
- Hidden and unregistered lanes stay governed by their existing rules. A coordinator cannot be hidden by the trial's
|
|
24
|
+
sort key.
|
|
25
|
+
- The desktop and phone render the same ordered identities from one projection. The browser directory must not invent a
|
|
26
|
+
second order.
|
|
27
|
+
|
|
28
|
+
The trial should expose a small control in the sidebar settings with three choices.
|
|
29
|
+
|
|
30
|
+
1. **Attention first** uses the current section queue.
|
|
31
|
+
2. **Coordinator first** tries the requested coordinator, pinned and attention order.
|
|
32
|
+
3. **Pinned first** keeps coordinator marking but lets the person's pins lead, followed by attention.
|
|
33
|
+
|
|
34
|
+
The selected mode is device-scoped at first. A later release can promote a mode into the owner profile after the
|
|
35
|
+
results show that people want the same order on every device.
|
|
36
|
+
|
|
37
|
+
## Codex status reliability
|
|
38
|
+
|
|
39
|
+
The current observer is layered. A trusted lane-signal sidecar wins, then the harness observer and Codex title parser,
|
|
40
|
+
then the window bell. Codex `Stop` currently records `done`, `PermissionRequest` records `needs_approval`, and a plain
|
|
41
|
+
task title is `idle`. This is the measured baseline for the experiment.
|
|
42
|
+
|
|
43
|
+
The candidate should add a Codex status probe behind the Rust shadow path. It may use the app-server thread status only
|
|
44
|
+
when the thread is live, belongs to the lane's working directory and has a fresh update time. It must publish the
|
|
45
|
+
source and freshness with the observation, and it must leave the existing title and bell fallback in place when the
|
|
46
|
+
probe is unavailable. A stale or ambiguous thread must never create a false `needs_input` or `needs_approval` row.
|
|
47
|
+
|
|
48
|
+
The probe should distinguish these cases before any status mapping changes.
|
|
49
|
+
|
|
50
|
+
| Observed case | Sidebar state | Evidence required |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| Codex is executing a turn or tool | Working | Live thread state or a fresh working sidecar event |
|
|
53
|
+
| Codex asks for permission | Needs approval | `PermissionRequest` sidecar event, or an equivalent live protocol event |
|
|
54
|
+
| Codex asks the person for a reply | Needs you | A live, typed question event with a stable request id |
|
|
55
|
+
| Codex completed a turn | Done, not seen | `Stop` sidecar event or a fresh completion event |
|
|
56
|
+
| No live Codex evidence | Idle or shell | Pane/process evidence, with stale titles treated as shell when the harness ended |
|
|
57
|
+
|
|
58
|
+
The phrase “waiting on me” must only be emitted when Codex provides an explicit question/input event. A completed turn
|
|
59
|
+
must stay Done until that event is measured. This prevents a title or a quiet pane from manufacturing an attention
|
|
60
|
+
request.
|
|
61
|
+
|
|
62
|
+
## Workspace shortcuts and a future Hypervibe key map
|
|
63
|
+
|
|
64
|
+
The first shortcut experiment is `Super+1` through `Super+9`. Each number selects the corresponding **visible
|
|
65
|
+
workspace in the person's profile order**, rather than the raw Zellij tab position. A workspace with both a picker tab
|
|
66
|
+
and a lane tab counts once. The switch focuses that workspace's remembered tab when one exists, then its picker or lane
|
|
67
|
+
tab according to the same `{"tab", "ws"}` memory used by the current phone shell. `Super+0` is deliberately left
|
|
68
|
+
unassigned until a stable home or coordinator action has an owner.
|
|
69
|
+
|
|
70
|
+
The terminal implementation must resolve the profile order and workspace identity before it calls Zellij. It should use
|
|
71
|
+
the same bounded `go-to-tab-name` route as `lanes here` and `lanes attach`, or a small equivalent Lanes command, rather
|
|
72
|
+
than binding `GoToTab N` directly. This skips Host, Throttle and unmanaged tabs, survives a reordered profile and keeps
|
|
73
|
+
the shortcut aligned with the browser and phone. A number beyond the visible workspace count is a no-op with a short
|
|
74
|
+
status hint. The existing `Ctrl-Alt-Left/Right` tab traversal remains available as the adjacent-workspace fallback.
|
|
75
|
+
|
|
76
|
+
The checked-in Zellij is 0.45.1. `zellij --config /tmp/lanes-zellij-super-test.kdl setup --check` returned exit 0
|
|
77
|
+
for a temporary `bind "Super 1" { GoToTab 1; }` fixture, so the grammar is available. This does not prove that a
|
|
78
|
+
window manager will deliver every Super chord. The terminal trial must verify delivery on each supported host and keep
|
|
79
|
+
the existing Ctrl-Alt route when a host reserves the modifier.
|
|
80
|
+
|
|
81
|
+
Browser desktop and tablet use the platform equivalent `Meta+1` through `Meta+9` (`Command` on macOS and `Super` on
|
|
82
|
+
Linux). The handler must run only when focus is outside a text input, contenteditable surface, search field, filter,
|
|
83
|
+
login control or composition, and it must never write the digit into a lane. A phone has no touch Super key. Its
|
|
84
|
+
workspace sheet remains the capability-floor path, while a hardware keyboard may use the same Meta chords under the
|
|
85
|
+
same focus guard. The browser and phone handlers must focus the remembered tab through the client control API and must
|
|
86
|
+
not synthesize terminal bytes.
|
|
87
|
+
|
|
88
|
+
The key namespace should stay small and discoverable. These are candidates for later experiments, ordered by the
|
|
89
|
+
least destructive action first.
|
|
90
|
+
|
|
91
|
+
| Candidate | Meaning | Guard and fallback |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `Super+Tab` / `Super+Shift+Tab` | Cycle visible workspaces in profile order | No-op at an unavailable view; `Ctrl-Alt-Left/Right` and the workspace sheet remain available |
|
|
94
|
+
| `Super+G` | Jump to the next lane marked Needs you | Requires an explicit input question or approval signal; show `nothing needs you` when empty |
|
|
95
|
+
| `Super+L` | Focus the current workspace's sidebar | Alias the existing `Ctrl-Alt-l` only after terminal, browser and phone focus tests |
|
|
96
|
+
| `Super+K` | Open a command palette for navigation-only actions | Palette actions must be reversible and must not send text or answer a prompt |
|
|
97
|
+
| `Super+P` | Open the pinned-lanes view | Keep the normal ordered list one escape away; respect hidden-lane policy |
|
|
98
|
+
| `Super+Shift+S` | Search workspaces and lanes | Search field owns the keyboard until Escape; no lane receives search text |
|
|
99
|
+
| `Super+Shift+U` | Arm the upload strip | Preserve the existing `Ctrl-Alt-u` path and show the armed state before a drop |
|
|
100
|
+
| `Super+Shift+D` | Open Docs for the current workspace | Use the existing Docs route and leave the terminal focus unchanged on close |
|
|
101
|
+
| `Super+R` | Reconnect the current view | Never reload while a send is pending; retain the last workspace and lane |
|
|
102
|
+
|
|
103
|
+
No future shortcut should move, close, hide, rename or message a lane without a separate confirmation contract. Those
|
|
104
|
+
verbs change shared state and need an explicit action surface rather than a mnemonic key. The same key must mean the
|
|
105
|
+
same navigation verb on terminal, browser and hardware-keyboard phone views. Every new binding must appear in the
|
|
106
|
+
sidebar key sheet and the runbook, and must have a conflict test proving that ordinary agent input, IME composition,
|
|
107
|
+
browser forms, picker filters and locked views keep their current behavior.
|
|
108
|
+
|
|
109
|
+
## Acceptance and rollout
|
|
110
|
+
|
|
111
|
+
The candidate needs a fixture matrix for both surfaces and both modes.
|
|
112
|
+
|
|
113
|
+
- Coordinator working, waiting for input, done and shell states with pinned and unpinned neighbours.
|
|
114
|
+
- Codex working, permission request, completion, explicit question, stale title and missing app-server cases.
|
|
115
|
+
- Desktop and phone order parity, including a reconnect and a change of the selected workspace.
|
|
116
|
+
- Rust shadow and legacy output comparisons for the same observation stream.
|
|
117
|
+
- `Super+1…9` / `Meta+1…9` select the same profile-ordered visible workspace, skip hidden boards and unmanaged tabs,
|
|
118
|
+
handle paired picker tabs, restore remembered per-workspace tabs and no-op with fewer-than-nine workspaces.
|
|
119
|
+
- A shortcut pressed in a lane prompt, an editor, a sidebar filter, a browser form or an IME composition reaches that
|
|
120
|
+
control and does not switch workspace. A locked terminal still accepts the navigation chords that are explicitly
|
|
121
|
+
declared shared.
|
|
122
|
+
- The temporary Zellij grammar check above is repeated with the candidate config, and browser and hardware-keyboard
|
|
123
|
+
tests record whether the host delivered the Meta/Super modifier.
|
|
124
|
+
|
|
125
|
+
The trial is ready for a small owner-selected cohort when every case has a source label, no false attention rows are
|
|
126
|
+
found in the fixture matrix, and switching back to Attention first restores the existing order without losing the
|
|
127
|
+
cursor or saved workspace. The owner decides whether the trial becomes the default for 1.9.1 or remains a candidate
|
|
128
|
+
for a follow-up release.
|
|
@@ -4842,3 +4842,22 @@ identical text; each new transition binds the observed workspace revision, while
|
|
|
4842
4842
|
key. Draft rows never enqueue a message. Notification routing sends only from a newly committed claim: a replayed or
|
|
4843
4843
|
uncertain claim stays held as `sending`/unknown and is never permission to send again. This also applies to overlapping
|
|
4844
4844
|
quiet-hours summaries. These modules remain unwired; the installed Python notification service is unchanged.
|
|
4845
|
+
|
|
4846
|
+
## Lanes 1.9.1 device trials
|
|
4847
|
+
|
|
4848
|
+
Use `lanes attach DEVICE --sidebar-order coordinator --workspace-keys on` or pass the same flags to `lanes-launch`.
|
|
4849
|
+
The sidebar comma key and the phone picker's Order row cycle Attention first, Coordinator first and Pinned first.
|
|
4850
|
+
The urgency tally and Tab queue cover promoted lanes too. The settings apply to this device at its next redraw.
|
|
4851
|
+
|
|
4852
|
+
From the terminal sidebar use Super+1 through Super+9. Open the same web view with `?keys` appended to its URL
|
|
4853
|
+
for Meta+1 through Meta+9 outside terminal input and forms. The web trial requires the device owner's Docs login.
|
|
4854
|
+
Each slot names one visible workspace in profile order. The phone keeps its touch picker. The existing
|
|
4855
|
+
Ctrl-Alt-Left and Ctrl-Alt-Right bindings work on hosts that reserve Super. Super+0 is free.
|
|
4856
|
+
Use `--workspace-keys off` and select Attention first to return to the defaults.
|
|
4857
|
+
|
|
4858
|
+
For one side-by-side Codex status sample in a guest, run `lane codex-status-shadow --probe /absolute/path/to/lanes-codex-shadow`
|
|
4859
|
+
with a matching managed build of the Rust probe. Without the flag, the command looks beside the guest's lane binary.
|
|
4860
|
+
The output compares the legacy observation with a fresh, read-only app-server sample and includes its evidence source.
|
|
4861
|
+
It leaves the active observer in control. A blocking typed question needs an outstanding request id and a current
|
|
4862
|
+
waiting flag. A trusted hook takes precedence, including Stop and permission requests. A missing, ambiguous or old
|
|
4863
|
+
thread falls back to the legacy observation. The sample expires after 30 seconds.
|
|
@@ -956,6 +956,7 @@ to this table and ends with `Ctrl-Alt-l` — not a sidebar key but the chord tha
|
|
|
956
956
|
| `g` / `G` | First / last row |
|
|
957
957
|
| `+` | New persistent shell in this workspace |
|
|
958
958
|
| `a` | Add the cursor session to a workspace |
|
|
959
|
+
| `,` | Cycle this device's sidebar order through Attention first, Coordinator first and Pinned first. Tap Order on the phone picker. |
|
|
959
960
|
| `x` | Close the cursor session: `y` arms, `Enter` closes, any other key cancels (on a registered lane: ` registered: u to unregister first`) |
|
|
960
961
|
| `u` | Unregister the cursor session added with `a`: it moves back to **Unregistered**, still running, and the cursor goes with it; on a lane a repository's `terminals.json` declares, take its terminal out of that file |
|
|
961
962
|
| `z` | Undo that unregister (within 10 s) |
|
|
@@ -58,7 +58,7 @@ fi
|
|
|
58
58
|
view_term=xterm-256color
|
|
59
59
|
if infocmp xterm-lanesview >/dev/null 2>&1; then view_term=xterm-lanesview; fi
|
|
60
60
|
lanes_tmux() {
|
|
61
|
-
env -i PATH
|
|
61
|
+
env -i PATH="$HOME/.local/share/lanes/compat/bin:/usr/bin:/bin" HOME="$HOME" TERM="$view_term" LANG=C.UTF-8 COLORTERM=truecolor \
|
|
62
62
|
tmux -N -u -2 -T RGB,hyperlinks -S "$path" "$@"
|
|
63
63
|
}
|
|
64
64
|
lanes_tmux has-session -t "$target" 2>/dev/null || fail 66 "lane $socket / $session is not provisioned (no such tmux session)"
|
|
@@ -104,8 +104,8 @@ fi
|
|
|
104
104
|
# exec: the supervisor's child pid must BE the tmux client, so a lane switch (SIGTERM) detaches it cleanly
|
|
105
105
|
# instead of orphaning a client on this pty.
|
|
106
106
|
if [ -n "$flags" ]; then
|
|
107
|
-
exec env -i PATH
|
|
107
|
+
exec env -i PATH="$HOME/.local/share/lanes/compat/bin:/usr/bin:/bin" HOME="$HOME" TERM="$view_term" LANG=C.UTF-8 COLORTERM=truecolor \
|
|
108
108
|
tmux -N -u -2 -T RGB,hyperlinks -S "$path" attach-session -f "$flags" -t "$target"
|
|
109
109
|
fi
|
|
110
|
-
exec env -i PATH
|
|
110
|
+
exec env -i PATH="$HOME/.local/share/lanes/compat/bin:/usr/bin:/bin" HOME="$HOME" TERM="$view_term" LANG=C.UTF-8 COLORTERM=truecolor \
|
|
111
111
|
tmux -N -u -2 -T RGB,hyperlinks -S "$path" attach-session -t "$target"
|
|
@@ -248,6 +248,7 @@ STATIC = {'docs.css': 'text/css; charset=utf-8', 'docs.js': 'text/javascript; ch
|
|
|
248
248
|
'upload.css': 'text/css; charset=utf-8', 'upload.js': 'text/javascript; charset=utf-8'}
|
|
249
249
|
FETCH_SITES = ('same-origin', 'none') # Sec-Fetch-Site values the gate serves (every route, F2) …
|
|
250
250
|
NAVIGATION_METHODS = ('GET', 'HEAD') # … and a top-level navigation by these methods, from any site
|
|
251
|
+
_WORKSPACE_READS = threading.BoundedSemaphore(2)
|
|
251
252
|
_DECRYPTS = threading.BoundedSemaphore(1) # encrypted documents decrypted at once (each held in memory)
|
|
252
253
|
_ID = r'([a-z0-9]{10,20})' # docs_store.ID_RE; check_id runs again before any path is formed
|
|
253
254
|
ROUTES = (('index', re.compile(r'/', re.ASCII)),
|
|
@@ -255,6 +256,7 @@ ROUTES = (('index', re.compile(r'/', re.ASCII)),
|
|
|
255
256
|
('raw', re.compile(rf'/d/{_ID}/raw', re.ASCII)),
|
|
256
257
|
('artifact', re.compile(rf'/d/{_ID}/artifact', re.ASCII)),
|
|
257
258
|
('receipt', re.compile(rf'/receipt/{_ID}\.json', re.ASCII)),
|
|
259
|
+
('workspace-keys', re.compile(r'/workspace-keys/([A-Za-z0-9_][A-Za-z0-9_.-]{0,47})', re.ASCII)),
|
|
258
260
|
('up', re.compile(r'/up', re.ASCII)),
|
|
259
261
|
('static', re.compile(r'/(docs\.css|docs\.js|upload\.css|upload\.js)', re.ASCII)))
|
|
260
262
|
METHODS = {'up': ('POST',)} # every other route: GET
|
|
@@ -1211,6 +1213,22 @@ class Handler(BaseHTTPRequestHandler):
|
|
|
1211
1213
|
if route == 'up':
|
|
1212
1214
|
return self._upload(service, caller)
|
|
1213
1215
|
workspaces = member_workspaces(caller.login)
|
|
1216
|
+
if route == 'workspace-keys':
|
|
1217
|
+
import workspace_keys
|
|
1218
|
+
meta = L.read_json(L.STATE / 'devices' / f'{name}.json')
|
|
1219
|
+
if (not isinstance(meta, dict) or meta.get('workspace_keys') != 'on' or
|
|
1220
|
+
(users.login_for(name, meta) or '').casefold() != caller.login.casefold()):
|
|
1221
|
+
return self._error(404, 'not-found')
|
|
1222
|
+
if not _WORKSPACE_READS.acquire(blocking=False):
|
|
1223
|
+
return self._error(503, 'busy')
|
|
1224
|
+
try:
|
|
1225
|
+
slots = workspace_keys.projection(name, meta, L.load_registry(), users.read(caller.login),
|
|
1226
|
+
allowed=workspaces)
|
|
1227
|
+
except (OSError, ValueError, KeyError, TypeError, L.LanesError):
|
|
1228
|
+
return self._error(503, 'busy')
|
|
1229
|
+
finally:
|
|
1230
|
+
_WORKSPACE_READS.release()
|
|
1231
|
+
return self._json(200, slots)
|
|
1214
1232
|
if route == 'index':
|
|
1215
1233
|
reg = registry()
|
|
1216
1234
|
docs, targets = visible_docs(caller.login, workspaces), upload_targets(workspaces, reg)
|
|
@@ -2021,5 +2039,10 @@ def main(argv=None):
|
|
|
2021
2039
|
return 0
|
|
2022
2040
|
|
|
2023
2041
|
|
|
2042
|
+
|
|
2043
|
+
# lanes site-hook loader (FLE-388)
|
|
2044
|
+
import site_hooks
|
|
2045
|
+
site_hooks.apply('docs', globals())
|
|
2046
|
+
|
|
2024
2047
|
if __name__ == '__main__':
|
|
2025
2048
|
sys.exit(main())
|
|
@@ -2964,3 +2964,8 @@ def find_lane(registry, lane_id):
|
|
|
2964
2964
|
if lane['id'] == lane_id:
|
|
2965
2965
|
return workspace, lane
|
|
2966
2966
|
raise LanesError(f'Unknown lane: {lane_id}')
|
|
2967
|
+
|
|
2968
|
+
|
|
2969
|
+
# lanes site-hook loader (FLE-388)
|
|
2970
|
+
import site_hooks
|
|
2971
|
+
site_hooks.apply('library', globals())
|
|
@@ -344,3 +344,8 @@ def reregister(record):
|
|
|
344
344
|
raise L.LanesError('Session could not be checked; nothing was registered')
|
|
345
345
|
data['sessions'].append(saved)
|
|
346
346
|
return _save(registry, data, board, saved['id'])
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
# lanes site-hook loader (FLE-388)
|
|
350
|
+
import site_hooks
|
|
351
|
+
site_hooks.apply('actions', globals(), 'registrations')
|
|
@@ -633,3 +633,8 @@ def _close_session(workspace, entry, unattended=False, *, idle_before=None):
|
|
|
633
633
|
for directory in ('resolve.dynamic', 'user-sessions'):
|
|
634
634
|
path = L.STATE / directory / (entry['id'] + ('.json' if directory == 'user-sessions' else ''))
|
|
635
635
|
path.unlink(missing_ok=True)
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
# lanes site-hook loader (FLE-388)
|
|
639
|
+
import site_hooks
|
|
640
|
+
site_hooks.apply('actions', globals(), 'session_actions')
|
|
@@ -675,6 +675,9 @@ def resolve_modes(env, meta):
|
|
|
675
675
|
return color, theme, glyphs
|
|
676
676
|
|
|
677
677
|
|
|
678
|
+
SIDEBAR_ORDERS = ('attention', 'coordinator', 'pinned')
|
|
679
|
+
|
|
680
|
+
|
|
678
681
|
def layered_look(profile_look, meta):
|
|
679
682
|
"""devices/<device>.json as resolve_modes and resolve_dim_notify read it on a device with an owner (cockpit v3 R3,
|
|
680
683
|
LNS-76): the person's profile look over the device file's, except where the device keeps a key for itself. Per key
|
|
@@ -839,7 +842,7 @@ KEY_SHEET = (('↑ ↓ j k', 'Up Dn j k', 'move'), ('⏎ → Space', 'Enter Spc'
|
|
|
839
842
|
('J K', 'J K', 'open next / prev lane'), ('Tab S-Tab', 'Tab S-Tab', 'next / prev needing you'),
|
|
840
843
|
('2 3', '2 3', 'show in viewport 2 / 3'), ('/ @', '/ @', 'find / addresses'),
|
|
841
844
|
('Esc', 'Esc', 'cancel, back to lane'), ('g G', 'g G', 'first / last'),
|
|
842
|
-
('+ U d', '+ U d', 'shell / upload / docs'), ('a', 'a', 'add
|
|
845
|
+
('+ U d', '+ U d', 'shell / upload / docs'), ('a ,', 'a ,', 'add / sidebar order'),
|
|
843
846
|
('x', 'x', 'close (y, then Enter)'), ('u z', 'u z', 'unregister / undo 10 s'),
|
|
844
847
|
('R m', 'R m', 'rename ⏎ / message', 'rename Enter / message'), ('P', 'P', 'register a session'),
|
|
845
848
|
('p o', 'p o', 'pin / show hidden lanes'), ('h H', 'h H', 'hide lane / tab ⏎', 'hide lane / tab Enter'),
|
|
@@ -1080,6 +1083,9 @@ class Sidebar:
|
|
|
1080
1083
|
# taken yet (its lock was busy), written again by poll_profile at `profile_retry_at` (time.monotonic()).
|
|
1081
1084
|
login, profile_path = None, None
|
|
1082
1085
|
profile_look, device_meta = {}, {}
|
|
1086
|
+
sidebar_order = 'attention'
|
|
1087
|
+
extended_keys = False
|
|
1088
|
+
remembered_workspace_tab = None
|
|
1083
1089
|
profile_workspaces = {} # the profile's `workspaces{order, hidden}` (R4, LNS-77): the phone's owner board
|
|
1084
1090
|
# The profile's `lanes{pins, hidden}` (cockpit v3 R5, LNS-78; read-only defaults, take_arrangement assigns fresh
|
|
1085
1091
|
# sets) and `o`'s toggle: hidden lanes shown again, faint.
|
|
@@ -1603,6 +1609,8 @@ class Sidebar:
|
|
|
1603
1609
|
On a device with an owner `meta` is layered_look's (cockpit v3 R3): the owner's profile beneath the device
|
|
1604
1610
|
file's --device-only keys, and this runs when either changes — a look recorded on another of the person's
|
|
1605
1611
|
devices included."""
|
|
1612
|
+
order = (meta or {}).get('sidebar_order')
|
|
1613
|
+
self.sidebar_order = order if order in SIDEBAR_ORDERS else 'attention'
|
|
1606
1614
|
color, theme, glyphs = resolve_modes(os.environ, meta)
|
|
1607
1615
|
dim, notify = resolve_dim_notify(os.environ, meta)
|
|
1608
1616
|
handles = resolve_handles(os.environ, meta) # W15 L2: where the rows draw the lane's handle
|
|
@@ -1711,6 +1719,13 @@ class Sidebar:
|
|
|
1711
1719
|
observed = visibility.snapshot(json.loads(out), self.mobile_titles, self.mobile)
|
|
1712
1720
|
except (ValueError, KeyError, TypeError):
|
|
1713
1721
|
return
|
|
1722
|
+
if self.mobile and self.device_meta.get('workspace_keys') == 'on':
|
|
1723
|
+
active = [(board, role) for kind, role in (('sidebars', 'picker'), ('viewports', 'view'))
|
|
1724
|
+
for board in observed[kind] if board in self.board_titles]
|
|
1725
|
+
if len(active) == 1 and active[0] != self.remembered_workspace_tab:
|
|
1726
|
+
board, role = active[0]
|
|
1727
|
+
L.atomic_write_if_changed(Path(self.view_dir) / f'{board}.last-tab', role)
|
|
1728
|
+
self.remembered_workspace_tab = active[0]
|
|
1714
1729
|
L.atomic_write(Path(self.view_dir) / 'visibility.json', json.dumps(observed))
|
|
1715
1730
|
for workspace in observed['viewports']:
|
|
1716
1731
|
shown = Path(self.view_dir) / f'{workspace}.main.shown'
|
|
@@ -2665,7 +2680,48 @@ class Sidebar:
|
|
|
2665
2680
|
text = text.removesuffix(reset)
|
|
2666
2681
|
return f'{band}{text.replace(reset, reset + band)}{reset}'
|
|
2667
2682
|
|
|
2668
|
-
def
|
|
2683
|
+
def numbered_workspace(self, number):
|
|
2684
|
+
import workspace_keys
|
|
2685
|
+
try:
|
|
2686
|
+
slots = workspace_keys.projection(self.device, self.device_meta, {'workspaces': self.workspaces},
|
|
2687
|
+
{'workspaces': self.profile_workspaces})
|
|
2688
|
+
tabs = slots[number - 1]['tabs'] if number <= len(slots) else {}
|
|
2689
|
+
remembered = None
|
|
2690
|
+
if self.mobile and tabs:
|
|
2691
|
+
try:
|
|
2692
|
+
remembered = (Path(self.view_dir) / (slots[number - 1]['board'] + '.last-tab')).read_text()
|
|
2693
|
+
except OSError:
|
|
2694
|
+
pass
|
|
2695
|
+
selected = tabs.get(remembered) or tabs.get('picker') or tabs.get('view')
|
|
2696
|
+
if not selected:
|
|
2697
|
+
self.message = f'Workspace {number} unavailable'
|
|
2698
|
+
return
|
|
2699
|
+
cmd = [os.environ.get('LANES_ZELLIJ') or 'zellij', '-s', self.device, 'action', 'go-to-tab-by-id']
|
|
2700
|
+
code, _, _ = L.run_bounded(cmd + [str(selected['id'])], 2)
|
|
2701
|
+
if code != 0:
|
|
2702
|
+
self.message = 'Workspace unavailable'
|
|
2703
|
+
except (L.LanesError, OSError, ValueError, TypeError, KeyError):
|
|
2704
|
+
self.message = 'Workspace list unavailable'
|
|
2705
|
+
self.dirty = True
|
|
2706
|
+
|
|
2707
|
+
def cycle_order(self):
|
|
2708
|
+
try:
|
|
2709
|
+
with L.sessions_lock(PROFILE_LOCK_S, 'sidebar order'):
|
|
2710
|
+
meta = read_json(self.look_path)
|
|
2711
|
+
if not isinstance(meta, dict):
|
|
2712
|
+
raise L.LanesError('unknown device')
|
|
2713
|
+
current = meta.get('sidebar_order')
|
|
2714
|
+
index = SIDEBAR_ORDERS.index(current) if current in SIDEBAR_ORDERS else 0
|
|
2715
|
+
order = SIDEBAR_ORDERS[(index + 1) % len(SIDEBAR_ORDERS)]
|
|
2716
|
+
L.atomic_write(Path(self.look_path), json.dumps(dict(meta, sidebar_order=order)) + '\n')
|
|
2717
|
+
except (ValueError, OSError, L.LanesError) as error:
|
|
2718
|
+
self.message = str(error)
|
|
2719
|
+
else:
|
|
2720
|
+
self.sidebar_order = order
|
|
2721
|
+
self.message = f'{order.capitalize()} first'
|
|
2722
|
+
self.dirty = True
|
|
2723
|
+
|
|
2724
|
+
def sectioned(self, lanes, order=None):
|
|
2669
2725
|
"""Registry lanes in attention order (spec §4.4, cockpit v3 S2): Needs you (by urgency, then in the order the
|
|
2670
2726
|
lanes ENTERED the section), Working (entry order), Done, not seen (newest entry first), then the rest in
|
|
2671
2727
|
registry order under a workspace header. Shared by the desktop and the phone (render_mobile draws this list).
|
|
@@ -2682,8 +2738,19 @@ class Sidebar:
|
|
|
2682
2738
|
A lane the owner pinned (cockpit v3 R5) leads its section — the pinned ones in registry order, then the others
|
|
2683
2739
|
in the order above — in the remainder and the single list alike."""
|
|
2684
2740
|
buckets, rest, agents, pins = {key: [] for key, *_ in ATTENTION}, [], False, self.lane_pins
|
|
2741
|
+
mode = order or self.sidebar_order
|
|
2742
|
+
promoted = {'Coordinator': [], 'Pinned': []}
|
|
2743
|
+
lead = 'coordinator'
|
|
2744
|
+
if mode == 'coordinator' and not any(lane_role(self.status.get(e['id'])) == lead for e in lanes):
|
|
2745
|
+
lead = 'fleet_admin'
|
|
2685
2746
|
for index, (entry, status, entered, key) in enumerate(self.agent_rows(lanes)):
|
|
2686
2747
|
agents = agents or status not in (None, 'shell')
|
|
2748
|
+
if mode == 'coordinator' and lane_role(self.status.get(entry['id'])) == lead:
|
|
2749
|
+
promoted['Coordinator'].append(entry)
|
|
2750
|
+
continue
|
|
2751
|
+
if mode != 'attention' and entry['id'] in pins:
|
|
2752
|
+
promoted['Pinned'].append(entry)
|
|
2753
|
+
continue
|
|
2687
2754
|
if key is None:
|
|
2688
2755
|
rest.append(entry)
|
|
2689
2756
|
continue
|
|
@@ -2699,9 +2766,13 @@ class Sidebar:
|
|
|
2699
2766
|
buckets[key].append((order, status, entry))
|
|
2700
2767
|
if pins:
|
|
2701
2768
|
rest = [e for e in rest if e.get('id') in pins] + [e for e in rest if e.get('id') not in pins]
|
|
2702
|
-
if not agents:
|
|
2703
|
-
return rest
|
|
2704
2769
|
out = []
|
|
2770
|
+
for label, group in promoted.items():
|
|
2771
|
+
if group:
|
|
2772
|
+
out.append({'id': '', 'divider': True, 'section': label.lower(), 'name': f'{label} ({len(group)})'})
|
|
2773
|
+
out.extend(group)
|
|
2774
|
+
if not agents:
|
|
2775
|
+
return out + rest
|
|
2705
2776
|
for key, title, _glyph, _members in ATTENTION:
|
|
2706
2777
|
bucket = sorted(buckets[key], key=itemgetter(0))
|
|
2707
2778
|
if bucket or key in ALWAYS_DRAWN:
|
|
@@ -2757,7 +2828,10 @@ class Sidebar:
|
|
|
2757
2828
|
def needs_you(self):
|
|
2758
2829
|
"""The visible lanes whose agent needs you, in section order (approval, errored, input; oldest first)."""
|
|
2759
2830
|
out = []
|
|
2760
|
-
|
|
2831
|
+
visible = self.visible()
|
|
2832
|
+
if self.sidebar_order != 'attention' and not self.filter and not self.registration:
|
|
2833
|
+
visible = self.sectioned(self.shown_lanes(), 'attention') + list(self.zmx or ()) + list(self.unregistered or ())
|
|
2834
|
+
for entry in visible:
|
|
2761
2835
|
agent = None if entry.get('divider') else (self.status.get(entry.get('id', '')) or {}).get('agent')
|
|
2762
2836
|
if isinstance(agent, dict) and agent.get('status') in NEEDS_YOU:
|
|
2763
2837
|
out.append(entry)
|
|
@@ -4393,6 +4467,10 @@ class Sidebar:
|
|
|
4393
4467
|
except OSError:
|
|
4394
4468
|
cols, rows = 36, 24
|
|
4395
4469
|
self.size = (cols, rows)
|
|
4470
|
+
enable_keys = self.device_meta.get('workspace_keys') == 'on'
|
|
4471
|
+
if enable_keys != self.extended_keys:
|
|
4472
|
+
sys.stdout.write('\033[>1u' if enable_keys else '\033[<u')
|
|
4473
|
+
self.extended_keys = enable_keys
|
|
4396
4474
|
if self.mobile:
|
|
4397
4475
|
self.render_mobile(cols, rows)
|
|
4398
4476
|
return
|
|
@@ -4539,7 +4617,7 @@ class Sidebar:
|
|
|
4539
4617
|
line(' ADD TO WORKSPACE', tone['bold'])
|
|
4540
4618
|
else:
|
|
4541
4619
|
line(counts or f' {len(self.shown_lanes())} lanes', tone['ink-dim'] if self.banner or not counts else tone['bold'])
|
|
4542
|
-
line()
|
|
4620
|
+
line(' Order: ' + self.sidebar_order.capitalize() + ' first' if not self.registration else '', tone['ink-dim'])
|
|
4543
4621
|
now, sep = time.time(), f' {marks["sep"]} ' # every ` · ` is the sep mark: the ASCII frame stays seven-bit
|
|
4544
4622
|
self.clock_sig = self.clock_signature(entries, now) # C7: what time changes in this frame (poll_clock)
|
|
4545
4623
|
for index in range(self.top, self.top + body):
|
|
@@ -4801,6 +4879,8 @@ class Sidebar:
|
|
|
4801
4879
|
"""The keys and mouse reports of one read, or of the part of it before / after a paste (handle())."""
|
|
4802
4880
|
if not data:
|
|
4803
4881
|
return
|
|
4882
|
+
if self.extended_keys:
|
|
4883
|
+
data = data.replace('\033[27u', '\033')
|
|
4804
4884
|
self.key_now, self.key_typed = self.key_clock(), False # BEY-7248: one reading for the keys of this read
|
|
4805
4885
|
entries = self.follow()
|
|
4806
4886
|
i = 0
|
|
@@ -4829,6 +4909,13 @@ class Sidebar:
|
|
|
4829
4909
|
if self.typed_burst(ch): # BEY-7248: a key of a typed sentence is no command
|
|
4830
4910
|
i += 1
|
|
4831
4911
|
continue
|
|
4912
|
+
if ch == '\033' and self.device_meta.get('workspace_keys') == 'on':
|
|
4913
|
+
chord = re.match(r'\x1b\[(49|5[0-7]);9u', data[i:])
|
|
4914
|
+
if chord:
|
|
4915
|
+
if not (self.prompt or self.filtering or self.armed or self.registration or self.typing):
|
|
4916
|
+
self.numbered_workspace(int(chord[1]) - 48)
|
|
4917
|
+
i += len(chord[0])
|
|
4918
|
+
continue
|
|
4832
4919
|
if self.prompt and ch == '\033':
|
|
4833
4920
|
# ONE escape sequence under the prompt, a name field or a confirmation (cockpit v3 S6 fix cycle 1,
|
|
4834
4921
|
# DEF-1824): consumed while the prompt stays, or handled as usual below — with the prompt cancelled
|
|
@@ -4875,6 +4962,9 @@ class Sidebar:
|
|
|
4875
4962
|
self.cursor -= 3
|
|
4876
4963
|
elif button == 65:
|
|
4877
4964
|
self.cursor += 3
|
|
4965
|
+
elif (button == 0 and pressed and self.mobile and y == 2 and not
|
|
4966
|
+
(self.prompt or self.registration or self.filtering or self.armed)):
|
|
4967
|
+
self.cycle_order()
|
|
4878
4968
|
elif button == 0 and pressed and self.box and y >= self.box_top:
|
|
4879
4969
|
self.begin_action()
|
|
4880
4970
|
self.armed = True # the click also gave this pane the focus: the next drop lands here
|
|
@@ -5003,6 +5093,8 @@ class Sidebar:
|
|
|
5003
5093
|
self.armed = True
|
|
5004
5094
|
elif ch == '+' and not self.registration and not self.attach_only:
|
|
5005
5095
|
self.new_shell()
|
|
5096
|
+
elif ch == ',' and not self.registration:
|
|
5097
|
+
self.cycle_order()
|
|
5006
5098
|
elif ch == 'a' and entries:
|
|
5007
5099
|
self.start_registration(entries[self.cursor])
|
|
5008
5100
|
elif ch == 'x' and entries:
|
|
@@ -5217,7 +5309,7 @@ class Sidebar:
|
|
|
5217
5309
|
elif self.expire_carry(): # no read came: a held lone Esc is the Esc key (BEY-6842)
|
|
5218
5310
|
self.dirty = True
|
|
5219
5311
|
finally:
|
|
5220
|
-
sys.stdout.write(self.stop_bytes())
|
|
5312
|
+
sys.stdout.write(('\033[<u' if self.extended_keys else '') + self.stop_bytes())
|
|
5221
5313
|
sys.stdout.flush()
|
|
5222
5314
|
termios.tcsetattr(fd, termios.TCSADRAIN, saved)
|
|
5223
5315
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""External site-hook loader (FLE-388, BEY-6912 durable federation).
|
|
2
|
+
|
|
3
|
+
A host declares `LANES_SITE_HOOK=<dir>` in site.conf (or the env). Each `.py`
|
|
4
|
+
module in that dir may define any of install_library / install_status /
|
|
5
|
+
install_cli / install_docs / install_actions. At each entrypoint the matching
|
|
6
|
+
one is called, so a host's federation hook lives OUTSIDE the package tree and
|
|
7
|
+
survives every update. No declaration (or `=refuse`) -> a no-op. Values are read
|
|
8
|
+
from site.conf, never executed.
|
|
9
|
+
"""
|
|
10
|
+
import importlib.util
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
_STAGES = ('library', 'status', 'cli', 'docs', 'actions')
|
|
16
|
+
_modules = None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _hook_dir():
|
|
20
|
+
val = os.environ.get('LANES_SITE_HOOK')
|
|
21
|
+
if val is None:
|
|
22
|
+
conf = Path(os.environ.get('HOME', '')) / '.config' / 'lanes' / 'site.conf'
|
|
23
|
+
try:
|
|
24
|
+
for line in conf.read_text().splitlines():
|
|
25
|
+
s = line.strip()
|
|
26
|
+
if s.startswith('LANES_SITE_HOOK='):
|
|
27
|
+
val = s.split('=', 1)[1].strip()
|
|
28
|
+
except OSError:
|
|
29
|
+
return None
|
|
30
|
+
if not val or val == 'refuse':
|
|
31
|
+
return None
|
|
32
|
+
d = Path(val).expanduser()
|
|
33
|
+
return d if d.is_dir() else None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _load():
|
|
37
|
+
global _modules
|
|
38
|
+
if _modules is not None:
|
|
39
|
+
return _modules
|
|
40
|
+
_modules = []
|
|
41
|
+
d = _hook_dir()
|
|
42
|
+
if d is None:
|
|
43
|
+
return _modules
|
|
44
|
+
for path in sorted(d.glob('*.py')):
|
|
45
|
+
if path.name.startswith('_'):
|
|
46
|
+
continue
|
|
47
|
+
spec = importlib.util.spec_from_file_location(path.stem, str(path))
|
|
48
|
+
if spec is None or spec.loader is None:
|
|
49
|
+
continue
|
|
50
|
+
mod = importlib.util.module_from_spec(spec)
|
|
51
|
+
sys.modules.setdefault(path.stem, mod)
|
|
52
|
+
spec.loader.exec_module(mod)
|
|
53
|
+
_modules.append(mod)
|
|
54
|
+
return _modules
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def apply(stage, *args):
|
|
58
|
+
"""Call install_<stage>(*args) on every declared site-hook module that defines it."""
|
|
59
|
+
if stage not in _STAGES:
|
|
60
|
+
raise ValueError('unknown site-hook stage: %r' % stage)
|
|
61
|
+
fn = 'install_' + stage
|
|
62
|
+
for mod in _load():
|
|
63
|
+
f = getattr(mod, fn, None)
|
|
64
|
+
if f is not None:
|
|
65
|
+
f(*args)
|
|
@@ -2411,6 +2411,11 @@ def main():
|
|
|
2411
2411
|
time.sleep(pause(level, time.time() - started, ctx.get('cut', 0)))
|
|
2412
2412
|
|
|
2413
2413
|
|
|
2414
|
+
|
|
2415
|
+
# lanes site-hook loader (FLE-388)
|
|
2416
|
+
import site_hooks
|
|
2417
|
+
site_hooks.apply('status', globals())
|
|
2418
|
+
|
|
2414
2419
|
if __name__ == '__main__':
|
|
2415
2420
|
if len(sys.argv) > 1 and sys.argv[1] == '--once':
|
|
2416
2421
|
# The same builder as the daemon, minus the one phase that is not an observation (client size flags).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Resolve numbered shortcuts from the device profile and Zellij's managed pane identities."""
|
|
2
|
+
import json
|
|
3
|
+
import os
|
|
4
|
+
import shlex
|
|
5
|
+
|
|
6
|
+
import device_sync
|
|
7
|
+
import lanes_lib as L
|
|
8
|
+
import users
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def projection(device, meta, registry, profile, call=L.run_bounded, allowed=None):
|
|
12
|
+
"""Up to nine visible boards. A missing managed tab keeps its slot empty."""
|
|
13
|
+
base = [os.environ.get('LANES_ZELLIJ') or str(L.SHARE / 'bin' / 'zellij-0.45.1'), '-s', device, 'action']
|
|
14
|
+
def listing(action, *flags):
|
|
15
|
+
code, output, _ = call(base + [action, '--json', *flags], 2)
|
|
16
|
+
if code != 0:
|
|
17
|
+
raise L.LanesError('Workspace list unavailable')
|
|
18
|
+
rows = json.loads(output)
|
|
19
|
+
if not isinstance(rows, list) or not all(isinstance(row, dict) for row in rows):
|
|
20
|
+
raise ValueError('Invalid workspace list')
|
|
21
|
+
return rows
|
|
22
|
+
|
|
23
|
+
tabs = listing('list-tabs')
|
|
24
|
+
panes = listing('list-panes', '--all')
|
|
25
|
+
mobile = bool(meta.get('mobile'))
|
|
26
|
+
known = device_sync.identities(device, tabs, panes, registry, mobile)
|
|
27
|
+
boards = users.arrange(registry['workspaces'], profile)
|
|
28
|
+
def managed(pane, board):
|
|
29
|
+
try:
|
|
30
|
+
words = shlex.split(pane.get('terminal_command') or pane.get('pane_command') or '')
|
|
31
|
+
except ValueError:
|
|
32
|
+
return False
|
|
33
|
+
return any(at is not None and words[at + 1:at + 3] == [device, board] for at in
|
|
34
|
+
(L.tree_file_at(words, 'libexec/sidebar'), L.tree_file_at(words, 'libexec/view.sh')))
|
|
35
|
+
|
|
36
|
+
result = []
|
|
37
|
+
for board in boards:
|
|
38
|
+
if allowed is not None and board['id'] not in allowed:
|
|
39
|
+
continue
|
|
40
|
+
choices = {}
|
|
41
|
+
for role in ('picker', 'view'):
|
|
42
|
+
tab = known.get(f"workspace/{board['id']}/{role}")
|
|
43
|
+
if tab is None:
|
|
44
|
+
continue
|
|
45
|
+
members = [p for p in panes if p.get('tab_id') == tab['tab_id'] and
|
|
46
|
+
not (p.get('is_plugin') or p.get('exited') or p.get('is_floating')) and type(p.get('id')) is int
|
|
47
|
+
and managed(p, board['id'])]
|
|
48
|
+
pane = next((p for p in members if p.get('is_focused')), next(iter(members), None))
|
|
49
|
+
if pane is not None:
|
|
50
|
+
choices[role] = {'tab': tab['name'], 'id': tab['tab_id'], 'pane': pane['id']}
|
|
51
|
+
result.append({'board': board['id'], 'workspace': board['title'], 'tabs': choices})
|
|
52
|
+
if len(result) == 9:
|
|
53
|
+
break
|
|
54
|
+
return result
|
|
@@ -14,6 +14,7 @@ if (typeof module == 'object') module.exports = {laneShellMode};
|
|
|
14
14
|
// END lanes tokens
|
|
15
15
|
root.dataset.lanesShell = mode;
|
|
16
16
|
const add = (tag, props) => D.head.append(Object.assign(D.createElement(tag), props)), js = src => add('script', {src});
|
|
17
|
+
if (globalThis.location?.search === '?keys') js('/lanes-assets/workspace-keys.js');
|
|
17
18
|
if (mode != 'phone') add('link', {rel: 'stylesheet', href: '/lanes-assets/browser.css'}), js('/lanes-assets/browser.js');
|
|
18
19
|
let d; const dir = () => !d && /^#lane(s$|=)/.test(globalThis.location?.hash) && js('/lanes-assets/directory.js', d = 1);
|
|
19
20
|
let o; const ops = () => !o && /^#(inbox|schedule|results)(=|$)/.test(globalThis.location?.hash) && js('/lanes-assets/inbox.js', o = 1);
|
|
@@ -57,18 +58,21 @@ if (typeof module == 'object') module.exports = {laneShellMode};
|
|
|
57
58
|
localStorage.setItem('zellij:mobile-theme', theme);
|
|
58
59
|
root.dataset.zjTheme = theme;
|
|
59
60
|
} catch {}
|
|
61
|
+
const rect = (x, y, w, h, r) => `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="${r}"/>`;
|
|
62
|
+
const path = d => `<path d="${d}"/>`;
|
|
63
|
+
const circle = (x, y, r) => `<circle cx="${x}" cy="${y}" r="${r}"/>`;
|
|
60
64
|
const icons = {
|
|
61
|
-
workspaces: [[3, 3], [14, 3], [3, 14], [14, 14]].map(([x, y]) =>
|
|
62
|
-
lanes: '
|
|
63
|
-
panes:
|
|
64
|
-
keyboard:
|
|
65
|
-
more:
|
|
66
|
-
close: '
|
|
67
|
-
arrow: '
|
|
68
|
-
check: '
|
|
69
|
-
search:
|
|
70
|
-
copy:
|
|
71
|
-
paste:
|
|
65
|
+
workspaces: [[3, 3], [14, 3], [3, 14], [14, 14]].map(([x, y]) => rect(x, y, 7, 7, 2)).join(''),
|
|
66
|
+
lanes: path('M8 5h13M8 12h13M8 19h13M3 5h.01M3 12h.01M3 19h.01'),
|
|
67
|
+
panes: rect(3, 4, 18, 16, 3) + path('M12 4v16'),
|
|
68
|
+
keyboard: rect(2, 5, 20, 14, 3) + path('M6 9h.01m4 0h.01m4 0h.01m4 0h.01M6 13h.01m4 0h.01m4 0h.01m4 0h.01M8 16h8'),
|
|
69
|
+
more: [5, 12, 19].map(x => circle(x, 12, 1)).join(''),
|
|
70
|
+
close: path('m6 6 12 12M6 18 18 6'),
|
|
71
|
+
arrow: path('m9 5 7 7-7 7'),
|
|
72
|
+
check: path('m5 12 4 4L19 6'),
|
|
73
|
+
search: circle(10.5, 10.5, 6.5) + path('m16 16 5 5'),
|
|
74
|
+
copy: rect(9, 9, 11, 11, 2) + path('M5 15V5h10'),
|
|
75
|
+
paste: rect(5, 5, 14, 16, 2) + path('M9 3h6v4H9z'),
|
|
72
76
|
};
|
|
73
77
|
const svg = name => `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${icons[name]}</svg>`;
|
|
74
78
|
const make = (tag, cls, text) => Object.assign(D.createElement(tag), tag == 'button' && {type: tag},
|
|
@@ -85,8 +89,9 @@ if (typeof module == 'object') module.exports = {laneShellMode};
|
|
|
85
89
|
let shell, heading, subtitle, status, note, empty, dock, sheet, list, search, count, lanesButton, panesButton, pasteKey, typingField, quickRow, quickOn, keysKey, view;
|
|
86
90
|
let laneFilterBar, laneFilterInput, laneFilterPrev = '', sentAt, filterTab, owed = new Set(), sock, unacked, gone, away, armed, seen, rl, hid, bye, retry, hiddenAt, doubt;
|
|
87
91
|
let api, term, previousCards, sheetOpen, shot, pre, said, down, returnFocus, menuWas, hintN, timer, queue = [], fontSize = 16, lastKey, restoring, mem = {ws: {}};
|
|
92
|
+
const fontKey = 'lanes:font-size';
|
|
88
93
|
try {
|
|
89
|
-
const stored = Number(localStorage.getItem(
|
|
94
|
+
const stored = Number(localStorage.getItem(fontKey));
|
|
90
95
|
if (stored >= 14 && stored <= 24) fontSize = stored;
|
|
91
96
|
} catch {}
|
|
92
97
|
const state = () => api?.getState();
|
|
@@ -98,7 +103,7 @@ if (typeof module == 'object') module.exports = {laneShellMode};
|
|
|
98
103
|
.then(r => r.ok, () => 0).then(ok => ok ? ((gone > 1 || unacked) && unsure(), W.location?.reload()) : (rl = 0, api && hint('No connection to Lanes')));
|
|
99
104
|
const back = () => hid && !bye && sock?.readyState > 1 && reconnect();
|
|
100
105
|
const set = (el, k, v) => el.setAttribute(k, v), kbd = () => W.__zjSoftKbdCapture, aria = (el, label) => set(el, 'aria-label', label), keep = ev => ev.preventDefault(), act = () => D.activeElement, unfocus = () => (kbd()?.element.blur(), act()?.blur());
|
|
101
|
-
const finder = (placeholder, label) => {
|
|
106
|
+
const finder = (placeholder, label = placeholder) => {
|
|
102
107
|
const el = Object.assign(make('input'), {type: 'search', placeholder, autocomplete: 'off', spellcheck: false});
|
|
103
108
|
aria(el, label);
|
|
104
109
|
return el;
|
|
@@ -155,7 +160,7 @@ if (typeof module == 'object') module.exports = {laneShellMode};
|
|
|
155
160
|
const tabKey = () => 'lanes:tab:' + W.location?.pathname;
|
|
156
161
|
const bare = () => (currentTab()?.name || '').replace(/ ☰$/, '');
|
|
157
162
|
const at = (a = data()?.active_pane) => JSON.stringify([currentTab()?.name, a?.is_plugin, a?.pane_id]);
|
|
158
|
-
const GLYPHS = '◆◇▸✓', TONES = ['urgent', 'attention', 'working', 'done'];
|
|
163
|
+
const GLYPHS = '◆◇▸✓', TONES = ['urgent', 'attention', 'working', 'done'], WORDS = ['need approval', 'need you', 'working', 'done'];
|
|
159
164
|
function parseCounts(title) {
|
|
160
165
|
const c = {approval: 0, input: 0, working: 0, done: 0}, keys = Object.keys(c);
|
|
161
166
|
let found = 0;
|
|
@@ -163,7 +168,6 @@ if (typeof module == 'object') module.exports = {laneShellMode};
|
|
|
163
168
|
return found ? c : null;
|
|
164
169
|
}
|
|
165
170
|
W.__lanesParseCounts = parseCounts;
|
|
166
|
-
const WORDS = ['need approval', 'need you', 'working', 'done'];
|
|
167
171
|
const countParts = c => c ? Object.values(c).map((n, i) => [GLYPHS[i], n, TONES[i], WORDS[i]]).filter(p => p[1]) : [];
|
|
168
172
|
const tabNamed = name => data()?.tabs.find(t => t.name === name), pickerTab = name => tabNamed(name + ' ☰');
|
|
169
173
|
const pickerTitle = name => paneAt(pickerTab(name)?.position)?.title || '';
|
|
@@ -265,7 +269,7 @@ if (typeof module == 'object') module.exports = {laneShellMode};
|
|
|
265
269
|
empty = make('p', 'lanes-empty', 'No matching workspaces');
|
|
266
270
|
const searchWrap = make('label', 'lanes-search');
|
|
267
271
|
searchWrap.innerHTML = svg('search');
|
|
268
|
-
search = finder('Find a workspace'
|
|
272
|
+
search = finder('Find a workspace');
|
|
269
273
|
on(search, 'input', renderCards); searchWrap.append(search);
|
|
270
274
|
list = make('div', 'lanes-workspaces');
|
|
271
275
|
const sessionButton = make('button', 'lanes-session-link', 'Switch session');
|
|
@@ -391,7 +395,7 @@ if (typeof module == 'object') module.exports = {laneShellMode};
|
|
|
391
395
|
const setFont = n => { fontSize = Math.min(24, Math.max(14, Math.round(n))); applyFont(); };
|
|
392
396
|
function applyFont() {
|
|
393
397
|
Object.assign(term.options, {fontSize, lineHeight: 1.1});
|
|
394
|
-
try {localStorage.getItem(
|
|
398
|
+
try {localStorage.getItem(fontKey) != fontSize && localStorage.setItem(fontKey, fontSize);} catch {}
|
|
395
399
|
text(id('lanes-font-value'), `${fontSize} px`);
|
|
396
400
|
resize();
|
|
397
401
|
}
|
|
@@ -416,7 +420,7 @@ if (typeof module == 'object') module.exports = {laneShellMode};
|
|
|
416
420
|
const row = menuRow('Text size');
|
|
417
421
|
const step = (t, name, by) => { const b = make('button', '', t); aria(b, name + ' terminal text');
|
|
418
422
|
on(b, 'click', () => setFont(fontSize + by)); return b; };
|
|
419
|
-
const value = make('output'
|
|
423
|
+
const value = make('output'); value.id = 'lanes-font-value';
|
|
420
424
|
row.append(step('A−', 'Smaller', -1), value, step('A+', 'Larger', 1));
|
|
421
425
|
Object.assign(menuRow('Docs', 'a', ' lanes-session-link'), {href: '/lanes-docs/', target: '_blank'});
|
|
422
426
|
fetch('/enrol/site', {credentials: 'same-origin'}).then(r => r.json())
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Loaded only by a view opened with ?keys. The host resolves the device's
|
|
2
|
+
// profile and managed tabs. The browser can only focus a pane in its own view.
|
|
3
|
+
function shortcutNumber(event, doc) {
|
|
4
|
+
if (!event.metaKey || event.altKey || event.ctrlKey || event.shiftKey || event.repeat ||
|
|
5
|
+
event.defaultPrevented || event.isComposing || event.keyCode === 229 || !/^[1-9]$/.test(event.key)) return 0;
|
|
6
|
+
const ownsInput = 'input,textarea,select,form,[contenteditable]:not([contenteditable="false"]),[role="textbox"],#terminal';
|
|
7
|
+
if (event.target?.closest?.(ownsInput) || doc.activeElement?.closest?.(ownsInput) ||
|
|
8
|
+
doc.querySelector('dialog[open],[aria-modal="true"]:not([hidden]),.security-modal:not([hidden])')) return 0;
|
|
9
|
+
return Number(event.key);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function workspacePane(slot, data, memory) {
|
|
13
|
+
if (!slot || !data) return null;
|
|
14
|
+
const {picker, view} = slot.tabs;
|
|
15
|
+
const remembered = memory?.ws?.[slot.workspace];
|
|
16
|
+
const targets = [view, picker].filter(Boolean);
|
|
17
|
+
const ordered = [targets.find(t => t.tab === remembered), picker, view].filter(Boolean);
|
|
18
|
+
for (const target of ordered) {
|
|
19
|
+
const matches = data.panes.filter(p => !p.is_plugin && p.pane_id === target.pane);
|
|
20
|
+
if (matches.length === 1 && data.tabs.some(t => t.position === matches[0].tab_position && t.name === target.tab))
|
|
21
|
+
return target.pane;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function installWorkspaceKeys(win, doc) {
|
|
27
|
+
let generation = 0, hint;
|
|
28
|
+
const invalidate = () => ++generation;
|
|
29
|
+
for (const type of ['pointerdown', 'focusin', 'pagehide', 'compositionstart']) win.addEventListener(type, invalidate, true);
|
|
30
|
+
win.addEventListener('keydown', async event => {
|
|
31
|
+
if (event.repeat) return;
|
|
32
|
+
const request = invalidate(), number = shortcutNumber(event, doc);
|
|
33
|
+
const api = win.__zjMobileUi, data = () => api?.getState()?.data;
|
|
34
|
+
const path = win.location.pathname, source = data()?.active_pane;
|
|
35
|
+
if (!number || !source || !/^\/[A-Za-z0-9_][\w.-]{0,47}$/.test(path)) return;
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
event.stopImmediatePropagation();
|
|
38
|
+
let pane = null;
|
|
39
|
+
try {
|
|
40
|
+
const reply = await win.fetch('/lanes-docs/workspace-keys' + path, {cache: 'no-store', signal: AbortSignal.timeout(5500)});
|
|
41
|
+
const slots = reply.ok && await reply.json();
|
|
42
|
+
let memory;
|
|
43
|
+
try { memory = JSON.parse(win.localStorage.getItem('lanes:tab:' + path)); } catch {}
|
|
44
|
+
if (Array.isArray(slots)) pane = workspacePane(slots[number - 1], data(), memory);
|
|
45
|
+
} catch {}
|
|
46
|
+
if (request !== generation || win.location.pathname !== path || doc.hidden ||
|
|
47
|
+
source.tab_position !== data()?.active_pane?.tab_position || source.pane_id !== data()?.active_pane?.pane_id) return;
|
|
48
|
+
if (pane !== null) {
|
|
49
|
+
if (hint) hint.hidden = true;
|
|
50
|
+
if (pane !== source.pane_id) win.__zjSendControl?.({type: 'FocusPane', pane_id: pane, is_plugin: false});
|
|
51
|
+
} else {
|
|
52
|
+
if (!hint) {
|
|
53
|
+
hint = doc.createElement('output');
|
|
54
|
+
hint.setAttribute('aria-live', 'polite');
|
|
55
|
+
hint.style.cssText = 'position:fixed;bottom:15%;left:1rem;padding:.4rem;background:Canvas;color:CanvasText;z-index:10';
|
|
56
|
+
doc.body.append(hint);
|
|
57
|
+
}
|
|
58
|
+
hint.hidden = false;
|
|
59
|
+
hint.textContent = 'Workspace ' + number + ' unavailable';
|
|
60
|
+
win.setTimeout(() => { if (hint.textContent === 'Workspace ' + number + ' unavailable') hint.hidden = true; }, 2000);
|
|
61
|
+
}
|
|
62
|
+
}, true);
|
|
63
|
+
}
|
|
64
|
+
if (typeof module === 'object') module.exports = {installWorkspaceKeys, shortcutNumber, workspacePane};
|
|
65
|
+
if (typeof window === 'object') installWorkspaceKeys(window, document);
|
package/payload/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibelord/lanes",
|
|
3
|
-
"version": "1.9.
|
|
4
|
-
"commit": "
|
|
5
|
-
"digest": "sha256:
|
|
3
|
+
"version": "1.9.2",
|
|
4
|
+
"commit": "5c99782f6def52af26fe1e2bcc88360b80686cb8",
|
|
5
|
+
"digest": "sha256:6f0da956770af1cff6de3c9d48455344d3579b37a3941757fafc60acb019feaf",
|
|
6
6
|
"executables": [
|
|
7
7
|
"bin/lanes",
|
|
8
8
|
"bin/lanes-site-serve",
|