Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73f8525db2 | ||
|
|
390ce61f5b | ||
|
|
6e109aec36 | ||
|
|
05057f695d |
@@ -8,7 +8,7 @@ SHAREDIR := $(PREFIX)/share/devdesk
|
|||||||
TTYD_ARCH ?= x86_64
|
TTYD_ARCH ?= x86_64
|
||||||
|
|
||||||
SHELL_SCRIPTS := bin/devdesk $(wildcard libexec/devdesk-*) scripts/fetch-ttyd.sh debian/devdesk.postinst debian/devdesk.postrm
|
SHELL_SCRIPTS := bin/devdesk $(wildcard libexec/devdesk-*) scripts/fetch-ttyd.sh debian/devdesk.postinst debian/devdesk.postrm
|
||||||
WEB_SOURCES := web/build.mjs web/index.template.html web/styles.css $(wildcard web/src/*.js) \
|
WEB_SOURCES := web/build.mjs web/index.template.html web/styles.css $(wildcard web/src/*.js) $(wildcard web/editor/*.js) \
|
||||||
vendor/web_template/base.css debian/changelog
|
vendor/web_template/base.css debian/changelog
|
||||||
|
|
||||||
.PHONY: all lint test install clean sync-template
|
.PHONY: all lint test install clean sync-template
|
||||||
@@ -26,7 +26,7 @@ build/ttyd: vendor/ttyd/VERSION vendor/ttyd/SHA256SUMS scripts/fetch-ttyd.sh
|
|||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
lint: node_modules/.package-lock.json
|
lint: node_modules/.package-lock.json
|
||||||
npx eslint --max-warnings 0 --ext .js,.mjs web/src web/build.mjs tests/protocol.test.mjs
|
npx eslint --max-warnings 0 --ext .js,.mjs web/src web/editor web/build.mjs tests/protocol.test.mjs
|
||||||
shellcheck -x $(SHELL_SCRIPTS)
|
shellcheck -x $(SHELL_SCRIPTS)
|
||||||
jq empty share/claude-settings.json
|
jq empty share/claude-settings.json
|
||||||
|
|
||||||
@@ -41,8 +41,11 @@ install: all
|
|||||||
install -m 0755 libexec/devdesk-picker libexec/devdesk-claude-run libexec/devdesk-session-hook \
|
install -m 0755 libexec/devdesk-picker libexec/devdesk-claude-run libexec/devdesk-session-hook \
|
||||||
libexec/devdesk-tmux-ready libexec/devdesk-serve libexec/devdesk-statusline \
|
libexec/devdesk-tmux-ready libexec/devdesk-serve libexec/devdesk-statusline \
|
||||||
libexec/devdesk-deploy libexec/devdesk-state-hook libexec/devdesk-notify-matrix $(DESTDIR)$(LIBDIR)/
|
libexec/devdesk-deploy libexec/devdesk-state-hook libexec/devdesk-notify-matrix $(DESTDIR)$(LIBDIR)/
|
||||||
|
install -m 0644 libexec/devdesk-files.sh $(DESTDIR)$(LIBDIR)/devdesk-files.sh
|
||||||
install -m 0755 build/ttyd $(DESTDIR)$(LIBDIR)/bin/ttyd
|
install -m 0755 build/ttyd $(DESTDIR)$(LIBDIR)/bin/ttyd
|
||||||
install -m 0644 dist/index.html share/tmux.conf share/claude-settings.json $(DESTDIR)$(SHAREDIR)/
|
install -m 0644 dist/index.html share/tmux.conf share/claude-settings.json $(DESTDIR)$(SHAREDIR)/
|
||||||
|
install -d $(DESTDIR)$(SHAREDIR)/assets
|
||||||
|
install -m 0644 dist/assets/editor.js $(DESTDIR)$(SHAREDIR)/assets/editor.js
|
||||||
install -m 0644 etc/env $(DESTDIR)$(SYSCONFDIR)/devdesk/env
|
install -m 0644 etc/env $(DESTDIR)$(SYSCONFDIR)/devdesk/env
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ The tmux server runs in its own unit, so every Claude process lives in **that**
|
|||||||
- **Conversation tracking:** a Claude `SessionStart` hook records each session's conversation ID in `/var/lib/devdesk/registry.json`. After a reboot the session resumes *that* conversation, even when other Claude instances, such as code-server, use the same directory.
|
- **Conversation tracking:** a Claude `SessionStart` hook records each session's conversation ID in `/var/lib/devdesk/registry.json`. After a reboot the session resumes *that* conversation, even when other Claude instances, such as code-server, use the same directory.
|
||||||
- **Session status:** Claude hooks (`devdesk-state-hook`) mark each session **working**, **waiting on you** (with Claude's message) or **idle**.
|
- **Session status:** Claude hooks (`devdesk-state-hook`) mark each session **working**, **waiting on you** (with Claude's message) or **idle**.
|
||||||
- The sidebar shows it with context % and a context bar; the session chip's dot shows the current session's state.
|
- The sidebar shows it with context % and a context bar; the session chip's dot shows the current session's state.
|
||||||
- A "… needs you" chip jumps to other sessions that are waiting, and a desktop notification fires when one starts waiting. With the panels closed, the **Panels** button shows a count of waiting sessions and Grafana alerts.
|
- A "… needs you" chip jumps to other sessions that are waiting, and a desktop notification fires when one starts waiting.
|
||||||
|
- The **🔔 inbox** lists what needs you (waiting sessions, firing Grafana alerts) and what happened while you were away (a background session finished or started waiting, CI passed or failed); its badge counts them.
|
||||||
- **Matrix "Claude needs you":** when a session has waited for `DEVDESK_MATRIX_DELAY` seconds (30) and no browser tab or SSH client is attached to it, `devdesk-notify-matrix` posts one message per wait, with a link, to the hookshot webhook URL in `/etc/devdesk/matrix-webhook` (mode 600; no file = off).
|
- **Matrix "Claude needs you":** when a session has waited for `DEVDESK_MATRIX_DELAY` seconds (30) and no browser tab or SSH client is attached to it, `devdesk-notify-matrix` posts one message per wait, with a link, to the hookshot webhook URL in `/etc/devdesk/matrix-webhook` (mode 600; no file = off).
|
||||||
- **File & image drop:** drag files onto the terminal or paste a screenshot.
|
- **File & image drop:** drag files onto the terminal or paste a screenshot.
|
||||||
- They're uploaded through ttyd to `/var/lib/devdesk/uploads/<session>/` (25 MB max, pruned after 7 days), and the path is pasted into Claude.
|
- They're uploaded through ttyd to `/var/lib/devdesk/uploads/<session>/` (25 MB max, pruned after 7 days), and the path is pasted into Claude.
|
||||||
@@ -45,7 +46,9 @@ The tmux server runs in its own unit, so every Claude process lives in **that**
|
|||||||
- **Ask Claude** types an investigation prompt into the current session without sending it.
|
- **Ask Claude** types an investigation prompt into the current session without sending it.
|
||||||
- Configure `DEVDESK_GRAFANA_URL`, plus a Viewer token in `DEVDESK_GRAFANA_TOKEN_FILE`.
|
- Configure `DEVDESK_GRAFANA_URL`, plus a Viewer token in `DEVDESK_GRAFANA_TOKEN_FILE`.
|
||||||
- **Repo / CI panel:** branch, ahead/behind, uncommitted changes, HEAD's Gitea CI status and open PRs for the session's folder. When CI fails, **Ask Claude to fix CI** types a prompt to read the failed job's log.
|
- **Repo / CI panel:** branch, ahead/behind, uncommitted changes, HEAD's Gitea CI status and open PRs for the session's folder. When CI fails, **Ask Claude to fix CI** types a prompt to read the failed job's log.
|
||||||
|
- **Files** (Ctrl+Shift+E): browse the session's folder beside the terminal, read files with syntax highlighting, preview markdown (sanitized, with its relative images) and images, and review uncommitted changes: git status with line counts, a **C** badge on files Claude edited, and a diff against HEAD. **→ Claude** types `@path` into the prompt. Read-only for now. Paths can't leave the session folder. The editor bundle (`/usr/share/devdesk/assets/editor.js`) loads over ttyd the first time and is cached by the browser.
|
||||||
- **Context:** a Claude `statusLine` command (`devdesk-statusline`) snapshots each session's model, context-window use and cost to `/var/lib/devdesk/context/<session>.json`. The Sessions panel shows it as a bar (cost in the tooltip), and Claude's own footer shows a one-line summary.
|
- **Context:** a Claude `statusLine` command (`devdesk-statusline`) snapshots each session's model, context-window use and cost to `/var/lib/devdesk/context/<session>.json`. The Sessions panel shows it as a bar (cost in the tooltip), and Claude's own footer shows a one-line summary.
|
||||||
|
- **Light mode:** the terminal switches palettes with the page. DevDesk starts Claude with its `dark-ansi` theme so Claude draws with the terminal's 16 colours, and the light palette maps bright white to ink; tmux and the status line use ANSI colours too. A session picks up Claude's theme the next time Claude starts in it (`/exit`, then ⏎ resumes the same conversation).
|
||||||
- **Phone:** a key bar replaces the shortcut hints (Esc, Tab, ⇧Tab, ^C, ↑, ↓, ⏎, Claude/Shell window), and the panels open as a drawer.
|
- **Phone:** a key bar replaces the shortcut hints (Esc, Tab, ⇧Tab, ^C, ↑, ↓, ⏎, Claude/Shell window), and the panels open as a drawer.
|
||||||
- **SSH:** `devdesk attach <name>`, `devdesk new <name> [project]`, `devdesk rename <old> <new>`, `devdesk end <name>`, `devdesk ls`, `devdesk pick`, `devdesk repo <name>`, `devdesk alerts`.
|
- **SSH:** `devdesk attach <name>`, `devdesk new <name> [project]`, `devdesk rename <old> <new>`, `devdesk end <name>`, `devdesk ls`, `devdesk pick`, `devdesk repo <name>`, `devdesk alerts`.
|
||||||
|
|
||||||
@@ -59,8 +62,10 @@ The tmux server runs in its own unit, so every Claude process lives in **that**
|
|||||||
| Ctrl-b d | Detach (the session keeps running) |
|
| Ctrl-b d | Detach (the session keeps running) |
|
||||||
| Shift+drag | Native browser selection (plain drag goes to tmux copy-mode, which copies via OSC 52) |
|
| Shift+drag | Native browser selection (plain drag goes to tmux copy-mode, which copies via OSC 52) |
|
||||||
| Ctrl+Shift+C / V | Copy selection / paste |
|
| Ctrl+Shift+C / V | Copy selection / paste |
|
||||||
|
| Ctrl+Shift+P | Command palette (also the ⌕ button) |
|
||||||
|
| Ctrl+Shift+E | Files pane (Esc: back, then close) |
|
||||||
|
|
||||||
Text size, desktop notifications (with a mute) and fullscreen are in the **⋯** menu. In Chromium, fullscreen also captures Ctrl+W/Ctrl+T, which browsers otherwise keep for themselves.
|
The **☀/◐** button switches light and dark mode (saved per browser, shared with the other web_template apps' `lt_theme` preference). Text size, desktop notifications (with a mute), the keyboard shortcuts sheet and fullscreen are in the **⋯** menu; everything is also in the command palette. In Chromium, fullscreen also captures Ctrl+W/Ctrl+T, which browsers otherwise keep for themselves.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
- **Put your changes in `/etc/devdesk/env.local`.** It's read after the packaged `env` and never shipped, so `apt upgrade` never asks about it. Example: `DEVDESK_REMOTE_CONTROL=1`.
|
- **Put your changes in `/etc/devdesk/env.local`.** It's read after the packaged `env` and never shipped, so `apt upgrade` never asks about it. Example: `DEVDESK_REMOTE_CONTROL=1`.
|
||||||
|
|||||||
+14
@@ -17,6 +17,8 @@ set -euo pipefail
|
|||||||
|
|
||||||
# shellcheck source=libexec/devdesk-lib.sh
|
# shellcheck source=libexec/devdesk-lib.sh
|
||||||
. "${DEVDESK_LIBEXEC:-/usr/lib/devdesk}/devdesk-lib.sh"
|
. "${DEVDESK_LIBEXEC:-/usr/lib/devdesk}/devdesk-lib.sh"
|
||||||
|
# shellcheck source=libexec/devdesk-files.sh
|
||||||
|
. "$DEVDESK_LIBEXEC/devdesk-files.sh"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
sed -n '2,12s/^# \{0,1\}//p' "$0"
|
sed -n '2,12s/^# \{0,1\}//p' "$0"
|
||||||
@@ -296,20 +298,31 @@ cmd_attach() {
|
|||||||
--list)
|
--list)
|
||||||
[ $# -eq 1 ] || dd_die "--list takes no arguments"
|
[ $# -eq 1 ] || dd_die "--list takes no arguments"
|
||||||
cmd_list
|
cmd_list
|
||||||
|
dd_linger
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--repo)
|
--repo)
|
||||||
shift
|
shift
|
||||||
cmd_repo "$@"
|
cmd_repo "$@"
|
||||||
|
dd_linger
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--alerts)
|
--alerts)
|
||||||
cmd_alerts
|
cmd_alerts
|
||||||
|
dd_linger
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--upload)
|
--upload)
|
||||||
shift
|
shift
|
||||||
cmd_upload "$@"
|
cmd_upload "$@"
|
||||||
|
dd_linger
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
--fs-list | --fs-read | --git-status | --git-show | --asset)
|
||||||
|
local action=${1#--}
|
||||||
|
shift
|
||||||
|
"cmd_${action//-/_}" "$@"
|
||||||
|
dd_linger
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--new | --rename | --end)
|
--new | --rename | --end)
|
||||||
@@ -317,6 +330,7 @@ cmd_attach() {
|
|||||||
shift
|
shift
|
||||||
"cmd_$action" "$@"
|
"cmd_$action" "$@"
|
||||||
ok_json
|
ok_json
|
||||||
|
dd_linger
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
--existing)
|
--existing)
|
||||||
|
|||||||
Vendored
+60
@@ -1,3 +1,63 @@
|
|||||||
|
devdesk (0.7.0) bookworm; urgency=medium
|
||||||
|
|
||||||
|
* Files pane (#19): a Files button (Ctrl+Shift+E) next to Panels opens the
|
||||||
|
session's folder beside the terminal (a drag-resizable split on wide
|
||||||
|
screens, an overlay on narrow ones and phones).
|
||||||
|
- Browse folders; read files with syntax highlighting (CodeMirror,
|
||||||
|
read-only, Ctrl+F search, line wrap toggle), markdown rendered as a
|
||||||
|
sanitized preview with its relative images, images shown inline.
|
||||||
|
- Changes tab: uncommitted git changes with line counts and a "C" badge
|
||||||
|
on files Claude edited (recorded by the state hook from Edit/Write);
|
||||||
|
diff against HEAD for any changed file. Non-git sessions list the files
|
||||||
|
Claude edited there.
|
||||||
|
- "→ Claude" types @path into the prompt; Copy path.
|
||||||
|
- After Claude's turn the list refreshes, and an open file that changed
|
||||||
|
on disk offers a reload.
|
||||||
|
- Paths stay inside the session folder (no absolute paths, no symlink
|
||||||
|
escapes). Read-only for now; editing is v0.8.0.
|
||||||
|
- The editor (~600 KB) is not in the page: it ships in
|
||||||
|
/usr/share/devdesk/assets, is fetched over ttyd the first time Files
|
||||||
|
opens, checked against the page's SHA-256 and cached in the browser.
|
||||||
|
* Fix: the state hook mis-read hook fields when Claude's message was empty.
|
||||||
|
|
||||||
|
-- Jared Vititoe <jjvititoe1@gmail.com> Thu, 08 Oct 2026 01:16:26 -0400
|
||||||
|
|
||||||
|
devdesk (0.6.1) bookworm; urgency=medium
|
||||||
|
|
||||||
|
* Inbox bell (#36): sessions waiting on you, firing alerts, and what
|
||||||
|
happened while you were away (a background session finished or started
|
||||||
|
waiting, CI passed or failed). Click to jump there; shared by all tabs.
|
||||||
|
Replaces the count on the Panels button.
|
||||||
|
* Phone header: theme in the ⋯ menu, Panels as an icon, so the bell fits.
|
||||||
|
|
||||||
|
-- Jared Vititoe <jjvititoe1@gmail.com> Thu, 08 Oct 2026 00:50:56 -0400
|
||||||
|
|
||||||
|
devdesk (0.6.0) bookworm; urgency=medium
|
||||||
|
|
||||||
|
* Light mode, like the other web_template apps (#31): the ☀/◐ button in the
|
||||||
|
header, shared lt_theme preference (OS setting until you choose), applied
|
||||||
|
before first paint and synced across tabs. The terminal has a light
|
||||||
|
palette; Claude runs with its dark-ansi theme so its colours come from
|
||||||
|
that palette, and the light palette maps bright white to ink, so Claude's
|
||||||
|
text, scrollback included, stays readable in both modes. tmux and the
|
||||||
|
statusLine use ANSI colours so they follow the theme too. Sessions pick
|
||||||
|
up Claude's theme the next time Claude starts in them.
|
||||||
|
* Command palette (#32): ⌕ button or Ctrl+Shift+P. Switch, create, rename
|
||||||
|
and end sessions, Claude/Shell window, scroll back, detach, theme, panels,
|
||||||
|
text size, fullscreen, notifications, copy link, open the repo / PRs / CI
|
||||||
|
run, show alerts, keyboard help.
|
||||||
|
* Dialogs instead of browser prompt/confirm for rename, end and new
|
||||||
|
session (name check inline, project folder picker), and a keyboard
|
||||||
|
shortcuts sheet in the ⋯ menu, the palette and the footer (#33).
|
||||||
|
* Toasts for results: created, renamed, ended, uploads, link copied, CI
|
||||||
|
finished, errors (#34).
|
||||||
|
* Fix: renames, ends and new sessions often reported "no response" although
|
||||||
|
they worked; ttyd dropped the reply of commands that exit right after
|
||||||
|
printing. Replies now wait for the browser to hang up (#35).
|
||||||
|
* Fix: the Sessions panel showed stale names right after a rename or end.
|
||||||
|
|
||||||
|
-- Jared Vititoe <jjvititoe1@gmail.com> Thu, 08 Oct 2026 00:32:11 -0400
|
||||||
|
|
||||||
devdesk (0.5.1) bookworm; urgency=medium
|
devdesk (0.5.1) bookworm; urgency=medium
|
||||||
|
|
||||||
* A session created by opening its URL shows up in the Sessions panel and
|
* A session created by opening its URL shows up in the Sessions panel and
|
||||||
|
|||||||
Vendored
+5
@@ -35,6 +35,11 @@ Comment: Bundled into index.html at build time:
|
|||||||
2014-2016 SourceLair Private Company, 2012-2013 Christopher Jeffrey);
|
2014-2016 SourceLair Private Company, 2012-2013 Christopher Jeffrey);
|
||||||
JetBrains Mono via @fontsource/jetbrains-mono (OFL-1.1,
|
JetBrains Mono via @fontsource/jetbrains-mono (OFL-1.1,
|
||||||
Copyright 2020 The JetBrains Mono Project Authors).
|
Copyright 2020 The JetBrains Mono Project Authors).
|
||||||
|
Bundled into assets/editor.js (the file viewer) at build time:
|
||||||
|
CodeMirror 6 and @lezer/highlight (MIT, Copyright 2018-2021 Marijn Haverbeke
|
||||||
|
and others); marked (MIT, Copyright 2018+ MarkedJS, 2011-2018 Christopher
|
||||||
|
Jeffrey); DOMPurify (Apache-2.0 or MPL-2.0 at the recipient's choice, here
|
||||||
|
Apache-2.0, Copyright 2025 Dr.-Ing. Mario Heiderich, Cure53).
|
||||||
|
|
||||||
License: MIT
|
License: MIT
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
|||||||
@@ -0,0 +1,168 @@
|
|||||||
|
# shellcheck shell=bash disable=SC2016 # single-quoted jq filters use jq variables
|
||||||
|
# File viewer commands (devdesk#19), sourced by bin/devdesk. Every path is
|
||||||
|
# relative to the session's folder and must stay inside it: no absolute paths,
|
||||||
|
# no newlines, no symlink escapes. Reached through `devdesk attach --fs-*`.
|
||||||
|
|
||||||
|
: "${DEVDESK_FS_MAX:=2097152}" # bytes the viewer opens
|
||||||
|
: "${DEVDESK_FS_LIST_MAX:=2000}" # entries per directory listing
|
||||||
|
: "${DEVDESK_ASSETS:=$DEVDESK_SHARE/assets}"
|
||||||
|
|
||||||
|
# Blob replies: a JSON header line, then base64 between markers (no body for
|
||||||
|
# binary files the viewer can't show). The client waits for the END marker.
|
||||||
|
DD_BLOB_BEGIN=DEVDESK-BLOB-BEGIN
|
||||||
|
DD_BLOB_END=DEVDESK-BLOB-END
|
||||||
|
|
||||||
|
dd_session_root() {
|
||||||
|
dd_valid_name "$1" || dd_die "invalid session name: $1"
|
||||||
|
realpath -e -- "$(dd_resolve_dir "$1")" 2>/dev/null || dd_die "the folder of session '$1' is missing"
|
||||||
|
}
|
||||||
|
|
||||||
|
# dd_fs_path ROOT REL -> the real path of REL inside ROOT, or die.
|
||||||
|
dd_fs_path() {
|
||||||
|
local root=$1 rel=${2:-.} p
|
||||||
|
case $rel in
|
||||||
|
/* | *$'\n'* | *$'\r'*) dd_die "bad path: $rel" ;;
|
||||||
|
esac
|
||||||
|
[ -n "$rel" ] || rel=.
|
||||||
|
p=$(realpath -e -- "$root/$rel" 2>/dev/null) || dd_die "no such file: $rel"
|
||||||
|
case "$p/" in
|
||||||
|
"$root"/*) printf '%s\n' "$p" ;;
|
||||||
|
*) dd_die "outside the session folder: $rel" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
dd_mime() {
|
||||||
|
case ${1,,} in
|
||||||
|
*.png) echo image/png ;;
|
||||||
|
*.jpg | *.jpeg) echo image/jpeg ;;
|
||||||
|
*.gif) echo image/gif ;;
|
||||||
|
*.webp) echo image/webp ;;
|
||||||
|
*.svg) echo image/svg+xml ;;
|
||||||
|
*.ico) echo image/x-icon ;;
|
||||||
|
*.bmp) echo image/bmp ;;
|
||||||
|
*.pdf) echo application/pdf ;;
|
||||||
|
*) echo "" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# dd_blob FILE LABEL: header + body for one file on disk.
|
||||||
|
dd_blob() {
|
||||||
|
local f=$1 label=$2 size mtime sha mime binary=false utf8=true body=true
|
||||||
|
read -r size mtime < <(stat -c '%s %Y' -- "$f")
|
||||||
|
mime=$(dd_mime "$f")
|
||||||
|
if [ "$size" -gt "$DEVDESK_FS_MAX" ]; then
|
||||||
|
jq -cMn --arg p "$label" --argjson s "$size" --argjson m "$mtime" --argjson max "$DEVDESK_FS_MAX" \
|
||||||
|
'{path: $p, size: $s, mtime: $m, tooLarge: true, max: $max}'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if head -c 8192 -- "$f" | grep -qaP '\x00'; then
|
||||||
|
binary=true
|
||||||
|
[ -n "$mime" ] || body=false
|
||||||
|
elif ! iconv -f UTF-8 -t UTF-8 -- "$f" >/dev/null 2>&1; then
|
||||||
|
utf8=false
|
||||||
|
fi
|
||||||
|
sha=$(sha256sum -- "$f" | cut -d' ' -f1)
|
||||||
|
jq -cMn --arg p "$label" --argjson s "$size" --argjson m "$mtime" --arg h "$sha" \
|
||||||
|
--argjson b "$binary" --argjson u "$utf8" --arg mime "$mime" --argjson body "$body" \
|
||||||
|
'{path: $p, size: $s, mtime: $m, sha: $h, binary: $b, utf8: $u, body: $body,
|
||||||
|
mime: (if $mime == "" then null else $mime end)}'
|
||||||
|
printf '%s\n' "$DD_BLOB_BEGIN"
|
||||||
|
if $body; then base64 -w0 -- "$f"; fi
|
||||||
|
printf '\n%s\n' "$DD_BLOB_END"
|
||||||
|
}
|
||||||
|
|
||||||
|
# --fs-list SESSION [REL]: one directory level, folders first, .git skipped.
|
||||||
|
cmd_fs_list() {
|
||||||
|
if [ $# -lt 1 ] || [ $# -gt 2 ]; then dd_die "usage: devdesk attach --fs-list SESSION [PATH]"; fi
|
||||||
|
local root dir rel=${2:-.}
|
||||||
|
root=$(dd_session_root "$1")
|
||||||
|
dir=$(dd_fs_path "$root" "$rel")
|
||||||
|
[ -d "$dir" ] || dd_die "not a folder: $rel"
|
||||||
|
# %y: type, %Y: type behind a symlink, %s: size, %T@: mtime, %f: name.
|
||||||
|
find "$dir" -mindepth 1 -maxdepth 1 ! -name .git -printf '%y\t%Y\t%s\t%T@\t%f\0' 2>/dev/null |
|
||||||
|
head -z -n "$((DEVDESK_FS_LIST_MAX + 1))" |
|
||||||
|
jq -cMRs --arg root "$root" --arg rel "${dir#"$root"}" --argjson max "$DEVDESK_FS_LIST_MAX" '
|
||||||
|
(split("\u0000") | map(select(length > 0) | split("\t") |
|
||||||
|
{t: .[0], to: .[1], s: (.[2] | tonumber), m: (.[3] | tonumber | floor), n: (.[4:] | join("\t"))})) as $all
|
||||||
|
| {root: $root, dir: ($rel | ltrimstr("/")), truncated: ($all | length > $max),
|
||||||
|
entries: ($all[:$max] | sort_by([(if .t == "d" or .to == "d" then 0 else 1 end), (.n | ascii_downcase)]))}'
|
||||||
|
}
|
||||||
|
|
||||||
|
# --fs-read SESSION REL
|
||||||
|
cmd_fs_read() {
|
||||||
|
[ $# -eq 2 ] || dd_die "usage: devdesk attach --fs-read SESSION PATH"
|
||||||
|
local root f
|
||||||
|
root=$(dd_session_root "$1")
|
||||||
|
f=$(dd_fs_path "$root" "$2")
|
||||||
|
[ -f "$f" ] || dd_die "not a file: $2"
|
||||||
|
dd_blob "$f" "${f#"$root"/}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# --git-status SESSION: changed files under the session folder, with line counts
|
||||||
|
# and whether Claude edited them (from devdesk-state-hook's edit log).
|
||||||
|
cmd_git_status() {
|
||||||
|
[ $# -eq 1 ] || dd_die "usage: devdesk attach --git-status SESSION"
|
||||||
|
local root g top prefix branch edits
|
||||||
|
root=$(dd_session_root "$1")
|
||||||
|
edits="$DEVDESK_STATE_DIR/edits/$1.txt"
|
||||||
|
g=(git --no-optional-locks -C "$root")
|
||||||
|
if ! top=$("${g[@]}" rev-parse --show-toplevel 2>/dev/null); then
|
||||||
|
# Not a repository: only what Claude edited.
|
||||||
|
jq -cMn --arg root "$root" --rawfile e <(cat -- "$edits" 2>/dev/null || true) '
|
||||||
|
{git: false, root: $root, files: [$e | split("\n")[] | select(length > 0) | select(startswith($root + "/"))
|
||||||
|
| {path: ltrimstr($root + "/"), x: " ", y: " ", claude: true}]}'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
prefix=$("${g[@]}" rev-parse --show-prefix)
|
||||||
|
branch=$("${g[@]}" symbolic-ref --short -q HEAD || echo "(detached)")
|
||||||
|
{
|
||||||
|
printf 'S\n'
|
||||||
|
"${g[@]}" status --porcelain=v1 -z --untracked-files=all -- . 2>/dev/null | head -z -n 1000 | tr '\0' '\n'
|
||||||
|
printf 'N\n'
|
||||||
|
"${g[@]}" diff --numstat HEAD -- . 2>/dev/null | head -n 1000
|
||||||
|
} | jq -cMRs --arg root "$root" --arg top "$top" --arg prefix "$prefix" --arg branch "$branch" \
|
||||||
|
--rawfile e <(cat -- "$edits" 2>/dev/null || true) '
|
||||||
|
(split("\nN\n") | .[0] | ltrimstr("S\n") | split("\n") | map(select(length > 2))) as $st
|
||||||
|
| (split("\nN\n") | .[1] // "" | split("\n") | map(select(length > 0) | split("\t")
|
||||||
|
| {key: .[2:] | join("\t"), value: {add: (.[0] | tonumber? // null), del: (.[1] | tonumber? // null)}}) | from_entries) as $num
|
||||||
|
| ($e | split("\n") | map(select(length > 0))) as $claude
|
||||||
|
# porcelain -z: "XY path", and after a rename/copy entry the next item is the old path.
|
||||||
|
| reduce range(0; $st | length) as $i ({skip: false, files: []};
|
||||||
|
if .skip then .skip = false
|
||||||
|
else ($st[$i]) as $line | ($line[3:]) as $p
|
||||||
|
| .files += [{repoPath: $p, x: $line[0:1], y: $line[1:2],
|
||||||
|
from: (if ($line[0:1] | test("[RC]")) then $st[$i + 1] else null end)}]
|
||||||
|
| .skip = ($line[0:1] | test("[RC]"))
|
||||||
|
end)
|
||||||
|
| .files | map(. + {path: (if (.repoPath | startswith($prefix)) then .repoPath | ltrimstr($prefix) else null end),
|
||||||
|
add: $num[.repoPath].add, del: $num[.repoPath].del,
|
||||||
|
claude: (($top + "/" + .repoPath) as $abs | any($claude[]; . == $abs))}) as $files
|
||||||
|
| {git: true, root: $root, branch: $branch,
|
||||||
|
files: ($files + [$claude[] | select(startswith($root + "/")) | ltrimstr($root + "/") as $p
|
||||||
|
| select(any($files[]; .path == $p) | not)
|
||||||
|
| {path: $p, repoPath: null, x: " ", y: " ", claude: true}])}'
|
||||||
|
}
|
||||||
|
|
||||||
|
# --git-show SESSION REL: the HEAD version of a file, for diffs. An empty body
|
||||||
|
# when HEAD doesn't have it (new file).
|
||||||
|
cmd_git_show() {
|
||||||
|
[ $# -eq 2 ] || dd_die "usage: devdesk attach --git-show SESSION PATH"
|
||||||
|
local root g top prefix tmp rel=$2
|
||||||
|
root=$(dd_session_root "$1")
|
||||||
|
case $rel in /* | *$'\n'* | *..*) dd_die "bad path: $rel" ;; esac
|
||||||
|
g=(git --no-optional-locks -C "$root")
|
||||||
|
top=$("${g[@]}" rev-parse --show-toplevel 2>/dev/null) || dd_die "not a git repository"
|
||||||
|
prefix=$("${g[@]}" rev-parse --show-prefix)
|
||||||
|
tmp=$(mktemp)
|
||||||
|
"${g[@]}" show "HEAD:$prefix$rel" >"$tmp" 2>/dev/null || : >"$tmp"
|
||||||
|
dd_blob "$tmp" "$rel"
|
||||||
|
rm -f "$tmp"
|
||||||
|
}
|
||||||
|
|
||||||
|
# --asset NAME: a lazily loaded part of the web UI (the file viewer's editor),
|
||||||
|
# shipped in $DEVDESK_ASSETS and cached by the browser.
|
||||||
|
cmd_asset() {
|
||||||
|
if [ $# -ne 1 ] || ! [[ $1 =~ ^[a-z0-9-]+\.js$ ]]; then dd_die "usage: devdesk attach --asset NAME.js"; fi
|
||||||
|
[ -f "$DEVDESK_ASSETS/$1" ] || dd_die "no such asset: $1"
|
||||||
|
dd_blob "$DEVDESK_ASSETS/$1" "$1"
|
||||||
|
}
|
||||||
+15
-1
@@ -43,8 +43,19 @@ DEVDESK_CONTEXT_DIR="$DEVDESK_STATE_DIR/context"
|
|||||||
DEVDESK_STATUS_DIR="$DEVDESK_STATE_DIR/state"
|
DEVDESK_STATUS_DIR="$DEVDESK_STATE_DIR/state"
|
||||||
DEVDESK_NAME_RE='^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$'
|
DEVDESK_NAME_RE='^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$'
|
||||||
|
|
||||||
|
# Under ttyd, a command that exits right after printing sometimes loses its last
|
||||||
|
# output: ttyd sees the exit and closes the WebSocket before reading the pty
|
||||||
|
# (devdesk#35). One-shot replies and errors therefore wait, at most
|
||||||
|
# DEVDESK_LINGER seconds, for the browser to hang up once it has the answer
|
||||||
|
# (ttyd then sends SIGHUP). devdesk-serve sets DEVDESK_VIA_TTYD=1.
|
||||||
|
dd_linger() {
|
||||||
|
[ "${DEVDESK_VIA_TTYD:-}" = 1 ] && [ -t 0 ] || return 0
|
||||||
|
read -r -t "${DEVDESK_LINGER:-1}" _ 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
dd_die() {
|
dd_die() {
|
||||||
printf 'devdesk: %s\n' "$*" >&2
|
printf 'devdesk: %s\n' "$*" >&2
|
||||||
|
dd_linger
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +132,7 @@ dd_registry_set_claude() {
|
|||||||
|
|
||||||
dd_registry_remove() {
|
dd_registry_remove() {
|
||||||
dd_registry_update 'del(.sessions[$n])' --arg n "$1"
|
dd_registry_update 'del(.sessions[$n])' --arg n "$1"
|
||||||
rm -f "$DEVDESK_CONTEXT_DIR/$1.json" "$DEVDESK_STATUS_DIR/$1.json"
|
rm -f "$DEVDESK_CONTEXT_DIR/$1.json" "$DEVDESK_STATUS_DIR/$1.json" "$DEVDESK_STATE_DIR/edits/$1.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
dd_registry_rename() {
|
dd_registry_rename() {
|
||||||
@@ -133,6 +144,9 @@ dd_registry_rename() {
|
|||||||
mv -f "$d/$1.json" "$d/$2.json"
|
mv -f "$d/$1.json" "$d/$2.json"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ -f "$DEVDESK_STATE_DIR/edits/$1.txt" ]; then
|
||||||
|
mv -f "$DEVDESK_STATE_DIR/edits/$1.txt" "$DEVDESK_STATE_DIR/edits/$2.txt"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Project name (directory or its slug) -> absolute directory inside the projects root.
|
# Project name (directory or its slug) -> absolute directory inside the projects root.
|
||||||
|
|||||||
@@ -22,4 +22,7 @@ if [ -n "${DEVDESK_BIND:-}" ]; then
|
|||||||
args+=(--interface "$DEVDESK_BIND")
|
args+=(--interface "$DEVDESK_BIND")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Tells `devdesk attach` it talks to a browser through ttyd (see dd_linger).
|
||||||
|
export DEVDESK_VIA_TTYD=1
|
||||||
|
|
||||||
exec "${DEVDESK_TTYD:-/usr/lib/devdesk/bin/ttyd}" "${args[@]}" "${DEVDESK_BIN:-/usr/bin/devdesk}" attach
|
exec "${DEVDESK_TTYD:-/usr/lib/devdesk/bin/ttyd}" "${args[@]}" "${DEVDESK_BIN:-/usr/bin/devdesk}" attach
|
||||||
|
|||||||
@@ -16,7 +16,23 @@ outer=${TMUX:-}
|
|||||||
session=$(tmux display-message -p -t "$TMUX_PANE" '#S' 2>/dev/null)
|
session=$(tmux display-message -p -t "$TMUX_PANE" '#S' 2>/dev/null)
|
||||||
[[ $session =~ ^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$ ]] || exit 0
|
[[ $session =~ ^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$ ]] || exit 0
|
||||||
|
|
||||||
IFS=$'\t' read -r event message < <(jq -rM '[.hook_event_name // "", (.message // "" | gsub("[\t\n]"; " "))] | @tsv' <<<"$input" 2>/dev/null)
|
# Unit separator, not tab: read collapses runs of whitespace delimiters, so an
|
||||||
|
# empty field would shift the ones after it.
|
||||||
|
IFS=$'\x1f' read -r event message tool file < <(jq -rM '[.hook_event_name // "", (.message // "" | gsub("[\u001f\n]"; " ")),
|
||||||
|
.tool_name // "", (.tool_input.file_path // .tool_input.notebook_path // "" | gsub("[\u001f\n]"; " "))] | join("\u001f")' <<<"$input" 2>/dev/null)
|
||||||
|
|
||||||
|
# Files Claude edits, for the file viewer's "Claude" badge (devdesk#19).
|
||||||
|
case $event:$tool in
|
||||||
|
PostToolUse:Edit | PostToolUse:Write | PostToolUse:MultiEdit | PostToolUse:NotebookEdit)
|
||||||
|
if [[ $file == /* ]]; then
|
||||||
|
log="${DEVDESK_STATE_DIR:-/var/lib/devdesk}/edits/$session.txt"
|
||||||
|
mkdir -p "${log%/*}" 2>/dev/null
|
||||||
|
if ! grep -qxF -- "$file" "$log" 2>/dev/null && [ "$(wc -l <"$log" 2>/dev/null || echo 0)" -lt 1000 ]; then
|
||||||
|
printf '%s\n' "$file" >>"$log"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
case $event in
|
case $event in
|
||||||
UserPromptSubmit | PostToolUse) state=working ;;
|
UserPromptSubmit | PostToolUse) state=working ;;
|
||||||
Notification) state=waiting ;;
|
Notification) state=waiting ;;
|
||||||
|
|||||||
@@ -38,12 +38,13 @@ if [[ $session =~ ^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$ ]]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Footer line, in TDS colours: session · model · context % · cost
|
# Footer line: session · model · context % · cost. ANSI colour numbers, not RGB,
|
||||||
|
# so the browser's dark or light palette applies (devdesk#31).
|
||||||
jq -rM --arg s "$session" '
|
jq -rM --arg s "$session" '
|
||||||
def c($rgb; $t): "\u001b[38;2;\($rgb)m\($t)\u001b[0m";
|
def c($sgr; $t): "\u001b[\($sgr)m\($t)\u001b[0m";
|
||||||
def pct: if . == null then "—" else "\(. | floor)%" end;
|
def pct: if . == null then "—" else "\(. | floor)%" end;
|
||||||
[ (if $s != "" then c("255;107;0"; "◈ \($s)") else empty end),
|
[ (if $s != "" then c("33"; "◈ \($s)") else empty end),
|
||||||
c("0;212;255"; .model.display_name // "Claude"),
|
c("36"; .model.display_name // "Claude"),
|
||||||
c("127;163;191"; "ctx \(.context_window.used_percentage | pct)"),
|
c("37"; "ctx \(.context_window.used_percentage | pct)"),
|
||||||
c("62;96;122"; "$\((.cost.total_cost_usd // 0) * 100 | round / 100)")
|
c("37"; "$\((.cost.total_cost_usd // 0) * 100 | round / 100)")
|
||||||
] | join(c("62;96;122"; " · "))' <<<"$input" 2>/dev/null || true
|
] | join(c("90"; " · "))' <<<"$input" 2>/dev/null || true
|
||||||
|
|||||||
Generated
+329
-1
@@ -7,20 +7,215 @@
|
|||||||
"name": "devdesk",
|
"name": "devdesk",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@codemirror/commands": "6.11.1",
|
||||||
|
"@codemirror/lang-markdown": "6.5.2",
|
||||||
|
"@codemirror/language": "6.13.1",
|
||||||
|
"@codemirror/legacy-modes": "6.5.5",
|
||||||
|
"@codemirror/merge": "6.12.2",
|
||||||
|
"@codemirror/search": "6.7.2",
|
||||||
|
"@codemirror/state": "6.7.6",
|
||||||
|
"@codemirror/view": "6.43.14",
|
||||||
"@fontsource/jetbrains-mono": "5.3.0",
|
"@fontsource/jetbrains-mono": "5.3.0",
|
||||||
|
"@lezer/highlight": "1.2.5",
|
||||||
"@xterm/addon-clipboard": "0.2.0",
|
"@xterm/addon-clipboard": "0.2.0",
|
||||||
"@xterm/addon-fit": "0.11.0",
|
"@xterm/addon-fit": "0.11.0",
|
||||||
"@xterm/addon-unicode11": "0.9.0",
|
"@xterm/addon-unicode11": "0.9.0",
|
||||||
"@xterm/addon-web-links": "0.12.0",
|
"@xterm/addon-web-links": "0.12.0",
|
||||||
"@xterm/addon-webgl": "0.19.0",
|
"@xterm/addon-webgl": "0.19.0",
|
||||||
"@xterm/xterm": "6.0.0",
|
"@xterm/xterm": "6.0.0",
|
||||||
|
"dompurify": "3.4.16",
|
||||||
"esbuild": "0.28.2",
|
"esbuild": "0.28.2",
|
||||||
"eslint": "8.57.1"
|
"eslint": "8.57.1",
|
||||||
|
"marked": "18.1.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@codemirror/autocomplete": {
|
||||||
|
"version": "6.20.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.3.tgz",
|
||||||
|
"integrity": "sha512-tlosUqb+3BbxCxZdu4tKeRghPFC+QM7q4X5YhKV2eCmPG+1r2F3f4AaSz5sCrFqUtX4Jh20VFTKecl16MgiV9g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/language": "^6.0.0",
|
||||||
|
"@codemirror/state": "^6.0.0",
|
||||||
|
"@codemirror/view": "^6.17.0",
|
||||||
|
"@lezer/common": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/commands": {
|
||||||
|
"version": "6.11.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.11.1.tgz",
|
||||||
|
"integrity": "sha512-O/4hG3SC1YwcmQ0d2UVNDs+AsaNWd1iHVxbTeEBuqH+6bExAiPK3iS/BvpY6rZGURALv4ZD3sIgcCmRvw3ehBg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/language": "^6.0.0",
|
||||||
|
"@codemirror/state": "^6.7.0",
|
||||||
|
"@codemirror/view": "^6.27.0",
|
||||||
|
"@lezer/common": "^1.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/lang-css": {
|
||||||
|
"version": "6.3.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz",
|
||||||
|
"integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/autocomplete": "^6.0.0",
|
||||||
|
"@codemirror/language": "^6.0.0",
|
||||||
|
"@codemirror/state": "^6.0.0",
|
||||||
|
"@lezer/common": "^1.0.2",
|
||||||
|
"@lezer/css": "^1.1.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/lang-html": {
|
||||||
|
"version": "6.4.12",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.12.tgz",
|
||||||
|
"integrity": "sha512-pw2ReWKUqSkbvh76RAT4NYxiogRu+PWkR2ukAwO9uOgrm8uipkzjtKKtNpyeAQwHOqxEeSvAXZ6vr3AfyB9y/w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/autocomplete": "^6.0.0",
|
||||||
|
"@codemirror/lang-css": "^6.0.0",
|
||||||
|
"@codemirror/lang-javascript": "^6.0.0",
|
||||||
|
"@codemirror/language": "^6.4.0",
|
||||||
|
"@codemirror/state": "^6.0.0",
|
||||||
|
"@codemirror/view": "^6.17.0",
|
||||||
|
"@lezer/common": "^1.0.0",
|
||||||
|
"@lezer/css": "^1.1.0",
|
||||||
|
"@lezer/html": "^1.3.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/lang-javascript": {
|
||||||
|
"version": "6.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.5.tgz",
|
||||||
|
"integrity": "sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/autocomplete": "^6.0.0",
|
||||||
|
"@codemirror/language": "^6.6.0",
|
||||||
|
"@codemirror/lint": "^6.0.0",
|
||||||
|
"@codemirror/state": "^6.0.0",
|
||||||
|
"@codemirror/view": "^6.17.0",
|
||||||
|
"@lezer/common": "^1.0.0",
|
||||||
|
"@lezer/javascript": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/lang-markdown": {
|
||||||
|
"version": "6.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.5.2.tgz",
|
||||||
|
"integrity": "sha512-AwBOdkWYuA//WcM0xO5PfHPUcmz/O2i5o0Nsg1U69SII/loCJlFI1Romd9xp2HYb1kYJRGZotyqRghuHH5n8Kw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/autocomplete": "^6.7.1",
|
||||||
|
"@codemirror/lang-html": "^6.0.0",
|
||||||
|
"@codemirror/language": "^6.3.0",
|
||||||
|
"@codemirror/state": "^6.0.0",
|
||||||
|
"@codemirror/view": "^6.0.0",
|
||||||
|
"@lezer/common": "^1.2.1",
|
||||||
|
"@lezer/markdown": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/language": {
|
||||||
|
"version": "6.13.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.13.1.tgz",
|
||||||
|
"integrity": "sha512-zfvU2r3TyylQLMj/te+5CnQ0rSqZi8B1oTCBbQkagcLW4Xc6imab6qN+pEJhsuNOLaJqiRyBXp9UhWA1DhVvDw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/state": "^6.0.0",
|
||||||
|
"@codemirror/streamparser": "^6.0.0",
|
||||||
|
"@codemirror/view": "^6.23.0",
|
||||||
|
"@lezer/common": "^1.5.0",
|
||||||
|
"@lezer/highlight": "^1.0.0",
|
||||||
|
"@lezer/lr": "^1.0.0",
|
||||||
|
"style-mod": "^4.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/legacy-modes": {
|
||||||
|
"version": "6.5.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/legacy-modes/-/legacy-modes-6.5.5.tgz",
|
||||||
|
"integrity": "sha512-9ltT214oMb3Y1w5eAZMSigzrjzZnMI2Wa3Feq73rU/i4C56MkwrpfswfQYOr28C5pXr6dWwspNTMyeHXlzWMxg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/streamparser": "^6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/lint": {
|
||||||
|
"version": "6.9.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.7.tgz",
|
||||||
|
"integrity": "sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/state": "^6.0.0",
|
||||||
|
"@codemirror/view": "^6.42.0",
|
||||||
|
"crelt": "^1.0.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/merge": {
|
||||||
|
"version": "6.12.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/merge/-/merge-6.12.2.tgz",
|
||||||
|
"integrity": "sha512-V8JvyAPjHbPupqP7BeMcsdsYCbyPij74jxIbaIJDORI+VZzW44zFmon8bF+oxGWvOKhcRmkiUMXd8MxHr3YA2w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/language": "^6.0.0",
|
||||||
|
"@codemirror/state": "^6.0.0",
|
||||||
|
"@codemirror/view": "^6.17.0",
|
||||||
|
"@lezer/highlight": "^1.0.0",
|
||||||
|
"style-mod": "^4.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/search": {
|
||||||
|
"version": "6.7.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.7.2.tgz",
|
||||||
|
"integrity": "sha512-gUYkYhT2+n/+VGZ+8EzE5WFkYZUZYm1VOKDudIsNqh42uRVQJ0a6Yss9sdKT3MeOYfuL1N6AZA57oza0Oyr0LA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/state": "^6.0.0",
|
||||||
|
"@codemirror/view": "^6.37.0",
|
||||||
|
"crelt": "^1.0.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/state": {
|
||||||
|
"version": "6.7.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.6.tgz",
|
||||||
|
"integrity": "sha512-kAz+AncRtKuIknedxT1bq4XwXv4UowhbkHU1myPrtVb/jZtImWuV5BXzv5vK6i3kYACsdiZiQKFQQ5Mq7elW8w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@marijn/find-cluster-break": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/streamparser": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/streamparser/-/streamparser-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-JTFPF6xrfjt0mnfGPgzcLiMwYmvIyNaoizp8BYzv8FE8KrT6GBGDZ190rtt+O7Wke3gG/MFHyiY9YGNeimof4w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@codemirror/view": {
|
||||||
|
"version": "6.43.14",
|
||||||
|
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.14.tgz",
|
||||||
|
"integrity": "sha512-hC45YnmJNR1rz42OF57BLoQNFMV12/13drnvibDsR2quNDmldcb4WvYVV81hFQg56i9lcqQMEDqilhX2QDcGQQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@codemirror/state": "^6.7.0",
|
||||||
|
"crelt": "^1.0.6",
|
||||||
|
"style-mod": "^4.1.0",
|
||||||
|
"w3c-keyname": "^2.2.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@esbuild/aix-ppc64": {
|
"node_modules/@esbuild/aix-ppc64": {
|
||||||
"version": "0.28.2",
|
"version": "0.28.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz",
|
||||||
@@ -574,6 +769,87 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-3-Clause"
|
"license": "BSD-3-Clause"
|
||||||
},
|
},
|
||||||
|
"node_modules/@lezer/common": {
|
||||||
|
"version": "1.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.3.tgz",
|
||||||
|
"integrity": "sha512-H0iErY4e43LpXbYDyBci5W4v/RwTgGV3YzYOlJPiGZ8RY8w51kVE+xLn1tg3Z6UmSfyETvtsUK3r7YsgDQEI7Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@lezer/css": {
|
||||||
|
"version": "1.3.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.9.tgz",
|
||||||
|
"integrity": "sha512-ZmzgvTOBdJWGIsY/ItAfN7UW8DV802oZG+jeG6E508SwEzz5YhuAajptpWPICvIyqYAD2+VjMdOS40GgGkyEOQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@lezer/common": "^1.2.0",
|
||||||
|
"@lezer/highlight": "^1.0.0",
|
||||||
|
"@lezer/lr": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@lezer/highlight": {
|
||||||
|
"version": "1.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.5.tgz",
|
||||||
|
"integrity": "sha512-O1GMVKgtf5YspFaRzpmqkVgMtIk2HG9uMAbH6wdAIdNh3TVzCsch/+cRi+6l2//UGDKe6NB9BW3cvuR5ezMQ0w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@lezer/common": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@lezer/html": {
|
||||||
|
"version": "1.3.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz",
|
||||||
|
"integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@lezer/common": "^1.2.0",
|
||||||
|
"@lezer/highlight": "^1.0.0",
|
||||||
|
"@lezer/lr": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@lezer/javascript": {
|
||||||
|
"version": "1.5.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.6.tgz",
|
||||||
|
"integrity": "sha512-sEvOqpl4vJQca0NugSQK02vQPbc5KrvoojnYGoqqFgFO0MtcYhwGiHKVEB+LuXYJnfyXo4QPA8ztbrEa4Fw5NA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@lezer/common": "^1.2.0",
|
||||||
|
"@lezer/highlight": "^1.1.3",
|
||||||
|
"@lezer/lr": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@lezer/lr": {
|
||||||
|
"version": "1.4.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.11.tgz",
|
||||||
|
"integrity": "sha512-UwgZcl1R66H2hDzBrA7kWyYmX6s8p5TQ+e/t7CuvgCtBEPxbEPaHYHu+pJBvTvDotEJpuQkJjbXuHiw5Cixxgw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@lezer/common": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@lezer/markdown": {
|
||||||
|
"version": "1.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.8.0.tgz",
|
||||||
|
"integrity": "sha512-X6w3A2NpyhdtGqTWRJB8gR4QDXBaFMbTOs780ZdZ15KKCfBXOQTKcB3Vr+W6tqJHVlealt53tLmHRvOqPTQgYA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@lezer/common": "^1.5.0",
|
||||||
|
"@lezer/highlight": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@marijn/find-cluster-break": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.4.tgz",
|
||||||
|
"integrity": "sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@nodelib/fs.scandir": {
|
"node_modules/@nodelib/fs.scandir": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||||
@@ -612,6 +888,14 @@
|
|||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/trusted-types": {
|
||||||
|
"version": "2.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||||
|
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"node_modules/@ungap/structured-clone": {
|
"node_modules/@ungap/structured-clone": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.4.0.tgz",
|
||||||
@@ -812,6 +1096,13 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/crelt": {
|
||||||
|
"version": "1.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz",
|
||||||
|
"integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||||
@@ -865,6 +1156,16 @@
|
|||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/dompurify": {
|
||||||
|
"version": "3.4.16",
|
||||||
|
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.16.tgz",
|
||||||
|
"integrity": "sha512-sqo+pNp3qRhCIpbgRi1y8Tgk27Bo2Ry7w0dC1NBeNTdZChWjz9Xb/KOoZbRP/R6pQZ80Qw8YhXw13hWWBbMRnQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||||
|
"optionalDependencies": {
|
||||||
|
"@types/trusted-types": "^2.0.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/esbuild": {
|
"node_modules/esbuild": {
|
||||||
"version": "0.28.2",
|
"version": "0.28.2",
|
||||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
|
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz",
|
||||||
@@ -1423,6 +1724,19 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/marked": {
|
||||||
|
"version": "18.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/marked/-/marked-18.1.0.tgz",
|
||||||
|
"integrity": "sha512-PamYXWWWg2nboG3oX5Ffzpy3EFZROqZJK9hSlMmUnekp7TxPs5DcT95vwd46m73/exfKCRVMtgXoPMI4FEJL6w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"marked": "bin/marked.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 20"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/minimatch": {
|
"node_modules/minimatch": {
|
||||||
"version": "3.1.5",
|
"version": "3.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
|
||||||
@@ -1705,6 +2019,13 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/style-mod": {
|
||||||
|
"version": "4.1.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.4.tgz",
|
||||||
|
"integrity": "sha512-XXWIQt633/EpAFx8aZDOTjBzrCaGmhvEQlQo6MVPfa2OzO2cWo+4hV9h+6UkHYlXGfy+ODXKUdP7Pthmcu5ATw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/supports-color": {
|
"node_modules/supports-color": {
|
||||||
"version": "7.2.0",
|
"version": "7.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
|
||||||
@@ -1761,6 +2082,13 @@
|
|||||||
"punycode": "^2.1.0"
|
"punycode": "^2.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/w3c-keyname": {
|
||||||
|
"version": "2.2.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",
|
||||||
|
"integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/which": {
|
"node_modules/which": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||||
|
|||||||
+16
-3
@@ -4,21 +4,34 @@
|
|||||||
"description": "Persistent browser terminal for Claude Code (ttyd + tmux), LotusGuild TDS styling",
|
"description": "Persistent browser terminal for Claude Code (ttyd + tmux), LotusGuild TDS styling",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": { "node": ">=18" },
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node web/build.mjs",
|
"build": "node web/build.mjs",
|
||||||
"lint": "eslint --ext .js,.mjs web/src web/build.mjs tests/protocol.test.mjs",
|
"lint": "eslint --ext .js,.mjs web/src web/editor web/build.mjs tests/protocol.test.mjs",
|
||||||
"test": "node --test tests/*.test.mjs"
|
"test": "node --test tests/*.test.mjs"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@codemirror/commands": "6.11.1",
|
||||||
|
"@codemirror/lang-markdown": "6.5.2",
|
||||||
|
"@codemirror/language": "6.13.1",
|
||||||
|
"@codemirror/legacy-modes": "6.5.5",
|
||||||
|
"@codemirror/merge": "6.12.2",
|
||||||
|
"@codemirror/search": "6.7.2",
|
||||||
|
"@codemirror/state": "6.7.6",
|
||||||
|
"@codemirror/view": "6.43.14",
|
||||||
"@fontsource/jetbrains-mono": "5.3.0",
|
"@fontsource/jetbrains-mono": "5.3.0",
|
||||||
|
"@lezer/highlight": "1.2.5",
|
||||||
"@xterm/addon-clipboard": "0.2.0",
|
"@xterm/addon-clipboard": "0.2.0",
|
||||||
"@xterm/addon-fit": "0.11.0",
|
"@xterm/addon-fit": "0.11.0",
|
||||||
"@xterm/addon-unicode11": "0.9.0",
|
"@xterm/addon-unicode11": "0.9.0",
|
||||||
"@xterm/addon-web-links": "0.12.0",
|
"@xterm/addon-web-links": "0.12.0",
|
||||||
"@xterm/addon-webgl": "0.19.0",
|
"@xterm/addon-webgl": "0.19.0",
|
||||||
"@xterm/xterm": "6.0.0",
|
"@xterm/xterm": "6.0.0",
|
||||||
|
"dompurify": "3.4.16",
|
||||||
"esbuild": "0.28.2",
|
"esbuild": "0.28.2",
|
||||||
"eslint": "8.57.1"
|
"eslint": "8.57.1",
|
||||||
|
"marked": "18.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"preferredNotifChannel": "terminal_bell",
|
"preferredNotifChannel": "terminal_bell",
|
||||||
|
"theme": "dark-ansi",
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"SessionStart": [
|
"SessionStart": [
|
||||||
{
|
{
|
||||||
|
|||||||
+12
-9
@@ -24,18 +24,21 @@ set -g set-titles-string "devdesk:#S|#T"
|
|||||||
# --- every new session gets a spare shell next to Claude ---------------------
|
# --- every new session gets a spare shell next to Claude ---------------------
|
||||||
set-hook -g session-created "new-window -d -n shell"
|
set-hook -g session-created "new-window -d -n shell"
|
||||||
|
|
||||||
# --- LotusGuild TDS colours ---------------------------------------------------
|
# --- colours ---------------------------------------------------------------------
|
||||||
|
# ANSI colour names, not hex: the browser maps them through its dark or light
|
||||||
|
# palette, so the status bar follows DevDesk's theme (devdesk#31). black is the
|
||||||
|
# bar, white muted text, cyan the accent, yellow the session name.
|
||||||
set -g status-position bottom
|
set -g status-position bottom
|
||||||
set -g status-style "bg=#060c14,fg=#7fa3bf"
|
set -g status-style "bg=black,fg=white"
|
||||||
set -g status-left "#[fg=#FF6B00,bold] #S #[fg=#3e607a,nobold]│ "
|
set -g status-left "#[fg=yellow,bold] #S #[fg=brightblack,nobold]│ "
|
||||||
set -g status-left-length 40
|
set -g status-left-length 40
|
||||||
set -g status-right ""
|
set -g status-right ""
|
||||||
set -g window-status-format " #I:#W "
|
set -g window-status-format " #I:#W "
|
||||||
set -g window-status-current-format "#[fg=#030508,bg=#00D4FF,bold] #I:#W "
|
set -g window-status-current-format "#[fg=cyan,reverse,bold] #I:#W "
|
||||||
set -g window-status-bell-style "fg=#FFB300,bold"
|
set -g window-status-bell-style "fg=yellow,bold"
|
||||||
set -g message-style "bg=#0d1520,fg=#00D4FF"
|
set -g message-style "bg=black,fg=cyan"
|
||||||
set -g mode-style "bg=#00D4FF,fg=#030508"
|
set -g mode-style "fg=cyan,reverse"
|
||||||
set -g pane-border-style "fg=#0d1520"
|
set -g pane-border-style "fg=brightblack"
|
||||||
set -g pane-active-border-style "fg=#00D4FF"
|
set -g pane-active-border-style "fg=cyan"
|
||||||
|
|
||||||
source-file -q /etc/devdesk/tmux.local.conf
|
source-file -q /etc/devdesk/tmux.local.conf
|
||||||
|
|||||||
@@ -327,6 +327,25 @@ posts() { [ -f "$TMP/posts" ] && wc -l <"$TMP/posts" || echo 0; }
|
|||||||
kill "$RECEIVER"
|
kill "$RECEIVER"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "under ttyd, one-shot replies wait for the browser to hang up (#35)" {
|
||||||
|
start_server
|
||||||
|
# No tty (CLI, tests): no waiting.
|
||||||
|
start=$(date +%s%N)
|
||||||
|
DEVDESK_VIA_TTYD=1 DEVDESK_LINGER=2 devdesk attach --list >/dev/null
|
||||||
|
[ $(( ($(date +%s%N) - start) / 1000000 )) -lt 1500 ]
|
||||||
|
# On a tty, as under ttyd: the reply is printed, then it waits. script's
|
||||||
|
# stdin stays open (like a browser that hasn't hung up); a closed stdin
|
||||||
|
# would hand the command EOF at once.
|
||||||
|
start=$(date +%s%N)
|
||||||
|
run bash -c "sleep 2 | script -qec \"DEVDESK_VIA_TTYD=1 DEVDESK_LINGER=0.6 '$REPO/bin/devdesk' attach --list\" /dev/null"
|
||||||
|
elapsed=$(( ($(date +%s%N) - start) / 1000000 ))
|
||||||
|
[[ $output == *'"sessions"'* ]]
|
||||||
|
[ "$elapsed" -ge 500 ]
|
||||||
|
# Errors are printed before the wait, too.
|
||||||
|
run bash -c "sleep 1 | script -qec \"DEVDESK_VIA_TTYD=1 DEVDESK_LINGER=0.3 '$REPO/bin/devdesk' attach --rename nosuch x\" /dev/null"
|
||||||
|
[[ $output == *"no session named"* ]]
|
||||||
|
}
|
||||||
|
|
||||||
@test "alerts reports unconfigured and unreachable Grafana cleanly" {
|
@test "alerts reports unconfigured and unreachable Grafana cleanly" {
|
||||||
run env DEVDESK_GRAFANA_URL= devdesk alerts
|
run env DEVDESK_GRAFANA_URL= devdesk alerts
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
@@ -472,3 +491,106 @@ posts() { [ -f "$TMP/posts" ] && wc -l <"$TMP/posts" || echo 0; }
|
|||||||
run claude_args alpha
|
run claude_args alpha
|
||||||
[ "$output" = "-n alpha --settings $REPO/share/claude-settings.json --remote-control devdesk-alpha" ]
|
[ "$output" = "-n alpha --settings $REPO/share/claude-settings.json --remote-control devdesk-alpha" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Decode a blob reply (header line, base64 between markers) into $TMP/blob.
|
||||||
|
blob_body() {
|
||||||
|
sed -n '/^DEVDESK-BLOB-BEGIN$/,/^DEVDESK-BLOB-END$/p' <<<"$1" | sed '1d;$d' | base64 -d >"$TMP/blob"
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "fs-list lists one level, folders first, and stays inside the session folder (#19)" {
|
||||||
|
p="$DEVDESK_PROJECTS_ROOT/alpha"
|
||||||
|
mkdir -p "$p/src/deep" "$p/.git"
|
||||||
|
echo hi >"$p/README.md"
|
||||||
|
echo x >"$p/src/a.sh"
|
||||||
|
ln -s "$TMP/outside" "$p/escape-link"
|
||||||
|
ln -s src "$p/src-link"
|
||||||
|
run devdesk attach --fs-list alpha
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
# Folders first (a symlink to a folder counts, even one that escapes: opening it fails).
|
||||||
|
[ "$(jq -r '[.entries[].n] | join(",")' <<<"$output")" = "escape-link,src,src-link,README.md" ]
|
||||||
|
run devdesk attach --fs-list alpha src
|
||||||
|
[ "$(jq -r '.dir + ":" + ([.entries[].n] | join(","))' <<<"$output")" = "src:deep,a.sh" ]
|
||||||
|
for bad in ../ /etc escape-link "src/../../alpha/../../outside"; do
|
||||||
|
run devdesk attach --fs-list alpha "$bad"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
done
|
||||||
|
run devdesk attach --fs-list alpha src-link
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "fs-read returns text, images and refuses binaries, big files and escapes (#19)" {
|
||||||
|
p="$DEVDESK_PROJECTS_ROOT/alpha"
|
||||||
|
printf 'line 1\r\nüñí\n' >"$p/notes.md"
|
||||||
|
printf '\x89PNG\r\n\x1a\n\0\0\0' >"$p/pic.png"
|
||||||
|
head -c 100 /dev/zero >"$p/blob.bin"
|
||||||
|
head -c 3000 /dev/zero | tr '\0' a >"$p/big.txt"
|
||||||
|
run devdesk attach --fs-read alpha notes.md
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(head -n1 <<<"$output" | jq -r '[.path, .binary, .utf8, .body] | @tsv')" = "$(printf 'notes.md\tfalse\ttrue\ttrue')" ]
|
||||||
|
blob_body "$output"
|
||||||
|
cmp "$TMP/blob" "$p/notes.md"
|
||||||
|
run devdesk attach --fs-read alpha pic.png
|
||||||
|
[ "$(head -n1 <<<"$output" | jq -r '[.mime, .body] | @tsv')" = "$(printf 'image/png\ttrue')" ]
|
||||||
|
run devdesk attach --fs-read alpha blob.bin
|
||||||
|
[ "$(head -n1 <<<"$output" | jq -r '[.binary, .body] | @tsv')" = "$(printf 'true\tfalse')" ]
|
||||||
|
run env DEVDESK_FS_MAX=1000 "$REPO/bin/devdesk" attach --fs-read alpha big.txt
|
||||||
|
[ "$(head -n1 <<<"$output" | jq -r '.tooLarge')" = true ]
|
||||||
|
run devdesk attach --fs-read alpha ../alpha/../../outside
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "git-status and git-show report changes, line counts and Claude's edits (#19)" {
|
||||||
|
p="$DEVDESK_PROJECTS_ROOT/alpha"
|
||||||
|
git -C "$p" init -q -b main
|
||||||
|
git -C "$p" -c user.name=t -c user.email=t@t commit -q --allow-empty -m init
|
||||||
|
printf 'one\ntwo\n' >"$p/kept.txt"
|
||||||
|
printf 'old\n' >"$p/moved.txt"
|
||||||
|
git -C "$p" add . && git -C "$p" -c user.name=t -c user.email=t@t commit -q -m files
|
||||||
|
printf 'one\nTWO\nthree\n' >"$p/kept.txt"
|
||||||
|
git -C "$p" mv moved.txt renamed.txt
|
||||||
|
echo new >"$p/fresh.txt"
|
||||||
|
mkdir -p "$DEVDESK_STATE_DIR/edits"
|
||||||
|
printf '%s\n' "$p/kept.txt" "$p/notes-outside-git.txt" >"$DEVDESK_STATE_DIR/edits/alpha.txt"
|
||||||
|
run devdesk attach --git-status alpha
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[ "$(jq -r '.files | map("\(.x)\(.y) \(.path) +\(.add) -\(.del) \(.claude)") | sort | join("|")' <<<"$output")" = \
|
||||||
|
" notes-outside-git.txt +null -null true| M kept.txt +2 -1 true|?? fresh.txt +null -null false|R renamed.txt +null -null false" ]
|
||||||
|
[ "$(jq -r '.files[] | select(.path == "renamed.txt") | .from' <<<"$output")" = moved.txt ]
|
||||||
|
run devdesk attach --git-show alpha kept.txt
|
||||||
|
blob_body "$output"
|
||||||
|
[ "$(cat "$TMP/blob")" = "$(printf 'one\ntwo')" ]
|
||||||
|
run devdesk attach --git-show alpha fresh.txt
|
||||||
|
[ "$(head -n1 <<<"$output" | jq -r '.size')" = 0 ]
|
||||||
|
run devdesk attach --git-status alpha
|
||||||
|
run env DEVDESK_PROJECTS_ROOT="$TMP/outside" "$REPO/bin/devdesk" attach --git-status alpha
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "the state hook logs Claude's edits; rename moves and end removes the log (#19)" {
|
||||||
|
start_server
|
||||||
|
devdesk new alpha
|
||||||
|
pane=$(tmux -S "$DEVDESK_SOCKET" display -p -t =alpha:shell '#{pane_id}')
|
||||||
|
hook() { TMUX="$DEVDESK_SOCKET,1,0" TMUX_PANE="$pane" "$REPO/libexec/devdesk-state-hook"; }
|
||||||
|
echo '{"hook_event_name":"PostToolUse","tool_name":"Edit","tool_input":{"file_path":"/x/a.txt"}}' | hook
|
||||||
|
echo '{"hook_event_name":"PostToolUse","tool_name":"Write","tool_input":{"file_path":"/x/a.txt"}}' | hook
|
||||||
|
echo '{"hook_event_name":"PostToolUse","tool_name":"Bash","tool_input":{"command":"ls"}}' | hook
|
||||||
|
echo '{"hook_event_name":"PostToolUse","tool_name":"NotebookEdit","tool_input":{"notebook_path":"/x/n.ipynb"}}' | hook
|
||||||
|
[ "$(cat "$DEVDESK_STATE_DIR/edits/alpha.txt")" = "$(printf '/x/a.txt\n/x/n.ipynb')" ]
|
||||||
|
devdesk rename alpha beta
|
||||||
|
[ -f "$DEVDESK_STATE_DIR/edits/beta.txt" ] && [ ! -e "$DEVDESK_STATE_DIR/edits/alpha.txt" ]
|
||||||
|
devdesk end beta
|
||||||
|
[ ! -e "$DEVDESK_STATE_DIR/edits/beta.txt" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "asset serves only named .js files from the assets folder (#19)" {
|
||||||
|
mkdir -p "$TMP/assets"
|
||||||
|
echo 'window.X = 1;' >"$TMP/assets/editor.js"
|
||||||
|
run env DEVDESK_ASSETS="$TMP/assets" "$REPO/bin/devdesk" attach --asset editor.js
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
blob_body "$output"
|
||||||
|
cmp "$TMP/blob" "$TMP/assets/editor.js"
|
||||||
|
for bad in ../etc/passwd editor.css nope.js; do
|
||||||
|
run env DEVDESK_ASSETS="$TMP/assets" "$REPO/bin/devdesk" attach --asset "$bad"
|
||||||
|
[ "$status" -ne 0 ]
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|||||||
+27
-1
@@ -2,6 +2,7 @@
|
|||||||
// file and nothing else), with CSS, JS, fonts and the favicon all inlined.
|
// file and nothing else), with CSS, JS, fonts and the favicon all inlined.
|
||||||
import { build, transform } from 'esbuild';
|
import { build, transform } from 'esbuild';
|
||||||
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
import { readFile, writeFile, mkdir } from 'node:fs/promises';
|
||||||
|
import { createHash } from 'node:crypto';
|
||||||
import { dirname, join } from 'node:path';
|
import { dirname, join } from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
@@ -33,8 +34,29 @@ async function fontFaces(weights) {
|
|||||||
return faces.join('\n');
|
return faces.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The file viewer's editor (devdesk#19): its own IIFE, served over the ttyd
|
||||||
|
// channel by `devdesk attach --asset editor.js` and cached by the browser. The
|
||||||
|
// page carries its SHA-256, which is both the integrity check and the cache key.
|
||||||
|
async function editorBundle() {
|
||||||
|
const out = await build({
|
||||||
|
entryPoints: [at('web', 'editor', 'index.js')],
|
||||||
|
bundle: true,
|
||||||
|
minify: true,
|
||||||
|
format: 'iife',
|
||||||
|
globalName: 'DevDeskEditor',
|
||||||
|
target: ['es2020'],
|
||||||
|
write: false,
|
||||||
|
legalComments: 'eof',
|
||||||
|
});
|
||||||
|
const code = out.outputFiles[0].text;
|
||||||
|
await mkdir(at('dist', 'assets'), { recursive: true });
|
||||||
|
await writeFile(at('dist', 'assets', 'editor.js'), code);
|
||||||
|
return { sha: createHash('sha256').update(code).digest('hex'), size: Buffer.byteLength(code) };
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const ver = await version();
|
const ver = await version();
|
||||||
|
const editor = await editorBundle();
|
||||||
|
|
||||||
const js = await build({
|
const js = await build({
|
||||||
entryPoints: [at('web', 'src', 'main.js')],
|
entryPoints: [at('web', 'src', 'main.js')],
|
||||||
@@ -44,7 +66,10 @@ async function main() {
|
|||||||
target: ['es2020'],
|
target: ['es2020'],
|
||||||
write: false,
|
write: false,
|
||||||
legalComments: 'eof',
|
legalComments: 'eof',
|
||||||
define: { __DEVDESK_VERSION__: JSON.stringify(ver) },
|
define: {
|
||||||
|
__DEVDESK_VERSION__: JSON.stringify(ver),
|
||||||
|
__EDITOR_SHA__: JSON.stringify(editor.sha),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const css = await transform([
|
const css = await transform([
|
||||||
@@ -67,6 +92,7 @@ async function main() {
|
|||||||
await mkdir(at('dist'), { recursive: true });
|
await mkdir(at('dist'), { recursive: true });
|
||||||
await writeFile(at('dist', 'index.html'), html);
|
await writeFile(at('dist', 'index.html'), html);
|
||||||
console.log(`dist/index.html ${(html.length / 1024).toFixed(0)} KiB (devdesk ${ver})`);
|
console.log(`dist/index.html ${(html.length / 1024).toFixed(0)} KiB (devdesk ${ver})`);
|
||||||
|
console.log(`dist/assets/editor.js ${(editor.size / 1024).toFixed(0)} KiB sha256 ${editor.sha.slice(0, 12)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((err) => {
|
main().catch((err) => {
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
// The file viewer's editor bundle (devdesk#19): CodeMirror 6 with stream-mode
|
||||||
|
// languages, a unified diff view, and markdown rendering. Built separately to
|
||||||
|
// dist/assets/editor.js (window.DevDeskEditor) and loaded over the ttyd channel
|
||||||
|
// the first time the Files pane opens, so the page itself stays small.
|
||||||
|
import { EditorView, keymap, lineNumbers, highlightActiveLine, highlightActiveLineGutter, drawSelection, highlightSpecialChars } from '@codemirror/view';
|
||||||
|
import { EditorState } from '@codemirror/state';
|
||||||
|
import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
|
||||||
|
import { syntaxHighlighting, HighlightStyle, StreamLanguage, bracketMatching, foldGutter, foldKeymap } from '@codemirror/language';
|
||||||
|
import { search, searchKeymap, highlightSelectionMatches } from '@codemirror/search';
|
||||||
|
import { markdownLanguage } from '@codemirror/lang-markdown';
|
||||||
|
import { unifiedMergeView } from '@codemirror/merge';
|
||||||
|
import { tags as t } from '@lezer/highlight';
|
||||||
|
import { shell } from '@codemirror/legacy-modes/mode/shell';
|
||||||
|
import { python } from '@codemirror/legacy-modes/mode/python';
|
||||||
|
import { javascript, json, typescript } from '@codemirror/legacy-modes/mode/javascript';
|
||||||
|
import { yaml } from '@codemirror/legacy-modes/mode/yaml';
|
||||||
|
import { toml } from '@codemirror/legacy-modes/mode/toml';
|
||||||
|
import { properties } from '@codemirror/legacy-modes/mode/properties';
|
||||||
|
import { nginx } from '@codemirror/legacy-modes/mode/nginx';
|
||||||
|
import { diff as diffMode } from '@codemirror/legacy-modes/mode/diff';
|
||||||
|
import { css } from '@codemirror/legacy-modes/mode/css';
|
||||||
|
import { xml, html } from '@codemirror/legacy-modes/mode/xml';
|
||||||
|
import { go } from '@codemirror/legacy-modes/mode/go';
|
||||||
|
import { rust } from '@codemirror/legacy-modes/mode/rust';
|
||||||
|
import { standardSQL } from '@codemirror/legacy-modes/mode/sql';
|
||||||
|
import { dockerFile } from '@codemirror/legacy-modes/mode/dockerfile';
|
||||||
|
import { lua } from '@codemirror/legacy-modes/mode/lua';
|
||||||
|
import { perl } from '@codemirror/legacy-modes/mode/perl';
|
||||||
|
import { ruby } from '@codemirror/legacy-modes/mode/ruby';
|
||||||
|
import { marked } from 'marked';
|
||||||
|
import DOMPurify from 'dompurify';
|
||||||
|
|
||||||
|
const MODES = {
|
||||||
|
shell, python, javascript, json, typescript, yaml, toml, properties, nginx, diff: diffMode, css, xml, html,
|
||||||
|
go, rust, sql: standardSQL, dockerfile: dockerFile, lua, perl, ruby,
|
||||||
|
};
|
||||||
|
|
||||||
|
const BY_EXT = {
|
||||||
|
md: 'markdown', markdown: 'markdown', mdx: 'markdown',
|
||||||
|
sh: 'shell', bash: 'shell', zsh: 'shell', ksh: 'shell', env: 'shell', bats: 'shell',
|
||||||
|
py: 'python', pyi: 'python',
|
||||||
|
js: 'javascript', mjs: 'javascript', cjs: 'javascript', jsx: 'javascript',
|
||||||
|
ts: 'typescript', tsx: 'typescript', mts: 'typescript',
|
||||||
|
json: 'json', jsonc: 'json', webmanifest: 'json',
|
||||||
|
yml: 'yaml', yaml: 'yaml',
|
||||||
|
toml: 'toml',
|
||||||
|
ini: 'properties', cfg: 'properties', conf: 'properties', properties: 'properties',
|
||||||
|
service: 'properties', timer: 'properties', socket: 'properties', mount: 'properties', network: 'properties',
|
||||||
|
diff: 'diff', patch: 'diff',
|
||||||
|
css: 'css', scss: 'css',
|
||||||
|
xml: 'xml', svg: 'xml', plist: 'xml',
|
||||||
|
html: 'html', htm: 'html', php: 'html', j2: 'html', jinja: 'html',
|
||||||
|
go: 'go', rs: 'rust', sql: 'sql', lua: 'lua', pl: 'perl', pm: 'perl', rb: 'ruby',
|
||||||
|
};
|
||||||
|
|
||||||
|
// Language for a path: extension, a few well-known names, else none.
|
||||||
|
export function languageFor(path) {
|
||||||
|
const name = path.split('/').pop().toLowerCase();
|
||||||
|
if (name === 'dockerfile' || name.startsWith('dockerfile.') || name.endsWith('.dockerfile')) return 'dockerfile';
|
||||||
|
if (name === 'makefile' || name === 'gnumakefile') return 'shell';
|
||||||
|
if (/(^|\/)nginx\//.test(path) || name === 'nginx.conf') return 'nginx';
|
||||||
|
if (['.bashrc', '.profile', '.bash_profile', '.zshrc', 'pkgbuild'].includes(name)) return 'shell';
|
||||||
|
if (name.startsWith('.env')) return 'shell';
|
||||||
|
const ext = name.includes('.') ? name.split('.').pop() : '';
|
||||||
|
return BY_EXT[ext] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function languageExtension(lang) {
|
||||||
|
if (lang === 'markdown') return markdownLanguage;
|
||||||
|
if (lang && MODES[lang]) return StreamLanguage.define(MODES[lang]);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Colours come from the page's TDS variables, so dark/light mode just works.
|
||||||
|
const highlight = HighlightStyle.define([
|
||||||
|
{ tag: [t.keyword, t.controlKeyword, t.operatorKeyword, t.modifier], color: 'var(--accent-orange)' },
|
||||||
|
{ tag: [t.string, t.special(t.string), t.regexp], color: 'var(--accent-green)' },
|
||||||
|
{ tag: [t.comment, t.lineComment, t.blockComment, t.meta], color: 'var(--text-muted)', fontStyle: 'italic' },
|
||||||
|
{ tag: [t.number, t.bool, t.atom, t.null], color: 'var(--accent-purple)' },
|
||||||
|
{ tag: [t.typeName, t.className, t.namespace], color: 'var(--accent-amber)' },
|
||||||
|
{ tag: [t.function(t.variableName), t.function(t.propertyName), t.definition(t.variableName)], color: 'var(--accent-cyan)' },
|
||||||
|
{ tag: [t.propertyName, t.attributeName], color: 'var(--accent-cyan)' },
|
||||||
|
{ tag: [t.tagName], color: 'var(--accent-orange)' },
|
||||||
|
{ tag: [t.heading, t.heading1, t.heading2, t.heading3], color: 'var(--accent-cyan)', fontWeight: 'bold' },
|
||||||
|
{ tag: t.strong, fontWeight: 'bold' },
|
||||||
|
{ tag: t.emphasis, fontStyle: 'italic' },
|
||||||
|
{ tag: t.strikethrough, textDecoration: 'line-through' },
|
||||||
|
{ tag: [t.link, t.url], color: 'var(--accent-cyan)', textDecoration: 'underline' },
|
||||||
|
{ tag: [t.monospace], color: 'var(--accent-amber)' },
|
||||||
|
{ tag: [t.quote], color: 'var(--text-secondary)', fontStyle: 'italic' },
|
||||||
|
{ tag: t.inserted, color: 'var(--accent-green)' },
|
||||||
|
{ tag: t.deleted, color: 'var(--accent-red)' },
|
||||||
|
{ tag: t.invalid, color: 'var(--accent-red)' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const theme = EditorView.theme({
|
||||||
|
'&': { height: '100%', color: 'var(--text-primary)', backgroundColor: 'var(--bg-terminal)', fontSize: 'var(--dd-editor-font, 13px)' },
|
||||||
|
'.cm-scroller': { fontFamily: 'var(--font-mono)', lineHeight: '1.5' },
|
||||||
|
'.cm-content': { caretColor: 'var(--accent-orange)' },
|
||||||
|
'.cm-cursor': { borderLeftColor: 'var(--accent-orange)' },
|
||||||
|
'.cm-gutters': { backgroundColor: 'var(--bg-secondary)', color: 'var(--text-dim)', border: 'none', borderRight: '1px solid var(--border-dim)' },
|
||||||
|
'.cm-activeLine': { backgroundColor: 'var(--accent-cyan-dim)' },
|
||||||
|
'.cm-activeLineGutter': { backgroundColor: 'var(--accent-cyan-dim)', color: 'var(--accent-cyan)' },
|
||||||
|
'&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection': { backgroundColor: 'rgba(0, 150, 220, 0.28) !important' },
|
||||||
|
'.cm-searchMatch': { backgroundColor: 'var(--accent-amber-dim)', outline: '1px solid var(--accent-amber)' },
|
||||||
|
'.cm-searchMatch.cm-searchMatch-selected': { backgroundColor: 'var(--accent-orange-dim)' },
|
||||||
|
'.cm-selectionMatch': { backgroundColor: 'var(--accent-cyan-dim)' },
|
||||||
|
'.cm-panels': { backgroundColor: 'var(--bg-secondary)', color: 'var(--text-primary)', borderColor: 'var(--border-color)' },
|
||||||
|
'.cm-panel input, .cm-panel button': { fontFamily: 'var(--font-mono)', fontSize: '12px' },
|
||||||
|
'.cm-textfield': { backgroundColor: 'var(--bg-input)', color: 'var(--text-primary)', border: '1px solid var(--border-color)' },
|
||||||
|
'.cm-button': { backgroundImage: 'none', backgroundColor: 'var(--bg-tertiary)', color: 'var(--text-primary)', border: '1px solid var(--border-color)' },
|
||||||
|
'.cm-foldGutter span': { color: 'var(--text-dim)' },
|
||||||
|
// unified diff
|
||||||
|
'.cm-changedLine': { backgroundColor: 'var(--accent-green-dim) !important' },
|
||||||
|
'.cm-changedText': { backgroundColor: 'rgba(0, 200, 120, 0.22) !important' },
|
||||||
|
'.cm-deletedChunk': { backgroundColor: 'var(--accent-red-dim) !important' },
|
||||||
|
'.cm-deletedChunk .cm-deletedText, .cm-deletedChunk del': { backgroundColor: 'rgba(255, 45, 85, 0.22)', textDecoration: 'none' },
|
||||||
|
'.cm-insertedLine': { backgroundColor: 'var(--accent-green-dim)' },
|
||||||
|
'.cm-changeGutter': { width: '3px' },
|
||||||
|
'.cm-changedLineGutter': { backgroundColor: 'var(--accent-green)' },
|
||||||
|
'.cm-deletedLineGutter': { backgroundColor: 'var(--accent-red)' },
|
||||||
|
});
|
||||||
|
|
||||||
|
function baseExtensions(path, { readOnly = true, wrap = false } = {}) {
|
||||||
|
return [
|
||||||
|
lineNumbers(), foldGutter(), highlightSpecialChars(), highlightActiveLine(), highlightActiveLineGutter(),
|
||||||
|
drawSelection(), history(), search({ top: true }), highlightSelectionMatches(), bracketMatching(),
|
||||||
|
syntaxHighlighting(highlight), theme, languageExtension(languageFor(path)),
|
||||||
|
// Read-only document in an editable view: the caret, selection, arrow keys
|
||||||
|
// and Ctrl+F work, typing doesn't; no on-screen keyboard on phones.
|
||||||
|
EditorState.readOnly.of(readOnly),
|
||||||
|
readOnly ? EditorView.contentAttributes.of({ inputmode: 'none' }) : [],
|
||||||
|
keymap.of([...defaultKeymap, ...historyKeymap, ...searchKeymap, ...foldKeymap]),
|
||||||
|
wrap ? EditorView.lineWrapping : [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read-only (v1) view of a file.
|
||||||
|
export function viewer(parent, { doc, path, wrap }) {
|
||||||
|
const view = new EditorView({ parent, state: EditorState.create({ doc, extensions: baseExtensions(path, { wrap }) }) });
|
||||||
|
return { view, destroy: () => view.destroy() };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unified diff of the HEAD version against the working copy.
|
||||||
|
export function diff(parent, { original, modified, path, wrap }) {
|
||||||
|
const view = new EditorView({
|
||||||
|
parent,
|
||||||
|
state: EditorState.create({
|
||||||
|
doc: modified,
|
||||||
|
extensions: [baseExtensions(path, { wrap }), unifiedMergeView({ original, mergeControls: false, highlightChanges: true, gutter: true })],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
return { view, destroy: () => view.destroy() };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Markdown to sanitized HTML (shown in a sandboxed iframe on top of this).
|
||||||
|
export function markdown(text) {
|
||||||
|
return DOMPurify.sanitize(marked.parse(text, { gfm: true, breaks: false }), { USE_PROFILES: { html: true } });
|
||||||
|
}
|
||||||
+44
-2
@@ -3,11 +3,20 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content">
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content">
|
||||||
<meta name="color-scheme" content="dark">
|
<meta name="color-scheme" content="dark light">
|
||||||
<meta name="theme-color" content="#030508">
|
<meta name="theme-color" content="#030508">
|
||||||
<meta name="generator" content="devdesk">
|
<meta name="generator" content="devdesk">
|
||||||
<title>DevDesk</title>
|
<title>DevDesk</title>
|
||||||
<link rel="icon" id="favicon" href="__FAVICON__">
|
<link rel="icon" id="favicon" href="__FAVICON__">
|
||||||
|
<script>
|
||||||
|
// Theme before first paint (same key as web_template's lt.theme), no dark flash.
|
||||||
|
try {
|
||||||
|
var t = localStorage.getItem('lt_theme');
|
||||||
|
if (t !== 'light' && t !== 'dark') t = matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
|
||||||
|
document.documentElement.setAttribute('data-theme', t);
|
||||||
|
document.documentElement.style.colorScheme = t;
|
||||||
|
} catch (e) { /* storage blocked: stay dark */ }
|
||||||
|
</script>
|
||||||
<!--STYLES-->
|
<!--STYLES-->
|
||||||
</head>
|
</head>
|
||||||
<body class="dd-app">
|
<body class="dd-app">
|
||||||
@@ -31,6 +40,16 @@
|
|||||||
<span class="lt-ws-status dd-ws" id="ws-status" data-state="connecting" role="status">
|
<span class="lt-ws-status dd-ws" id="ws-status" data-state="connecting" role="status">
|
||||||
<span class="lt-dot"></span><span id="ws-label">connecting</span>
|
<span class="lt-dot"></span><span id="ws-label">connecting</span>
|
||||||
</span>
|
</span>
|
||||||
|
<button type="button" class="lt-btn lt-btn-ghost lt-btn-sm dd-cmd-btn" id="cmd-toggle" title="Command palette (Ctrl+Shift+P)" aria-label="Open command palette">⌕<span class="dd-cmd-kbd"> ⌃⇧P</span></button>
|
||||||
|
<button type="button" class="lt-theme-btn" id="theme-toggle" aria-label="Switch to light mode" title="Switch to light mode">☀</button>
|
||||||
|
<div class="lt-notif-dropdown-wrap dd-inbox">
|
||||||
|
<button type="button" class="lt-btn lt-btn-ghost lt-btn-sm lt-notif-bell-btn" id="inbox-toggle" aria-haspopup="dialog" aria-expanded="false" aria-controls="inbox-panel" aria-label="Inbox" title="Inbox">🔔</button>
|
||||||
|
<span class="lt-notif-badge" id="inbox-badge" data-count="0" aria-hidden="true"></span>
|
||||||
|
<div class="lt-notif-panel dd-inbox-panel" id="inbox-panel" role="dialog" aria-label="Inbox" aria-hidden="true">
|
||||||
|
<div class="lt-notif-panel-header"><span>Inbox</span><button type="button" class="lt-notif-panel-clear">Mark all read</button></div>
|
||||||
|
<div class="lt-notif-panel-list"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="dd-more">
|
<div class="dd-more">
|
||||||
<button type="button" class="lt-btn lt-btn-ghost lt-btn-sm dd-more-toggle" id="more-toggle" aria-haspopup="menu" aria-expanded="false" title="Settings" aria-label="Settings">⋯</button>
|
<button type="button" class="lt-btn lt-btn-ghost lt-btn-sm dd-more-toggle" id="more-toggle" aria-haspopup="menu" aria-expanded="false" title="Settings" aria-label="Settings">⋯</button>
|
||||||
<div class="dd-menu dd-more-menu" id="more-menu" role="menu" hidden>
|
<div class="dd-menu dd-more-menu" id="more-menu" role="menu" hidden>
|
||||||
@@ -42,12 +61,16 @@
|
|||||||
<button type="button" class="dd-icon-btn" id="font-up" aria-label="Larger text">A+</button>
|
<button type="button" class="dd-icon-btn" id="font-up" aria-label="Larger text">A+</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<button type="button" class="dd-menu-item" id="theme-menu" role="menuitem">Light mode</button>
|
||||||
<button type="button" class="dd-menu-item" id="notify-toggle" role="menuitem">Desktop notifications</button>
|
<button type="button" class="dd-menu-item" id="notify-toggle" role="menuitem">Desktop notifications</button>
|
||||||
|
<button type="button" class="dd-menu-item" id="palette-menu" role="menuitem">Command palette</button>
|
||||||
|
<button type="button" class="dd-menu-item" id="help-open" role="menuitem">Keyboard shortcuts</button>
|
||||||
<button type="button" class="dd-menu-item" id="fullscreen-toggle" role="menuitem" title="In Chromium, fullscreen also captures Ctrl+W/Ctrl+T for the terminal">Fullscreen</button>
|
<button type="button" class="dd-menu-item" id="fullscreen-toggle" role="menuitem" title="In Chromium, fullscreen also captures Ctrl+W/Ctrl+T for the terminal">Fullscreen</button>
|
||||||
<div class="dd-menu-foot" id="version">devdesk</div>
|
<div class="dd-menu-foot" id="version">devdesk</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="lt-btn lt-btn-sm dd-panels" id="sidebar-toggle" aria-controls="sidebar" aria-expanded="false">Panels<span class="dd-badge" id="panels-badge" hidden></span></button>
|
<button type="button" class="lt-btn lt-btn-sm dd-files-toggle" id="files-toggle" aria-controls="files" aria-expanded="false" title="Files: browse, preview and diff this session's folder (Ctrl+Shift+E)"><span class="dd-panels-label">Files</span><span class="dd-panels-icon" aria-hidden="true">🗀</span></button>
|
||||||
|
<button type="button" class="lt-btn lt-btn-sm dd-panels" id="sidebar-toggle" aria-controls="sidebar" aria-expanded="false"><span class="dd-panels-label">Panels</span><span class="dd-panels-icon" aria-hidden="true">▤</span></button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -67,6 +90,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="lt-frame dd-files" id="files" aria-label="Files" hidden>
|
||||||
|
<div class="dd-files-resizer" id="files-resizer" role="separator" aria-orientation="vertical" aria-label="Resize the files pane" tabindex="0"></div>
|
||||||
|
<div class="dd-files-head">
|
||||||
|
<div class="dd-files-tabs" role="tablist">
|
||||||
|
<button type="button" role="tab" data-files-tab="files" aria-selected="true">Files</button>
|
||||||
|
<button type="button" role="tab" data-files-tab="changes" aria-selected="false">Changes <span class="dd-files-count"></span></button>
|
||||||
|
</div>
|
||||||
|
<span class="dd-files-actions">
|
||||||
|
<button type="button" class="dd-icon-btn dd-files-refresh" title="Refresh" aria-label="Refresh">↻</button>
|
||||||
|
<button type="button" class="dd-icon-btn dd-files-close" title="Close (Esc)" aria-label="Close files">✕</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<nav class="dd-files-crumbs" aria-label="Path"></nav>
|
||||||
|
<div class="dd-files-body" tabindex="-1"></div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div class="dd-backdrop" id="backdrop" hidden></div>
|
<div class="dd-backdrop" id="backdrop" hidden></div>
|
||||||
<aside id="sidebar" class="dd-sidebar" aria-label="Panels">
|
<aside id="sidebar" class="dd-sidebar" aria-label="Panels">
|
||||||
<section class="lt-frame dd-widget" id="widget-sessions" data-state="live">
|
<section class="lt-frame dd-widget" id="widget-sessions" data-state="live">
|
||||||
@@ -128,6 +167,9 @@
|
|||||||
<span class="lt-footer-hint"><span class="lt-footer-key">⇧drag</span>select</span>
|
<span class="lt-footer-hint"><span class="lt-footer-key">⇧drag</span>select</span>
|
||||||
<span class="lt-footer-sep">│</span>
|
<span class="lt-footer-sep">│</span>
|
||||||
<span class="lt-footer-hint"><span class="lt-footer-key">drop / paste</span>attach files</span>
|
<span class="lt-footer-hint"><span class="lt-footer-key">drop / paste</span>attach files</span>
|
||||||
|
<span class="lt-footer-sep">│</span>
|
||||||
|
<span class="lt-footer-hint"><span class="lt-footer-key">^⇧P</span>commands</span>
|
||||||
|
<button type="button" class="dd-footer-help" id="footer-help">all keys</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="dd-keybar" id="keybar" role="toolbar" aria-label="Terminal keys" hidden>
|
<div class="dd-keybar" id="keybar" role="toolbar" aria-label="Terminal keys" hidden>
|
||||||
<button type="button" data-keys="esc">Esc</button>
|
<button type="button" data-keys="esc">Esc</button>
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
// each with an "Ask Claude" button that types an investigation prompt into the
|
// each with an "Ask Claude" button that types an investigation prompt into the
|
||||||
// current session (without pressing Enter).
|
// current session (without pressing Enter).
|
||||||
|
|
||||||
import { el } from './sessions.js';
|
import { el } from './dom.js';
|
||||||
|
|
||||||
const SEVERITY = {
|
const SEVERITY = {
|
||||||
critical: 'lt-chip-critical',
|
critical: 'lt-chip-critical',
|
||||||
|
|||||||
+97
-6
@@ -121,6 +121,19 @@ export function runCommand(args, timeoutMs = 8000) {
|
|||||||
return limited(() => runCommandNow(args, timeoutMs));
|
return limited(() => runCommandNow(args, timeoutMs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A full JSON reply, or devdesk's one-line error.
|
||||||
|
function isComplete(text) {
|
||||||
|
const clean = stripAnsi(text);
|
||||||
|
if (/^devdesk: .*\n/m.test(clean)) return true;
|
||||||
|
if (!/\}\s*$/.test(clean)) return false;
|
||||||
|
try {
|
||||||
|
parseListOutput(clean);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function runCommandNow(args, timeoutMs) {
|
async function runCommandNow(args, timeoutMs) {
|
||||||
const token = await fetchToken();
|
const token = await fetchToken();
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -132,15 +145,26 @@ async function runCommandNow(args, timeoutMs) {
|
|||||||
reject(new Error('devdesk did not answer'));
|
reject(new Error('devdesk did not answer'));
|
||||||
}, timeoutMs);
|
}, timeoutMs);
|
||||||
socket.onopen = () => socket.send(encodeInit(token, 240, 24));
|
socket.onopen = () => socket.send(encodeInit(token, 240, 24));
|
||||||
socket.onmessage = (event) => {
|
let settled = false;
|
||||||
const { type, payload } = decodeServer(event.data);
|
const finish = () => {
|
||||||
if (type === Server.OUTPUT) chunks.push(payload.slice());
|
if (settled) return;
|
||||||
};
|
settled = true;
|
||||||
socket.onerror = () => {};
|
|
||||||
socket.onclose = () => {
|
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
resolve(new TextDecoder().decode(concat(chunks)));
|
resolve(new TextDecoder().decode(concat(chunks)));
|
||||||
};
|
};
|
||||||
|
socket.onmessage = (event) => {
|
||||||
|
const { type, payload } = decodeServer(event.data);
|
||||||
|
if (type !== Server.OUTPUT) return;
|
||||||
|
chunks.push(payload.slice());
|
||||||
|
// Hang up as soon as the answer is complete: devdesk waits for that
|
||||||
|
// before exiting, so ttyd can't drop its last output (devdesk#35).
|
||||||
|
if (isComplete(new TextDecoder().decode(concat(chunks)))) {
|
||||||
|
finish();
|
||||||
|
socket.close();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.onerror = () => {};
|
||||||
|
socket.onclose = finish;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +235,8 @@ async function uploadNow(session, file, onProgress) {
|
|||||||
if (!sending && output.includes('DEVDESK-UPLOAD-READY')) {
|
if (!sending && output.includes('DEVDESK-UPLOAD-READY')) {
|
||||||
sending = true;
|
sending = true;
|
||||||
send();
|
send();
|
||||||
|
} else if (sending && isComplete(output.replace(/^[\s\S]*DEVDESK-UPLOAD-READY/, ''))) {
|
||||||
|
socket.close(); // the reply is in; let devdesk exit (devdesk#35)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
socket.onerror = () => {};
|
socket.onerror = () => {};
|
||||||
@@ -232,6 +258,71 @@ async function uploadNow(session, file, onProgress) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Blob replies (`--fs-read`, `--git-show`, `--asset`): a JSON header line, then
|
||||||
|
// base64 between DEVDESK-BLOB-BEGIN/END. Resolves { header, base64 }, base64
|
||||||
|
// being null when the file has no body (too large, binary). Only the head and
|
||||||
|
// the tail of the stream are decoded while it arrives, so megabytes stay cheap.
|
||||||
|
export function runBlob(args, timeoutMs = 30000) {
|
||||||
|
return limited(() => runBlobNow(args, timeoutMs));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runBlobNow(args, timeoutMs) {
|
||||||
|
const token = await fetchToken();
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const socket = new WebSocket(wsUrl(window.location, args), ['tty']);
|
||||||
|
socket.binaryType = 'arraybuffer';
|
||||||
|
const chunks = [];
|
||||||
|
const decoder = new TextDecoder();
|
||||||
|
let head = '';
|
||||||
|
let tail = '';
|
||||||
|
let settled = false;
|
||||||
|
const done = (fn, value) => {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
clearTimeout(timer);
|
||||||
|
socket.close();
|
||||||
|
fn(value);
|
||||||
|
};
|
||||||
|
const timer = setTimeout(() => done(reject, new Error('devdesk did not answer in time')), timeoutMs);
|
||||||
|
const finish = () => {
|
||||||
|
const text = stripAnsi(new TextDecoder().decode(concat(chunks)));
|
||||||
|
const error = /^devdesk: (.*)$/m.exec(text);
|
||||||
|
const line = text.split(/\r?\n/).find((l) => l.startsWith('{'));
|
||||||
|
if (!line) {
|
||||||
|
done(reject, new Error(error ? error[1] : 'no reply'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let header;
|
||||||
|
try {
|
||||||
|
header = JSON.parse(line);
|
||||||
|
} catch {
|
||||||
|
done(reject, new Error('unreadable reply'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const body = /DEVDESK-BLOB-BEGIN\r?\n([\s\S]*?)\r?\nDEVDESK-BLOB-END/.exec(text);
|
||||||
|
done(resolve, { header, base64: body ? body[1].replace(/\s+/g, '') : null });
|
||||||
|
};
|
||||||
|
socket.onopen = () => socket.send(encodeInit(token, 240, 24));
|
||||||
|
socket.onmessage = (event) => {
|
||||||
|
const { type, payload } = decodeServer(event.data);
|
||||||
|
if (type !== Server.OUTPUT) return;
|
||||||
|
chunks.push(payload.slice());
|
||||||
|
const piece = decoder.decode(payload, { stream: true });
|
||||||
|
if (head.length < 4096) head += piece;
|
||||||
|
tail = (tail + piece).slice(-256);
|
||||||
|
const firstLine = /^\s*(\{.*\})\r?$/m.exec(head);
|
||||||
|
if (tail.includes('DEVDESK-BLOB-END') || /^devdesk: .*\n/m.test(head)
|
||||||
|
|| (firstLine && !head.includes('DEVDESK-BLOB-BEGIN') && /"tooLarge":true/.test(firstLine[1]))) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
socket.onerror = () => {};
|
||||||
|
socket.onclose = () => {
|
||||||
|
if (!settled) finish();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Git + Gitea CI status for a session's folder (`devdesk attach --repo NAME`).
|
// Git + Gitea CI status for a session's folder (`devdesk attach --repo NAME`).
|
||||||
export async function fetchRepo(session) {
|
export async function fetchRepo(session) {
|
||||||
return parseListOutput(await runCommand(['--repo', session]));
|
return parseListOutput(await runCommand(['--repo', session]));
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// Tiny DOM builder: el('a', { class, href, onclick }, ...children). Attributes
|
||||||
|
// that are null/undefined/false are skipped; on* keys become event listeners.
|
||||||
|
export function el(tag, attrs = {}, ...children) {
|
||||||
|
const node = document.createElement(tag);
|
||||||
|
for (const [key, value] of Object.entries(attrs)) {
|
||||||
|
if (value === undefined || value === null || value === false) continue;
|
||||||
|
if (key === 'class') node.className = value;
|
||||||
|
else if (key.startsWith('on')) node.addEventListener(key.slice(2), value);
|
||||||
|
else node.setAttribute(key, value === true ? '' : value);
|
||||||
|
}
|
||||||
|
node.append(...children.filter((c) => c !== null && c !== undefined));
|
||||||
|
return node;
|
||||||
|
}
|
||||||
@@ -0,0 +1,552 @@
|
|||||||
|
/* global __EDITOR_SHA__ */
|
||||||
|
// Files pane (devdesk#19): browse the session's folder, read files with syntax
|
||||||
|
// highlighting, preview markdown and images, and review what changed (git
|
||||||
|
// status + diff against HEAD, with a badge on files Claude edited). Read-only
|
||||||
|
// in v1. Everything goes through `devdesk attach --fs-*` over ttyd.
|
||||||
|
|
||||||
|
import { runBlob, runCommand } from './connection.js';
|
||||||
|
import { parseListOutput } from './protocol.js';
|
||||||
|
import { el } from './dom.js';
|
||||||
|
import { ago } from './sessions.js';
|
||||||
|
import { toast } from './ui.js';
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- editor bundle
|
||||||
|
|
||||||
|
const DB = 'devdesk';
|
||||||
|
const STORE = 'assets';
|
||||||
|
|
||||||
|
function idb(mode, run) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const open = indexedDB.open(DB, 1);
|
||||||
|
open.onupgradeneeded = () => open.result.createObjectStore(STORE);
|
||||||
|
open.onerror = () => reject(open.error);
|
||||||
|
open.onsuccess = () => {
|
||||||
|
const tx = open.result.transaction(STORE, mode);
|
||||||
|
const request = run(tx.objectStore(STORE));
|
||||||
|
tx.oncomplete = () => {
|
||||||
|
open.result.close();
|
||||||
|
resolve(request?.result);
|
||||||
|
};
|
||||||
|
tx.onerror = () => reject(tx.error);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sha256(text) {
|
||||||
|
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text));
|
||||||
|
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, '0')).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function decodeBase64(b64) {
|
||||||
|
const bin = atob(b64);
|
||||||
|
const bytes = new Uint8Array(bin.length);
|
||||||
|
for (let i = 0; i < bin.length; i += 1) bytes[i] = bin.charCodeAt(i);
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The editor (~600 KB) is not in the page: it's fetched over ttyd the first time
|
||||||
|
// the pane opens, checked against the hash this page was built with, cached in
|
||||||
|
// IndexedDB under that hash, and run.
|
||||||
|
let editorLoading = null;
|
||||||
|
export function loadEditor() {
|
||||||
|
editorLoading ??= (async () => {
|
||||||
|
if (window.DevDeskEditor) return window.DevDeskEditor;
|
||||||
|
let code = null;
|
||||||
|
try {
|
||||||
|
code = await idb('readonly', (store) => store.get(__EDITOR_SHA__));
|
||||||
|
} catch {
|
||||||
|
// No IndexedDB (private mode): fetch every time.
|
||||||
|
}
|
||||||
|
if (!code) {
|
||||||
|
const { base64 } = await runBlob(['--asset', 'editor.js'], 60000);
|
||||||
|
if (!base64) throw new Error('the editor bundle is missing on the server');
|
||||||
|
code = new TextDecoder().decode(decodeBase64(base64));
|
||||||
|
if (crypto.subtle && (await sha256(code)) !== __EDITOR_SHA__) {
|
||||||
|
throw new Error('the server has a different DevDesk version: reload the page');
|
||||||
|
}
|
||||||
|
idb('readwrite', (store) => {
|
||||||
|
store.clear();
|
||||||
|
store.put(code, __EDITOR_SHA__);
|
||||||
|
}).catch(() => {});
|
||||||
|
}
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.textContent = code;
|
||||||
|
document.head.append(script);
|
||||||
|
script.remove();
|
||||||
|
if (!window.DevDeskEditor) throw new Error('the editor failed to start');
|
||||||
|
return window.DevDeskEditor;
|
||||||
|
})().catch((error) => {
|
||||||
|
editorLoading = null;
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
return editorLoading;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- helpers
|
||||||
|
|
||||||
|
const size = (n) => (n < 1024 ? `${n} B` : n < 1048576 ? `${(n / 1024).toFixed(1)} KB` : `${(n / 1048576).toFixed(1)} MB`);
|
||||||
|
const join = (dir, name) => (dir ? `${dir}/${name}` : name);
|
||||||
|
const parent = (path) => path.split('/').slice(0, -1).join('/');
|
||||||
|
const isMarkdown = (path) => /\.(md|markdown|mdx)$/i.test(path);
|
||||||
|
|
||||||
|
const STATUS = {
|
||||||
|
M: ['M', 'modified', 'amber'], A: ['A', 'added', 'green'], D: ['D', 'deleted', 'red'], R: ['R', 'renamed', 'cyan'],
|
||||||
|
C: ['C', 'copied', 'cyan'], U: ['U', 'conflict', 'red'], '?': ['N', 'new', 'green'], ' ': ['·', 'edited by Claude', 'cyan'],
|
||||||
|
};
|
||||||
|
function statusOf(f) {
|
||||||
|
const code = f.x === '?' ? '?' : f.x !== ' ' ? f.x : f.y;
|
||||||
|
return STATUS[code] ?? STATUS.M;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Markdown preview document: sanitized HTML in a sandboxed iframe (no scripts,
|
||||||
|
// no same-origin), styled from the page's current TDS colours.
|
||||||
|
function previewDocument(html) {
|
||||||
|
const css = getComputedStyle(document.documentElement);
|
||||||
|
const v = (name) => css.getPropertyValue(name).trim();
|
||||||
|
return `<!doctype html><html><head><meta charset="utf-8"><base target="_blank"><style>
|
||||||
|
:root { color-scheme: ${document.documentElement.dataset.theme === 'light' ? 'light' : 'dark'}; }
|
||||||
|
body { margin: 0; padding: 18px 22px 40px; background: ${v('--bg-terminal')}; color: ${v('--text-primary')};
|
||||||
|
font: 14px/1.65 ${v('--font-mono') || 'monospace'}; overflow-wrap: anywhere; }
|
||||||
|
h1, h2, h3, h4 { color: ${v('--accent-cyan')}; line-height: 1.3; margin: 1.4em 0 0.5em; }
|
||||||
|
h1 { font-size: 1.45em; border-bottom: 1px solid ${v('--border-color')}; padding-bottom: 0.3em; }
|
||||||
|
h2 { font-size: 1.2em; border-bottom: 1px solid ${v('--border-dim')}; padding-bottom: 0.2em; }
|
||||||
|
a { color: ${v('--accent-orange')}; }
|
||||||
|
code { background: ${v('--bg-tertiary')}; padding: 1px 5px; color: ${v('--accent-amber')}; font-family: inherit; }
|
||||||
|
pre { background: ${v('--bg-secondary')}; border: 1px solid ${v('--border-dim')}; padding: 10px 12px; overflow-x: auto; }
|
||||||
|
pre code { background: none; padding: 0; color: ${v('--text-primary')}; }
|
||||||
|
blockquote { margin: 0.8em 0; padding: 2px 14px; border-left: 3px solid ${v('--accent-cyan')}; color: ${v('--text-secondary')}; }
|
||||||
|
table { border-collapse: collapse; margin: 0.8em 0; } th, td { border: 1px solid ${v('--border-color')}; padding: 4px 10px; }
|
||||||
|
th { background: ${v('--bg-secondary')}; } hr { border: 0; border-top: 1px solid ${v('--border-color')}; }
|
||||||
|
img { max-width: 100%; } li { margin: 0.2em 0; } input[type=checkbox] { margin-right: 6px; }
|
||||||
|
</style></head><body>${html}</body></html>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relative <img> in a markdown file (e.g. docs/screenshot.png) can't load from
|
||||||
|
// the sandboxed preview: fetch up to 10 of them over ttyd and inline them.
|
||||||
|
async function inlineImages(html, session, mdPath) {
|
||||||
|
const doc = new DOMParser().parseFromString(`<body>${html}</body>`, 'text/html');
|
||||||
|
const images = [...doc.querySelectorAll('img[src]')]
|
||||||
|
.filter((img) => !/^([a-z][a-z0-9+.-]*:|\/\/|#)/i.test(img.getAttribute('src'))).slice(0, 10);
|
||||||
|
if (!images.length) return html;
|
||||||
|
const base = parent(mdPath);
|
||||||
|
await Promise.all(images.map(async (img) => {
|
||||||
|
const parts = [];
|
||||||
|
for (const part of `${base}/${decodeURIComponent(img.getAttribute('src').split(/[?#]/)[0])}`.split('/')) {
|
||||||
|
if (part === '..') parts.pop();
|
||||||
|
else if (part && part !== '.') parts.push(part);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const { header, base64 } = await runBlob(['--fs-read', session, parts.join('/')]);
|
||||||
|
if (header.mime?.startsWith('image/') && base64) img.setAttribute('src', `data:${header.mime};base64,${base64}`);
|
||||||
|
} catch {
|
||||||
|
// missing image: leave the broken link
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
return doc.body.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- pane
|
||||||
|
|
||||||
|
function readPref(key) {
|
||||||
|
try {
|
||||||
|
return localStorage.getItem(`devdesk.files.${key}`);
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function writePref(key, value) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(`devdesk.files.${key}`, value);
|
||||||
|
} catch {
|
||||||
|
// Private mode: the preference lasts until the tab closes.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FilesPane {
|
||||||
|
// hooks: session() -> name, paste(text), onToggle(open), focusTerminal()
|
||||||
|
constructor(root, hooks) {
|
||||||
|
this.root = root;
|
||||||
|
this.hooks = hooks;
|
||||||
|
this.tab = 'files';
|
||||||
|
this.dir = '';
|
||||||
|
this.session = null;
|
||||||
|
this.listing = null;
|
||||||
|
this.changes = null;
|
||||||
|
this.current = null; // { path, mode: 'view' | 'diff' | 'preview', sha }
|
||||||
|
this.editorView = null;
|
||||||
|
this.seq = 0;
|
||||||
|
this.wrap = readPref('wrap') === '1';
|
||||||
|
this.body = root.querySelector('.dd-files-body');
|
||||||
|
this.crumbs = root.querySelector('.dd-files-crumbs');
|
||||||
|
this.tabs = [...root.querySelectorAll('[data-files-tab]')];
|
||||||
|
this.count = root.querySelector('.dd-files-count');
|
||||||
|
for (const button of this.tabs) button.addEventListener('click', () => this.showTab(button.dataset.filesTab));
|
||||||
|
root.querySelector('.dd-files-refresh').addEventListener('click', () => this.refresh({ force: true }));
|
||||||
|
root.querySelector('.dd-files-close').addEventListener('click', () => this.close());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Esc: back from a file to the list, then close. main.js routes Esc here
|
||||||
|
// whenever the pane is open and the terminal doesn't have the focus.
|
||||||
|
escape() {
|
||||||
|
if (this.current) this.back();
|
||||||
|
else this.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
get isOpen() {
|
||||||
|
return !this.root.hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
open(tab) {
|
||||||
|
if (tab) this.tab = tab;
|
||||||
|
this.root.hidden = false;
|
||||||
|
this.hooks.onToggle(true);
|
||||||
|
this.syncSession();
|
||||||
|
this.renderTabs();
|
||||||
|
if (!this.current) this.refresh();
|
||||||
|
loadEditor().catch(() => {}); // warm up while the list loads
|
||||||
|
}
|
||||||
|
|
||||||
|
close() {
|
||||||
|
this.root.hidden = true;
|
||||||
|
this.hooks.onToggle(false);
|
||||||
|
this.hooks.focusTerminal();
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle(tab) {
|
||||||
|
if (this.isOpen && (!tab || tab === this.tab)) this.close();
|
||||||
|
else this.open(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The pane follows the current session; a different session starts at its root.
|
||||||
|
syncSession() {
|
||||||
|
const session = this.hooks.session();
|
||||||
|
if (session === this.session) return false;
|
||||||
|
this.session = session;
|
||||||
|
this.dir = '';
|
||||||
|
this.listing = null;
|
||||||
|
this.changes = null;
|
||||||
|
this.destroyEditor();
|
||||||
|
this.current = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionChanged() {
|
||||||
|
if (this.isOpen && this.syncSession()) this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
showTab(tab) {
|
||||||
|
this.tab = tab;
|
||||||
|
this.destroyEditor();
|
||||||
|
this.current = null;
|
||||||
|
this.renderTabs();
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderTabs() {
|
||||||
|
for (const button of this.tabs) button.setAttribute('aria-selected', String(button.dataset.filesTab === this.tab));
|
||||||
|
}
|
||||||
|
|
||||||
|
// After Claude's turn: refresh what's visible; an open file that changed on
|
||||||
|
// disk gets a reload notice instead of jumping under you.
|
||||||
|
async claudeTurnEnded() {
|
||||||
|
if (!this.isOpen) return;
|
||||||
|
if (!this.current) {
|
||||||
|
this.refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.loadChanges().catch(() => {});
|
||||||
|
if (this.current.mode === 'view' || this.current.mode === 'preview') {
|
||||||
|
try {
|
||||||
|
const { header } = await runBlob(['--fs-read', this.session, this.current.path]);
|
||||||
|
if (header.sha && header.sha !== this.current.sha) this.showStale();
|
||||||
|
} catch {
|
||||||
|
// deleted or unreadable: leave it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async refresh({ force = false } = {}) {
|
||||||
|
if (!this.session) {
|
||||||
|
this.message('Open a session to browse its files.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.current && !force) return;
|
||||||
|
if (this.current && force) {
|
||||||
|
this.openFile(this.current.path, this.current.mode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.tab === 'files') await this.loadDir(this.dir);
|
||||||
|
else await this.renderChanges(true);
|
||||||
|
if (this.tab === 'files') this.loadChanges().catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
|
message(text, tone = '') {
|
||||||
|
this.crumbs.replaceChildren();
|
||||||
|
this.body.replaceChildren(el('div', { class: `dd-files-msg${tone ? ` is-${tone}` : ''}` }, text));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------ files tab
|
||||||
|
|
||||||
|
async loadDir(dir) {
|
||||||
|
const session = this.session;
|
||||||
|
const seq = ++this.seq; // a newer navigation wins over a slower reply
|
||||||
|
this.renderCrumbs(dir);
|
||||||
|
if (!this.listing || this.listing.dir !== dir) this.body.replaceChildren(el('div', { class: 'dd-files-msg' }, 'Loading…'));
|
||||||
|
try {
|
||||||
|
const listing = parseListOutput(await runCommand(['--fs-list', session, dir || '.'], 15000));
|
||||||
|
if (seq !== this.seq || session !== this.session || this.current || this.tab !== 'files') return;
|
||||||
|
this.listing = listing;
|
||||||
|
this.dir = listing.dir;
|
||||||
|
this.renderDir();
|
||||||
|
} catch (error) {
|
||||||
|
if (seq !== this.seq) return;
|
||||||
|
if (dir) {
|
||||||
|
toast.error(`${dir}: ${error.message}`);
|
||||||
|
this.dir = '';
|
||||||
|
this.loadDir('');
|
||||||
|
} else {
|
||||||
|
this.message(error.message, 'error');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderCrumbs(path, { file = false } = {}) {
|
||||||
|
const parts = path ? path.split('/') : [];
|
||||||
|
const nodes = [el('button', { type: 'button', class: 'dd-crumb', title: this.listing?.root, onclick: () => this.goDir('') }, this.session)];
|
||||||
|
parts.forEach((part, i) => {
|
||||||
|
nodes.push(el('span', { class: 'dd-crumb-sep' }, '/'));
|
||||||
|
const target = parts.slice(0, i + 1).join('/');
|
||||||
|
const last = i === parts.length - 1;
|
||||||
|
nodes.push(last && file
|
||||||
|
? el('span', { class: 'dd-crumb is-file' }, part)
|
||||||
|
: el('button', { type: 'button', class: `dd-crumb${last ? ' is-current' : ''}`, onclick: () => this.goDir(target) }, part));
|
||||||
|
});
|
||||||
|
this.crumbs.replaceChildren(...nodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
goDir(dir) {
|
||||||
|
this.destroyEditor();
|
||||||
|
this.current = null;
|
||||||
|
this.tab = 'files';
|
||||||
|
this.renderTabs();
|
||||||
|
this.loadDir(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
changeFor(path) {
|
||||||
|
return this.changes?.files?.find((f) => f.path === path) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderDir() {
|
||||||
|
const { entries, truncated } = this.listing;
|
||||||
|
this.renderCrumbs(this.dir);
|
||||||
|
const rows = [];
|
||||||
|
if (this.dir) {
|
||||||
|
rows.push(el('li', {}, el('button', { type: 'button', class: 'dd-file is-up', onclick: () => this.goDir(parent(this.dir)) },
|
||||||
|
el('span', { class: 'dd-file-icon' }, '↰'), el('span', { class: 'dd-file-name' }, '..'))));
|
||||||
|
}
|
||||||
|
for (const e of entries) {
|
||||||
|
const isDir = e.t === 'd' || e.to === 'd';
|
||||||
|
const path = join(this.dir, e.n);
|
||||||
|
const change = isDir ? null : this.changeFor(path);
|
||||||
|
const dirty = isDir && this.changes?.files?.some((f) => f.path?.startsWith(`${path}/`));
|
||||||
|
rows.push(el('li', {}, el('button', {
|
||||||
|
type: 'button', class: `dd-file${isDir ? ' is-dir' : ''}${e.t === 'l' ? ' is-link' : ''}`,
|
||||||
|
title: `${path}${e.t === 'l' ? ' (symlink)' : ''}`,
|
||||||
|
onclick: () => (isDir ? this.goDir(path) : this.openFile(path)),
|
||||||
|
},
|
||||||
|
el('span', { class: 'dd-file-icon', 'aria-hidden': 'true' }, isDir ? '▸' : e.t === 'l' ? '↪' : '·'),
|
||||||
|
el('span', { class: 'dd-file-name' }, e.n),
|
||||||
|
change ? el('span', { class: `dd-file-status is-${statusOf(change)[2]}`, title: statusOf(change)[1] }, statusOf(change)[0]) : null,
|
||||||
|
change?.claude ? el('span', { class: 'dd-claude-chip', title: 'Claude edited this file' }, 'C') : null,
|
||||||
|
dirty ? el('span', { class: 'dd-file-status is-amber', title: 'contains changes' }, '•') : null,
|
||||||
|
el('span', { class: 'dd-file-meta' }, isDir ? '' : size(e.s)),
|
||||||
|
el('span', { class: 'dd-file-meta dd-file-age' }, ago(e.m)))));
|
||||||
|
}
|
||||||
|
if (!entries.length) rows.push(el('li', { class: 'dd-files-msg' }, 'Empty folder.'));
|
||||||
|
if (truncated) rows.push(el('li', { class: 'dd-files-msg' }, `Only the first ${entries.length} entries are shown.`));
|
||||||
|
this.body.replaceChildren(el('ul', { class: 'dd-file-list' }, ...rows));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------ changes tab
|
||||||
|
|
||||||
|
async loadChanges() {
|
||||||
|
const session = this.session;
|
||||||
|
const changes = parseListOutput(await runCommand(['--git-status', session], 15000));
|
||||||
|
if (session !== this.session) return null;
|
||||||
|
this.changes = changes;
|
||||||
|
const n = changes.files?.length ?? 0;
|
||||||
|
this.count.textContent = n ? String(n) : '';
|
||||||
|
if (this.tab === 'files' && !this.current && this.listing) this.renderDir();
|
||||||
|
return changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
async renderChanges(reload) {
|
||||||
|
this.crumbs.replaceChildren(el('span', { class: 'dd-crumb is-file' }, this.changes?.git === false ? 'Edited by Claude' : `${this.changes?.branch ?? ''} · uncommitted changes`));
|
||||||
|
if (reload || !this.changes) {
|
||||||
|
this.body.replaceChildren(el('div', { class: 'dd-files-msg' }, 'Loading…'));
|
||||||
|
try {
|
||||||
|
await this.loadChanges();
|
||||||
|
} catch (error) {
|
||||||
|
this.message(error.message, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.tab !== 'changes' || this.current) return;
|
||||||
|
const { files = [], git, branch } = this.changes;
|
||||||
|
this.crumbs.replaceChildren(el('span', { class: 'dd-crumb is-file' }, git ? `${branch} · ${files.length} changed` : 'Not a git repository · files Claude edited'));
|
||||||
|
if (!files.length) {
|
||||||
|
this.body.replaceChildren(el('div', { class: 'dd-files-msg' }, git ? 'No uncommitted changes.' : 'Claude hasn\'t edited files in this folder yet.'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const rows = files.map((f) => {
|
||||||
|
const [letter, label, tone] = statusOf(f);
|
||||||
|
const name = f.path ?? f.repoPath;
|
||||||
|
const openable = f.path !== null && f.path !== undefined;
|
||||||
|
return el('li', {}, el('button', {
|
||||||
|
type: 'button', class: 'dd-file', disabled: !openable,
|
||||||
|
title: `${label}${f.from ? ` from ${f.from}` : ''}${f.claude ? ' · edited by Claude' : ''}${openable ? '' : ' (outside this folder)'}`,
|
||||||
|
onclick: () => this.openFile(f.path, git && f.x !== '?' && f.y !== '?' ? 'diff' : 'view'),
|
||||||
|
},
|
||||||
|
el('span', { class: `dd-file-status is-${tone}` }, letter),
|
||||||
|
el('span', { class: 'dd-file-name' }, name),
|
||||||
|
f.claude ? el('span', { class: 'dd-claude-chip', title: 'Claude edited this file' }, 'C') : null,
|
||||||
|
el('span', { class: 'dd-file-meta' },
|
||||||
|
f.add !== null && f.add !== undefined ? el('span', { class: 'dd-add' }, `+${f.add}`) : null,
|
||||||
|
f.del !== null && f.del !== undefined ? el('span', { class: 'dd-del' }, ` −${f.del}`) : null)));
|
||||||
|
});
|
||||||
|
this.body.replaceChildren(el('ul', { class: 'dd-file-list' }, ...rows));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------ viewer
|
||||||
|
|
||||||
|
destroyEditor() {
|
||||||
|
this.editorView?.destroy();
|
||||||
|
this.editorView = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
back() {
|
||||||
|
this.destroyEditor();
|
||||||
|
this.current = null;
|
||||||
|
if (this.tab === 'files') this.loadDir(this.dir);
|
||||||
|
else this.renderChanges(false);
|
||||||
|
this.body.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
showStale() {
|
||||||
|
const bar = this.body.querySelector('.dd-viewer-stale');
|
||||||
|
if (bar) bar.hidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async openFile(path, mode) {
|
||||||
|
const session = this.session;
|
||||||
|
this.destroyEditor();
|
||||||
|
const change = this.changeFor(path);
|
||||||
|
const wanted = mode ?? (isMarkdown(path) ? 'preview' : 'view');
|
||||||
|
this.current = { path, mode: wanted, sha: null };
|
||||||
|
this.seq += 1;
|
||||||
|
this.renderCrumbs(path, { file: true });
|
||||||
|
this.body.replaceChildren(el('div', { class: 'dd-files-msg' }, 'Loading…'));
|
||||||
|
let blob;
|
||||||
|
let original = null;
|
||||||
|
let editor;
|
||||||
|
try {
|
||||||
|
const deleted = change && (change.x === 'D' || change.y === 'D');
|
||||||
|
[blob, original, editor] = await Promise.all([
|
||||||
|
deleted ? Promise.resolve({ header: { path, size: 0, utf8: true, body: true }, base64: '' }) : runBlob(['--fs-read', session, path]),
|
||||||
|
wanted === 'diff' ? runBlob(['--git-show', session, path]) : Promise.resolve(null),
|
||||||
|
loadEditor().catch((error) => ({ error })),
|
||||||
|
]);
|
||||||
|
} catch (error) {
|
||||||
|
if (session === this.session) this.viewerMessage(path, error.message, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (session !== this.session || this.current?.path !== path) return;
|
||||||
|
const { header, base64 } = blob;
|
||||||
|
this.current.sha = header.sha ?? null;
|
||||||
|
|
||||||
|
const text = (b64, utf8 = true) => new TextDecoder(utf8 ? 'utf-8' : 'latin1').decode(decodeBase64(b64 || ''));
|
||||||
|
const content = el('div', { class: 'dd-viewer-content' });
|
||||||
|
const actions = [];
|
||||||
|
const action = (label, run, extra = {}) => actions.push(el('button', { type: 'button', class: 'dd-viewer-btn', onclick: run, ...extra }, label));
|
||||||
|
|
||||||
|
if (wanted !== 'diff' && isMarkdown(path)) {
|
||||||
|
action(wanted === 'preview' ? 'Source' : 'Preview', () => this.openFile(path, wanted === 'preview' ? 'view' : 'preview'));
|
||||||
|
}
|
||||||
|
if (change && change.x !== '?' && change.y !== '?' && this.changes?.git) {
|
||||||
|
action(wanted === 'diff' ? 'File' : 'Diff', () => this.openFile(path, wanted === 'diff' ? (isMarkdown(path) ? 'preview' : 'view') : 'diff'));
|
||||||
|
}
|
||||||
|
if (wanted === 'view' || wanted === 'diff') {
|
||||||
|
action(this.wrap ? 'No wrap' : 'Wrap', () => {
|
||||||
|
this.wrap = !this.wrap;
|
||||||
|
writePref('wrap', this.wrap ? '1' : '0');
|
||||||
|
this.openFile(path, wanted);
|
||||||
|
}, { title: 'Wrap long lines' });
|
||||||
|
}
|
||||||
|
action('Copy path', () => navigator.clipboard?.writeText(path).then(() => toast.success('Path copied'), () => toast.error('Clipboard refused')));
|
||||||
|
action('→ Claude', () => {
|
||||||
|
this.hooks.paste(`@${path} `);
|
||||||
|
toast.info(`Mentioned @${path} in the prompt`);
|
||||||
|
}, { title: 'Type @path into the current prompt so Claude reads the file' });
|
||||||
|
|
||||||
|
if (header.tooLarge) {
|
||||||
|
content.append(el('div', { class: 'dd-files-msg' }, `This file is ${size(header.size)}; the viewer opens files up to ${size(header.max)}.`));
|
||||||
|
} else if (header.mime?.startsWith('image/') && base64) {
|
||||||
|
content.classList.add('is-image');
|
||||||
|
content.append(el('img', { src: `data:${header.mime};base64,${base64}`, alt: path }));
|
||||||
|
} else if (header.binary || !header.body) {
|
||||||
|
content.append(el('div', { class: 'dd-files-msg' }, `Binary file (${size(header.size)}).`));
|
||||||
|
} else if (editor?.error) {
|
||||||
|
content.append(el('pre', { class: 'dd-plain' }, text(base64, header.utf8)));
|
||||||
|
toast.warning(`Plain view: ${editor.error.message}`);
|
||||||
|
} else if (wanted === 'preview') {
|
||||||
|
content.classList.add('is-preview');
|
||||||
|
content.append(el('iframe', {
|
||||||
|
class: 'dd-md-frame', title: `Preview of ${path}`,
|
||||||
|
sandbox: 'allow-popups allow-popups-to-escape-sandbox', srcdoc: previewDocument(editor.markdown(text(base64))),
|
||||||
|
}));
|
||||||
|
const frame = content.lastChild;
|
||||||
|
inlineImages(editor.markdown(text(base64)), session, path).then((html) => {
|
||||||
|
if (frame.isConnected) frame.srcdoc = previewDocument(html);
|
||||||
|
});
|
||||||
|
} else if (wanted === 'diff') {
|
||||||
|
this.editorView = editor.diff(content, { original: text(original?.base64), modified: text(base64), path, wrap: this.wrap });
|
||||||
|
} else {
|
||||||
|
this.editorView = editor.viewer(content, { doc: text(base64, header.utf8), path, wrap: this.wrap });
|
||||||
|
}
|
||||||
|
|
||||||
|
const meta = [
|
||||||
|
header.size !== undefined && !header.tooLarge ? size(header.size) : '',
|
||||||
|
header.mtime ? `changed ${ago(header.mtime)}` : '',
|
||||||
|
header.utf8 === false ? 'not UTF-8 (shown as Latin-1)' : '',
|
||||||
|
wanted === 'diff' ? 'diff against HEAD' : '',
|
||||||
|
change ? statusOf(change)[1] : '',
|
||||||
|
change?.claude ? 'edited by Claude' : '',
|
||||||
|
].filter(Boolean).join(' · ');
|
||||||
|
const stale = el('div', { class: 'dd-viewer-stale', hidden: true },
|
||||||
|
'This file changed on disk. ', el('button', { type: 'button', class: 'dd-viewer-btn', onclick: () => this.openFile(path, wanted) }, 'Reload'));
|
||||||
|
this.body.replaceChildren(
|
||||||
|
el('div', { class: 'dd-viewer-bar' },
|
||||||
|
el('button', { type: 'button', class: 'dd-viewer-btn dd-viewer-back', title: 'Back (Esc)', onclick: () => this.back() }, '←'),
|
||||||
|
el('span', { class: 'dd-viewer-meta' }, meta),
|
||||||
|
el('span', { class: 'dd-viewer-actions' }, ...actions)),
|
||||||
|
stale,
|
||||||
|
content);
|
||||||
|
// Keyboard straight into the file: arrows scroll, Ctrl+F searches, Esc goes back.
|
||||||
|
if (this.editorView) this.editorView.view.focus();
|
||||||
|
else this.body.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
viewerMessage(path, text, tone) {
|
||||||
|
this.body.replaceChildren(
|
||||||
|
el('div', { class: 'dd-viewer-bar' },
|
||||||
|
el('button', { type: 'button', class: 'dd-viewer-btn dd-viewer-back', title: 'Back (Esc)', onclick: () => this.back() }, '←'),
|
||||||
|
el('span', { class: 'dd-viewer-meta' }, path)),
|
||||||
|
el('div', { class: `dd-files-msg is-${tone}` }, text));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Theme switch: the editor follows CSS variables; the preview iframe needs a re-render.
|
||||||
|
themeChanged() {
|
||||||
|
if (this.current?.mode === 'preview') this.openFile(this.current.path, 'preview');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
// The bell (house .lt-notif-* pattern): what needs you right now (waiting
|
||||||
|
// sessions, firing Grafana alerts) plus recent events you may have missed
|
||||||
|
// (a background session finished or started waiting, CI passed or failed).
|
||||||
|
// Events live in localStorage, so every tab shows the same inbox.
|
||||||
|
|
||||||
|
import { el } from './dom.js';
|
||||||
|
import { ago } from './sessions.js';
|
||||||
|
|
||||||
|
const KEY = 'devdesk.inbox';
|
||||||
|
const MAX = 30;
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
try {
|
||||||
|
const list = JSON.parse(localStorage.getItem(KEY) || '[]');
|
||||||
|
return Array.isArray(list) ? list : [];
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function save(events) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(KEY, JSON.stringify(events.slice(0, MAX)));
|
||||||
|
} catch {
|
||||||
|
// Private mode: the inbox lasts as long as the tab.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const when = (ms) => {
|
||||||
|
const a = ago(Math.floor(ms / 1000));
|
||||||
|
return a === 'now' ? 'just now' : `${a} ago`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const KINDS = {
|
||||||
|
waiting: { icon: '!', tone: 'red' },
|
||||||
|
finished: { icon: '✓', tone: 'green' },
|
||||||
|
'ci-pass': { icon: '✓', tone: 'green' },
|
||||||
|
'ci-fail': { icon: '✗', tone: 'red' },
|
||||||
|
};
|
||||||
|
|
||||||
|
export class Inbox {
|
||||||
|
// hooks: openSession(name), showAlerts()
|
||||||
|
constructor({ button, badge, panel, hooks }) {
|
||||||
|
Object.assign(this, { button, badge, panel, hooks });
|
||||||
|
this.events = load();
|
||||||
|
this.waiting = [];
|
||||||
|
this.alerts = [];
|
||||||
|
this.list = panel.querySelector('.lt-notif-panel-list');
|
||||||
|
panel.querySelector('.lt-notif-panel-clear').addEventListener('click', () => this.markAllRead());
|
||||||
|
window.addEventListener('storage', (event) => {
|
||||||
|
if (event.key === KEY) {
|
||||||
|
this.events = load();
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get isOpen() {
|
||||||
|
return !this.panel.hasAttribute('aria-hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
setOpen(open) {
|
||||||
|
if (open) this.panel.removeAttribute('aria-hidden');
|
||||||
|
else this.panel.setAttribute('aria-hidden', 'true');
|
||||||
|
this.button.setAttribute('aria-expanded', String(open));
|
||||||
|
if (open) this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Something happened. The same kind for the same session within a minute is
|
||||||
|
// one event (several tabs, quick flaps).
|
||||||
|
record({ kind, session, text, url }) {
|
||||||
|
const now = Date.now();
|
||||||
|
if (this.events.some((e) => e.kind === kind && e.session === session && now - e.at < 60000)) return;
|
||||||
|
this.events.unshift({ id: `${now}-${Math.random().toString(36).slice(2, 7)}`, kind, session, text, url, at: now, read: false });
|
||||||
|
this.events = this.events.slice(0, MAX);
|
||||||
|
save(this.events);
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Live state: other sessions waiting on you, firing alerts.
|
||||||
|
setLive({ waiting, alerts }) {
|
||||||
|
if (waiting) this.waiting = waiting;
|
||||||
|
if (alerts) this.alerts = alerts;
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
markAllRead() {
|
||||||
|
this.events = this.events.map((e) => ({ ...e, read: true }));
|
||||||
|
save(this.events);
|
||||||
|
this.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
unread() {
|
||||||
|
return this.events.filter((e) => !e.read && e.kind !== 'waiting').length;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const count = this.waiting.length + this.alerts.length + this.unread();
|
||||||
|
const urgent = this.waiting.length > 0 || this.alerts.some((a) => a.severity === 'critical');
|
||||||
|
this.badge.textContent = count ? String(count) : '';
|
||||||
|
this.badge.dataset.count = String(count);
|
||||||
|
this.badge.classList.toggle('is-calm', count > 0 && !urgent);
|
||||||
|
this.button.title = count
|
||||||
|
? [
|
||||||
|
this.waiting.length && `${this.waiting.length} session(s) need you`,
|
||||||
|
this.alerts.length && `${this.alerts.length} alert(s) firing`,
|
||||||
|
this.unread() && `${this.unread()} new event(s)`,
|
||||||
|
].filter(Boolean).join(' · ')
|
||||||
|
: 'Inbox: nothing new';
|
||||||
|
if (this.isOpen) this.renderPanel();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderPanel() {
|
||||||
|
const close = (run) => () => {
|
||||||
|
this.setOpen(false);
|
||||||
|
run();
|
||||||
|
};
|
||||||
|
const item = ({ dot, title, meta, unread, onclick }) => el('div', {
|
||||||
|
class: `lt-notif-item${unread ? ' lt-notif-item--unread' : ''}`, role: 'button', tabindex: '0', onclick,
|
||||||
|
onkeydown: (event) => {
|
||||||
|
if (event.key === 'Enter' || event.key === ' ') {
|
||||||
|
event.preventDefault();
|
||||||
|
onclick();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
el('span', { class: `lt-notif-dot dd-notif-${dot}` }),
|
||||||
|
el('div', { class: 'lt-notif-item-body' },
|
||||||
|
el('div', { class: 'lt-notif-item-title' }, title),
|
||||||
|
meta ? el('div', { class: 'lt-notif-item-time' }, meta) : null));
|
||||||
|
const nodes = [];
|
||||||
|
|
||||||
|
if (this.waiting.length) {
|
||||||
|
nodes.push(el('div', { class: 'dd-notif-section' }, 'Needs you'));
|
||||||
|
for (const s of this.waiting) {
|
||||||
|
nodes.push(item({
|
||||||
|
dot: 'red', unread: true, title: `${s.name}: ${s.status?.message || 'Claude is waiting for your input'}`,
|
||||||
|
meta: s.status?.since ? `waiting ${ago(s.status.since)}` : 'waiting',
|
||||||
|
onclick: close(() => this.hooks.openSession(s.name)),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.alerts.length) {
|
||||||
|
nodes.push(el('div', { class: 'dd-notif-section' }, 'Ops alerts'));
|
||||||
|
for (const a of this.alerts.slice(0, 5)) {
|
||||||
|
nodes.push(item({
|
||||||
|
dot: a.severity === 'critical' ? 'red' : 'amber', title: `${a.severity ? `${a.severity}: ` : ''}${a.name}`,
|
||||||
|
meta: [a.state, a.summary].filter(Boolean).join(' · '), onclick: close(() => this.hooks.showAlerts()),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (this.alerts.length > 5) nodes.push(el('div', { class: 'dd-notif-more' }, `+${this.alerts.length - 5} more in the Ops Alerts panel`));
|
||||||
|
}
|
||||||
|
const recent = this.events.filter((e) => e.kind !== 'waiting' || !this.waiting.some((s) => s.name === e.session));
|
||||||
|
if (recent.length) {
|
||||||
|
nodes.push(el('div', { class: 'dd-notif-section' }, 'Recent'));
|
||||||
|
for (const e of recent.slice(0, 12)) {
|
||||||
|
const kind = KINDS[e.kind] ?? { tone: 'cyan' };
|
||||||
|
nodes.push(item({
|
||||||
|
dot: e.read ? 'read' : kind.tone, unread: !e.read, title: e.text, meta: when(e.at),
|
||||||
|
onclick: close(() => {
|
||||||
|
this.events = this.events.map((x) => (x.id === e.id ? { ...x, read: true } : x));
|
||||||
|
save(this.events);
|
||||||
|
if (e.url) window.open(e.url, '_blank', 'noopener');
|
||||||
|
else if (e.session) this.hooks.openSession(e.session);
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!nodes.length) nodes.push(el('div', { class: 'dd-notif-empty' }, 'Nothing needs you. Sessions that finish or wait while you\'re elsewhere show up here.'));
|
||||||
|
this.list.replaceChildren(...nodes);
|
||||||
|
}
|
||||||
|
}
|
||||||
+328
-32
@@ -1,14 +1,19 @@
|
|||||||
/* global __DEVDESK_VERSION__ */
|
/* global __DEVDESK_VERSION__ */
|
||||||
import { createTerminal, loadFonts } from './term.js';
|
import { THEMES, createTerminal, loadFonts } from './term.js';
|
||||||
|
import { getTheme, initTheme, onThemeChange, toggleTheme } from './theme.js';
|
||||||
import {
|
import {
|
||||||
TtydConnection, fetchAlerts, fetchRepo, fetchToken, uploadFile, AuthExpiredError, UnauthorizedError,
|
TtydConnection, fetchAlerts, fetchRepo, fetchToken, uploadFile, AuthExpiredError, UnauthorizedError,
|
||||||
} from './connection.js';
|
} from './connection.js';
|
||||||
import { parseTitle, pasteSafe, sessionFromSearch } from './protocol.js';
|
import { parseTitle, pasteSafe, sessionFromSearch } from './protocol.js';
|
||||||
import { SessionsPanel, el, recentNames, rememberSession, sessionStatus } from './sessions.js';
|
import { SessionsPanel, recentNames, rememberSession, sessionStatus } from './sessions.js';
|
||||||
import { renderAlerts } from './alerts.js';
|
import { renderAlerts } from './alerts.js';
|
||||||
import { renderRepo } from './repo.js';
|
import { renderRepo } from './repo.js';
|
||||||
import { bindAskClaude } from './widgets.js';
|
import { bindAskClaude } from './widgets.js';
|
||||||
import { heardWithin, onShared, share } from './shared.js';
|
import { heardWithin, onShared, share } from './shared.js';
|
||||||
|
import { CommandPalette, dialogOpen, openDialog, toast } from './ui.js';
|
||||||
|
import { Inbox } from './inbox.js';
|
||||||
|
import { FilesPane } from './files.js';
|
||||||
|
import { el } from './dom.js';
|
||||||
import * as notify from './notify.js';
|
import * as notify from './notify.js';
|
||||||
|
|
||||||
const $ = (id) => document.getElementById(id);
|
const $ = (id) => document.getElementById(id);
|
||||||
@@ -49,7 +54,6 @@ const ui = {
|
|||||||
moreMenu: $('more-menu'),
|
moreMenu: $('more-menu'),
|
||||||
notifyButton: $('notify-toggle'),
|
notifyButton: $('notify-toggle'),
|
||||||
sidebarButton: $('sidebar-toggle'),
|
sidebarButton: $('sidebar-toggle'),
|
||||||
panelsBadge: $('panels-badge'),
|
|
||||||
backdrop: $('backdrop'),
|
backdrop: $('backdrop'),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -70,6 +74,10 @@ const isNarrow = () => !window.matchMedia('(min-width: 1100px)').matches;
|
|||||||
let term;
|
let term;
|
||||||
let fit;
|
let fit;
|
||||||
let sessionsPanel;
|
let sessionsPanel;
|
||||||
|
let palette;
|
||||||
|
let inbox;
|
||||||
|
let files;
|
||||||
|
let lastRepo = null;
|
||||||
let lastAlerts = null;
|
let lastAlerts = null;
|
||||||
let waitingOthers = [];
|
let waitingOthers = [];
|
||||||
let paneTitleRaw = '';
|
let paneTitleRaw = '';
|
||||||
@@ -125,6 +133,7 @@ function renderSessionChip() {
|
|||||||
// waiting (devdesk#15), and the Panels badge. Only the tab that fetched the list
|
// waiting (devdesk#15), and the Panels badge. Only the tab that fetched the list
|
||||||
// notifies, so several open tabs don't ring once each.
|
// notifies, so several open tabs don't ring once each.
|
||||||
let prevWaiting = new Set();
|
let prevWaiting = new Set();
|
||||||
|
const prevStatus = new Map();
|
||||||
function renderAttention(fetched) {
|
function renderAttention(fetched) {
|
||||||
const data = sessionsPanel?.data;
|
const data = sessionsPanel?.data;
|
||||||
waitingOthers = (data?.sessions ?? []).filter((s) => s.name !== state.session && sessionStatus(s).key === 'waiting');
|
waitingOthers = (data?.sessions ?? []).filter((s) => s.name !== state.session && sessionStatus(s).key === 'waiting');
|
||||||
@@ -132,6 +141,7 @@ function renderAttention(fetched) {
|
|||||||
if (fetched && !prevWaiting.has(s.name)) notify.ring(s.name, s.status?.message || 'Claude needs your input');
|
if (fetched && !prevWaiting.has(s.name)) notify.ring(s.name, s.status?.message || 'Claude needs your input');
|
||||||
}
|
}
|
||||||
prevWaiting = new Set(waitingOthers.map((s) => s.name));
|
prevWaiting = new Set(waitingOthers.map((s) => s.name));
|
||||||
|
if (fetched) recordTransitions(data?.sessions ?? []);
|
||||||
ui.attention.classList.toggle('is-active', waitingOthers.length > 0);
|
ui.attention.classList.toggle('is-active', waitingOthers.length > 0);
|
||||||
ui.attention.textContent = waitingOthers.length === 1 ? `${waitingOthers[0].name} needs you` : `${waitingOthers.length} need you`;
|
ui.attention.textContent = waitingOthers.length === 1 ? `${waitingOthers[0].name} needs you` : `${waitingOthers.length} need you`;
|
||||||
ui.attention.title = waitingOthers.map((s) => `${s.name}: ${s.status?.message || 'waiting'}`).join('\n');
|
ui.attention.title = waitingOthers.map((s) => `${s.name}: ${s.status?.message || 'waiting'}`).join('\n');
|
||||||
@@ -139,17 +149,27 @@ function renderAttention(fetched) {
|
|||||||
renderPanelsBadge();
|
renderPanelsBadge();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inbox events for what happened while you were elsewhere: a session (other than
|
||||||
|
// the one you're looking at) finished a turn or started waiting. Only the tab
|
||||||
|
// that fetched the list records them; the inbox is shared via localStorage.
|
||||||
|
function recordTransitions(sessions) {
|
||||||
|
for (const s of sessions) {
|
||||||
|
const key = sessionStatus(s).key;
|
||||||
|
const prev = prevStatus.get(s.name);
|
||||||
|
prevStatus.set(s.name, key);
|
||||||
|
if (!prev || prev === key) continue;
|
||||||
|
const away = s.name !== state.session || document.hidden;
|
||||||
|
if (!away) continue;
|
||||||
|
if (key === 'waiting') {
|
||||||
|
inbox.record({ kind: 'waiting', session: s.name, text: `${s.name} needs you: ${s.status?.message || 'Claude is waiting for your input'}` });
|
||||||
|
} else if (prev === 'working' && key === 'idle') {
|
||||||
|
inbox.record({ kind: 'finished', session: s.name, text: `${s.name} finished` });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function renderPanelsBadge() {
|
function renderPanelsBadge() {
|
||||||
const alerts = lastAlerts?.alerts ?? [];
|
inbox?.setLive({ waiting: waitingOthers, alerts: lastAlerts?.alerts ?? [] });
|
||||||
const count = waitingOthers.length + alerts.length;
|
|
||||||
const urgent = waitingOthers.length > 0 || alerts.some((a) => a.severity === 'critical');
|
|
||||||
ui.panelsBadge.hidden = count === 0 || ui.body.classList.contains('dd-sidebar-open');
|
|
||||||
ui.panelsBadge.textContent = String(count);
|
|
||||||
ui.panelsBadge.classList.toggle('is-urgent', urgent);
|
|
||||||
ui.panelsBadge.title = [
|
|
||||||
waitingOthers.length ? `${waitingOthers.length} session(s) need you` : '',
|
|
||||||
alerts.length ? `${alerts.length} Grafana alert(s)` : '',
|
|
||||||
].filter(Boolean).join(' · ');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSessionData({ fetched = false } = {}) {
|
function onSessionData({ fetched = false } = {}) {
|
||||||
@@ -193,7 +213,7 @@ function uploadMessage(text, isError = false, sticky = false) {
|
|||||||
async function attachFiles(files) {
|
async function attachFiles(files) {
|
||||||
if (!files.length) return;
|
if (!files.length) return;
|
||||||
if (!state.session || !state.conn?.isOpen) {
|
if (!state.session || !state.conn?.isOpen) {
|
||||||
uploadMessage('Open a session first: files are attached to the current session.', true);
|
toast.warning('Open a session first: files are attached to the current session.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const session = state.session;
|
const session = state.session;
|
||||||
@@ -204,15 +224,17 @@ async function attachFiles(files) {
|
|||||||
uploadMessage(`Uploading ${file.name || 'image'}… ${Math.round(p * 100)}%`, false, true));
|
uploadMessage(`Uploading ${file.name || 'image'}… ${Math.round(p * 100)}%`, false, true));
|
||||||
paths.push(path);
|
paths.push(path);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
uploadMessage(`${file.name || 'file'}: ${error.message}`, true);
|
uploadUi.hidden = true;
|
||||||
|
toast.error(`${file.name || 'file'}: ${error.message}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
uploadUi.hidden = true;
|
||||||
if (session !== state.session) return;
|
if (session !== state.session) return;
|
||||||
// A pasted image path makes Claude attach the image itself.
|
// A pasted image path makes Claude attach the image itself.
|
||||||
term.paste(`${paths.join(' ')} `);
|
term.paste(`${paths.join(' ')} `);
|
||||||
term.focus();
|
term.focus();
|
||||||
uploadMessage(paths.length === 1 ? `Attached ${paths[0]}` : `Attached ${paths.length} files`);
|
toast.success(paths.length === 1 ? `Attached ${paths[0].split('/').pop()}` : `Attached ${paths.length} files`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function wireUploads() {
|
function wireUploads() {
|
||||||
@@ -257,6 +279,7 @@ let repoBusy = false;
|
|||||||
async function refreshRepo() {
|
async function refreshRepo() {
|
||||||
const session = state.session;
|
const session = state.session;
|
||||||
if (!session) {
|
if (!session) {
|
||||||
|
lastRepo = null;
|
||||||
renderRepo($('widget-repo'), null);
|
renderRepo($('widget-repo'), null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -266,10 +289,14 @@ async function refreshRepo() {
|
|||||||
const repo = await fetchRepo(session);
|
const repo = await fetchRepo(session);
|
||||||
if (session !== state.session) return;
|
if (session !== state.session) return;
|
||||||
renderRepo($('widget-repo'), repo);
|
renderRepo($('widget-repo'), repo);
|
||||||
|
lastRepo = repo;
|
||||||
const key = `${session}@${repo.sha}`;
|
const key = `${session}@${repo.sha}`;
|
||||||
const ci = repo.ci?.total ? repo.ci.state : '';
|
const ci = repo.ci?.total ? repo.ci.state : '';
|
||||||
if (key === lastCi.key && lastCi.state === 'pending' && ['success', 'failure', 'error'].includes(ci)) {
|
if (key === lastCi.key && lastCi.state === 'pending' && ['success', 'failure', 'error'].includes(ci)) {
|
||||||
notify.ring(session, `CI ${ci === 'success' ? 'passed' : 'failed'} on ${repo.branch} @ ${repo.sha}`);
|
const text = `CI ${ci === 'success' ? 'passed' : 'failed'} on ${repo.branch} @ ${repo.sha}`;
|
||||||
|
notify.ring(session, text);
|
||||||
|
toast[ci === 'success' ? 'success' : 'error'](text);
|
||||||
|
inbox.record({ kind: ci === 'success' ? 'ci-pass' : 'ci-fail', session, text: `${session}: ${text}`, url: repo.ci?.url });
|
||||||
}
|
}
|
||||||
lastCi = { key, state: ci };
|
lastCi = { key, state: ci };
|
||||||
} catch {
|
} catch {
|
||||||
@@ -305,6 +332,7 @@ function connect(session, { reconnect = false } = {}) {
|
|||||||
paneTitleRaw = '';
|
paneTitleRaw = '';
|
||||||
renderPaneTitle();
|
renderPaneTitle();
|
||||||
onSessionData();
|
onSessionData();
|
||||||
|
files?.sessionChanged();
|
||||||
hideOverlay();
|
hideOverlay();
|
||||||
setWsState('connecting', 'connecting');
|
setWsState('connecting', 'connecting');
|
||||||
state.openedAt = 0;
|
state.openedAt = 0;
|
||||||
@@ -440,6 +468,7 @@ function applyTitle() {
|
|||||||
sessionsPanel.setCurrent(parsed.session);
|
sessionsPanel.setCurrent(parsed.session);
|
||||||
onSessionData();
|
onSessionData();
|
||||||
refreshRepo();
|
refreshRepo();
|
||||||
|
files?.sessionChanged();
|
||||||
}
|
}
|
||||||
paneTitleRaw = parsed.pane;
|
paneTitleRaw = parsed.pane;
|
||||||
renderPaneTitle();
|
renderPaneTitle();
|
||||||
@@ -469,6 +498,7 @@ function closeMenus() {
|
|||||||
menu.hidden = true;
|
menu.hidden = true;
|
||||||
button.setAttribute('aria-expanded', 'false');
|
button.setAttribute('aria-expanded', 'false');
|
||||||
}
|
}
|
||||||
|
if (inbox?.isOpen) inbox.setOpen(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Session switcher on the session chip (devdesk#16).
|
// Session switcher on the session chip (devdesk#16).
|
||||||
@@ -497,10 +527,7 @@ function renderSwitcher() {
|
|||||||
el('div', { class: 'dd-menu-sep' }),
|
el('div', { class: 'dd-menu-sep' }),
|
||||||
el('button', {
|
el('button', {
|
||||||
type: 'button', role: 'menuitem', class: 'dd-menu-item',
|
type: 'button', role: 'menuitem', class: 'dd-menu-item',
|
||||||
onclick: choose(() => {
|
onclick: choose(() => sessionsPanel.newDialog()),
|
||||||
setSidebar(true);
|
|
||||||
sessionsPanel.toggleForm(true);
|
|
||||||
}),
|
|
||||||
}, '+ New session…'),
|
}, '+ New session…'),
|
||||||
el('button', { type: 'button', role: 'menuitem', class: 'dd-menu-item', onclick: choose(() => connect(null)) }, 'Open picker'),
|
el('button', { type: 'button', role: 'menuitem', class: 'dd-menu-item', onclick: choose(() => connect(null)) }, 'Open picker'),
|
||||||
);
|
);
|
||||||
@@ -509,13 +536,206 @@ function renderSwitcher() {
|
|||||||
// ---------------------------------------------------------------- chrome controls
|
// ---------------------------------------------------------------- chrome controls
|
||||||
|
|
||||||
function setFontSize(size) {
|
function setFontSize(size) {
|
||||||
|
if (!Number.isFinite(size)) return;
|
||||||
const clamped = Math.min(24, Math.max(10, size));
|
const clamped = Math.min(24, Math.max(10, size));
|
||||||
term.options.fontSize = clamped;
|
term.options.fontSize = clamped;
|
||||||
store.set('fontSize', clamped);
|
store.set('fontSize', clamped);
|
||||||
|
document.documentElement.style.setProperty('--dd-editor-font', `${clamped - 1}px`);
|
||||||
$('font-size').textContent = String(clamped);
|
$('font-size').textContent = String(clamped);
|
||||||
fit.fit();
|
fit.fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function toggleNotifications() {
|
||||||
|
const current = notify.notificationsState();
|
||||||
|
if (current === 'default') {
|
||||||
|
const result = await notify.requestNotifications();
|
||||||
|
if (result === 'granted') toast.success('Desktop notifications on');
|
||||||
|
else if (result === 'denied') toast.warning('The browser blocked notifications for this site');
|
||||||
|
} else if (current === 'granted') {
|
||||||
|
notify.setMuted(!notify.isMuted());
|
||||||
|
toast.info(notify.isMuted() ? 'Desktop notifications muted in this browser' : 'Desktop notifications unmuted');
|
||||||
|
} else {
|
||||||
|
toast.warning(current === 'denied' ? 'Notifications are blocked in the browser\'s site settings' : 'This browser has no notifications');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- palette & help
|
||||||
|
|
||||||
|
const sendKeys = (keys) => state.conn?.sendInput(keys);
|
||||||
|
|
||||||
|
async function copyLink() {
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
url.search = state.session ? `?arg=${encodeURIComponent(state.session)}` : '';
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(url.href);
|
||||||
|
toast.success('Link copied');
|
||||||
|
} catch {
|
||||||
|
toast.error('Could not copy: the browser refused clipboard access');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const openUrl = (url) => window.open(url, '_blank', 'noopener');
|
||||||
|
|
||||||
|
// Commands for the palette (devdesk#32), rebuilt on every open.
|
||||||
|
function buildCommands() {
|
||||||
|
const sessions = [...(sessionsPanel?.data?.sessions ?? [])].sort((a, b) =>
|
||||||
|
(b.running - a.running) || ((b.activity || 0) - (a.activity || 0)) || a.name.localeCompare(b.name));
|
||||||
|
const current = sessions.find((s) => s.name === state.session);
|
||||||
|
const panelsOpen = ui.body.classList.contains('dd-sidebar-open');
|
||||||
|
const notifyState = notify.notificationsState();
|
||||||
|
const commands = [];
|
||||||
|
const add = (command) => commands.push(command);
|
||||||
|
|
||||||
|
for (const s of sessions) {
|
||||||
|
if (s.name === state.session) continue;
|
||||||
|
const status = sessionStatus(s);
|
||||||
|
add({
|
||||||
|
id: `switch:${s.name}`, group: 'Sessions', label: `Switch to ${s.name}`, hint: status.label, keywords: s.dir,
|
||||||
|
icon: status.key === 'waiting' ? '!' : s.running ? '●' : '○', run: () => connect(s.name),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
add({ id: 'new', group: 'Sessions', icon: '+', label: 'New session…', keywords: 'create open project', run: () => sessionsPanel.newDialog() });
|
||||||
|
if (state.session) {
|
||||||
|
add({ id: 'rename', group: 'Sessions', icon: '✎', label: `Rename ${state.session}…`, run: () => sessionsPanel.rename(state.session) });
|
||||||
|
add({
|
||||||
|
id: 'end', group: 'Sessions', icon: '×', label: `End ${state.session}…`, keywords: 'close kill stop',
|
||||||
|
run: () => sessionsPanel.end(current ?? { name: state.session, running: true }),
|
||||||
|
});
|
||||||
|
add({ id: 'copy-link', group: 'Sessions', icon: '⧉', label: 'Copy link to this session', keywords: 'url share', run: copyLink });
|
||||||
|
}
|
||||||
|
add({ id: 'picker', group: 'Sessions', icon: '≡', label: 'Open the session picker', keywords: 'fzf list', run: () => connect(null) });
|
||||||
|
|
||||||
|
if (state.session && state.conn?.isOpen) {
|
||||||
|
add({ id: 'win-claude', group: 'Terminal', icon: '0', label: 'Claude window', kbd: '^b 0', run: () => sendKeys('\x020') });
|
||||||
|
add({ id: 'win-shell', group: 'Terminal', icon: '1', label: 'Shell window', kbd: '^b 1', run: () => sendKeys('\x021') });
|
||||||
|
add({ id: 'scroll', group: 'Terminal', icon: '⇞', label: 'Scroll back (tmux copy mode, q to leave)', kbd: '^b [', keywords: 'history scrollback', run: () => sendKeys('\x02[') });
|
||||||
|
add({ id: 'detach', group: 'Terminal', icon: '⏏', label: 'Detach (the session keeps running)', kbd: '^b d', run: () => sendKeys('\x02d') });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state.session) {
|
||||||
|
add({ id: 'files', group: 'Files', icon: '🗀', label: files.isOpen ? 'Close files' : 'Browse files', kbd: 'Ctrl+⇧E', keywords: 'explorer folder read open view', run: () => files.toggle('files') });
|
||||||
|
add({ id: 'changes', group: 'Files', icon: '±', label: 'Review changes (git diff)', keywords: 'git status diff claude edits', run: () => files.open('changes') });
|
||||||
|
}
|
||||||
|
add({
|
||||||
|
id: 'theme', group: 'View', icon: getTheme() === 'light' ? '◐' : '☀', keywords: 'theme light dark mode colour color',
|
||||||
|
label: getTheme() === 'light' ? 'Switch to dark mode' : 'Switch to light mode', run: toggleTheme,
|
||||||
|
});
|
||||||
|
add({ id: 'panels', group: 'View', icon: '▤', label: panelsOpen ? 'Hide panels' : 'Show panels', keywords: 'sidebar', run: () => setSidebar(!panelsOpen) });
|
||||||
|
add({ id: 'font-up', group: 'View', icon: 'A+', label: 'Larger text', keywords: 'font zoom', run: () => setFontSize(term.options.fontSize + 1) });
|
||||||
|
add({ id: 'font-down', group: 'View', icon: 'A−', label: 'Smaller text', keywords: 'font zoom', run: () => setFontSize(term.options.fontSize - 1) });
|
||||||
|
add({ id: 'font-reset', group: 'View', icon: 'A', label: 'Reset text size', keywords: 'font zoom', run: () => setFontSize(14) });
|
||||||
|
add({ id: 'fullscreen', group: 'View', icon: '⛶', label: document.fullscreenElement ? 'Exit fullscreen' : 'Fullscreen', run: toggleFullscreen });
|
||||||
|
if (notifyState !== 'unsupported') {
|
||||||
|
add({
|
||||||
|
id: 'notify', group: 'View', icon: '🔔', keywords: 'notifications alerts bell',
|
||||||
|
label: { default: 'Enable desktop notifications', denied: 'Desktop notifications (blocked)', granted: notify.isMuted() ? 'Unmute desktop notifications' : 'Mute desktop notifications' }[notifyState],
|
||||||
|
run: () => toggleNotifications().then(renderNotifyButton),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastRepo?.url) {
|
||||||
|
add({ id: 'open-repo', group: 'Links', icon: '↗', label: `Open ${lastRepo.repo} in Gitea`, run: () => openUrl(lastRepo.url) });
|
||||||
|
add({ id: 'open-prs', group: 'Links', icon: '↗', label: 'Open pull requests', run: () => openUrl(`${lastRepo.url}/pulls`) });
|
||||||
|
if (lastRepo.ci?.url) add({ id: 'open-ci', group: 'Links', icon: '↗', label: `Open CI run (${lastRepo.ci.state})`, run: () => openUrl(lastRepo.ci.url) });
|
||||||
|
}
|
||||||
|
if (lastAlerts?.alerts?.length) {
|
||||||
|
add({
|
||||||
|
id: 'alerts', group: 'Links', icon: '!', label: `Show ${lastAlerts.alerts.length} ops alert(s)`, keywords: 'grafana',
|
||||||
|
run: () => {
|
||||||
|
setSidebar(true);
|
||||||
|
$('widget-alerts').scrollIntoView({ block: 'start', behavior: 'smooth' });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
add({ id: 'help', group: 'Help', icon: '?', label: 'Keyboard shortcuts', keywords: 'keys help', run: showHelp });
|
||||||
|
|
||||||
|
// After a command, typing goes back to the terminal unless it opened a dialog.
|
||||||
|
return commands.map((c) => ({
|
||||||
|
...c,
|
||||||
|
run: () => {
|
||||||
|
c.run();
|
||||||
|
if (!dialogOpen()) term.focus();
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
const KEY_HELP = [
|
||||||
|
['Claude', [
|
||||||
|
['⇧ Enter', 'New line in the prompt'],
|
||||||
|
['Esc', 'Interrupt Claude'],
|
||||||
|
['⇧ Tab', 'Cycle mode (auto-accept, plan…)'],
|
||||||
|
['↑ / ↓', 'Previous / next prompt'],
|
||||||
|
['Ctrl+C', 'Cancel; twice to quit (the menu offers resume)'],
|
||||||
|
]],
|
||||||
|
['Windows & sessions (tmux)', [
|
||||||
|
['Ctrl-b 0 / 1', 'Claude window / shell window'],
|
||||||
|
['Ctrl-b s', 'Switch session (the URL follows)'],
|
||||||
|
['Ctrl-b [', 'Scroll back; q to leave'],
|
||||||
|
['Ctrl-b d', 'Detach (the session keeps running)'],
|
||||||
|
]],
|
||||||
|
['DevDesk', [
|
||||||
|
['Ctrl+⇧ P', 'Command palette'],
|
||||||
|
['Ctrl+⇧ E', 'Files: browse, preview, diff (Esc closes)'],
|
||||||
|
['Ctrl+⇧ C / V', 'Copy selection / paste'],
|
||||||
|
['⇧ drag', 'Select text in the browser'],
|
||||||
|
['Drop or paste a file', 'Upload it and attach it for Claude'],
|
||||||
|
['Ctrl+W', 'Asks before closing; Chromium fullscreen keeps it for the terminal'],
|
||||||
|
]],
|
||||||
|
];
|
||||||
|
|
||||||
|
function showHelp() {
|
||||||
|
const body = el('div', { class: 'dd-keys' }, ...KEY_HELP.map(([title, rows]) => el('section', {},
|
||||||
|
el('h3', { class: 'dd-keys-title' }, title),
|
||||||
|
el('dl', { class: 'dd-keys-list' }, ...rows.flatMap(([keys, what]) => [el('dt', {}, el('kbd', {}, keys)), el('dd', {}, what)])))));
|
||||||
|
if (touch) body.append(el('p', { class: 'dd-dialog-hint' }, 'On a phone, the key bar under the terminal sends Esc, Tab, ⇧Tab, Ctrl+C, arrows, Enter and the window switches.'));
|
||||||
|
openDialog({ title: 'Keyboard shortcuts', body, actions: [{ label: 'Close', primary: true }] }).then(() => term.focus());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drag the files pane's left edge (or use ←/→ on it). The terminal keeps at
|
||||||
|
// least ~60 columns; the width is remembered per browser.
|
||||||
|
function wireResizer() {
|
||||||
|
const main = document.querySelector('.dd-main');
|
||||||
|
const handle = $('files-resizer');
|
||||||
|
const apply = (px) => {
|
||||||
|
const max = main.clientWidth - 520;
|
||||||
|
const width = Math.round(Math.max(340, Math.min(max, px)));
|
||||||
|
main.style.setProperty('--dd-files-w', `${width}px`);
|
||||||
|
return width;
|
||||||
|
};
|
||||||
|
const saved = Number(store.get('filesWidth', 0));
|
||||||
|
if (saved) apply(saved);
|
||||||
|
handle.addEventListener('pointerdown', (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
handle.setPointerCapture(event.pointerId);
|
||||||
|
ui.body.classList.add('dd-resizing');
|
||||||
|
const move = (e) => apply(main.getBoundingClientRect().right - e.clientX);
|
||||||
|
const up = () => {
|
||||||
|
ui.body.classList.remove('dd-resizing');
|
||||||
|
handle.removeEventListener('pointermove', move);
|
||||||
|
handle.removeEventListener('pointerup', up);
|
||||||
|
store.set('filesWidth', $('files').getBoundingClientRect().width);
|
||||||
|
};
|
||||||
|
handle.addEventListener('pointermove', move);
|
||||||
|
handle.addEventListener('pointerup', up);
|
||||||
|
});
|
||||||
|
handle.addEventListener('keydown', (event) => {
|
||||||
|
if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return;
|
||||||
|
event.preventDefault();
|
||||||
|
const width = apply($('files').getBoundingClientRect().width + (event.key === 'ArrowLeft' ? 40 : -40));
|
||||||
|
store.set('filesWidth', width);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggleFullscreen() {
|
||||||
|
if (document.fullscreenElement) {
|
||||||
|
await document.exitFullscreen();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await document.documentElement.requestFullscreen();
|
||||||
|
// Chromium: capture Ctrl+W/Ctrl+T/Esc etc. for the terminal while fullscreen.
|
||||||
|
navigator.keyboard?.lock?.().catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
function renderNotifyButton() {
|
function renderNotifyButton() {
|
||||||
const current = notify.notificationsState();
|
const current = notify.notificationsState();
|
||||||
const labels = {
|
const labels = {
|
||||||
@@ -529,6 +749,7 @@ function renderNotifyButton() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setSidebar(open) {
|
function setSidebar(open) {
|
||||||
|
if (open && files?.isOpen) files.close();
|
||||||
ui.body.classList.toggle('dd-sidebar-open', open);
|
ui.body.classList.toggle('dd-sidebar-open', open);
|
||||||
ui.sidebarButton.setAttribute('aria-expanded', String(open));
|
ui.sidebarButton.setAttribute('aria-expanded', String(open));
|
||||||
ui.backdrop.hidden = !(open && isNarrow());
|
ui.backdrop.hidden = !(open && isNarrow());
|
||||||
@@ -578,21 +799,80 @@ function wireChrome() {
|
|||||||
$('font-down').addEventListener('click', () => setFontSize(term.options.fontSize - 1));
|
$('font-down').addEventListener('click', () => setFontSize(term.options.fontSize - 1));
|
||||||
$('font-up').addEventListener('click', () => setFontSize(term.options.fontSize + 1));
|
$('font-up').addEventListener('click', () => setFontSize(term.options.fontSize + 1));
|
||||||
ui.notifyButton.addEventListener('click', async () => {
|
ui.notifyButton.addEventListener('click', async () => {
|
||||||
if (notify.notificationsState() === 'default') await notify.requestNotifications();
|
await toggleNotifications();
|
||||||
else if (notify.notificationsState() === 'granted') notify.setMuted(!notify.isMuted());
|
|
||||||
renderNotifyButton();
|
renderNotifyButton();
|
||||||
});
|
});
|
||||||
$('fullscreen-toggle').addEventListener('click', async () => {
|
$('fullscreen-toggle').addEventListener('click', () => {
|
||||||
closeMenus();
|
closeMenus();
|
||||||
if (document.fullscreenElement) {
|
toggleFullscreen();
|
||||||
await document.exitFullscreen();
|
});
|
||||||
|
$('help-open').addEventListener('click', () => {
|
||||||
|
closeMenus();
|
||||||
|
showHelp();
|
||||||
|
});
|
||||||
|
$('footer-help').addEventListener('click', showHelp);
|
||||||
|
$('palette-menu').addEventListener('click', () => {
|
||||||
|
closeMenus();
|
||||||
|
palette.open();
|
||||||
|
});
|
||||||
|
files = new FilesPane($('files'), {
|
||||||
|
session: () => state.session,
|
||||||
|
paste: (text) => {
|
||||||
|
term.paste(text);
|
||||||
|
},
|
||||||
|
focusTerminal: () => term.focus(),
|
||||||
|
onToggle: (open) => {
|
||||||
|
ui.body.classList.toggle('dd-files-open', open);
|
||||||
|
$('files-toggle').setAttribute('aria-expanded', String(open));
|
||||||
|
if (open && ui.body.classList.contains('dd-sidebar-open')) setSidebar(false);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
$('files-toggle').addEventListener('click', () => files.toggle());
|
||||||
|
wireResizer();
|
||||||
|
palette = new CommandPalette(buildCommands);
|
||||||
|
$('cmd-toggle').addEventListener('click', () => palette.open());
|
||||||
|
// Ctrl+Shift+P (⌘⇧P): Ctrl+K belongs to the terminal (kill-line in Claude and bash).
|
||||||
|
document.addEventListener('keydown', (event) => {
|
||||||
|
if ((event.ctrlKey || event.metaKey) && event.shiftKey && !event.altKey && event.code === 'KeyE') {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
if (state.session) files.toggle();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await document.documentElement.requestFullscreen();
|
if ((event.ctrlKey || event.metaKey) && event.shiftKey && !event.altKey && event.code === 'KeyP') {
|
||||||
// Chromium: capture Ctrl+W/Ctrl+T/Esc etc. for the terminal while fullscreen.
|
event.preventDefault();
|
||||||
navigator.keyboard?.lock?.().catch(() => {});
|
event.stopPropagation();
|
||||||
|
if (palette.isOpen) palette.close();
|
||||||
|
else if (!dialogOpen()) palette.open();
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
wireMenu(ui.moreToggle, ui.moreMenu, () => {
|
||||||
|
renderNotifyButton();
|
||||||
|
$('theme-menu').textContent = getTheme() === 'light' ? 'Dark mode' : 'Light mode';
|
||||||
});
|
});
|
||||||
wireMenu(ui.moreToggle, ui.moreMenu, renderNotifyButton);
|
$('theme-menu').addEventListener('click', () => {
|
||||||
|
closeMenus();
|
||||||
|
toggleTheme();
|
||||||
|
});
|
||||||
|
inbox = new Inbox({
|
||||||
|
button: $('inbox-toggle'),
|
||||||
|
badge: $('inbox-badge'),
|
||||||
|
panel: $('inbox-panel'),
|
||||||
|
hooks: {
|
||||||
|
openSession: (name) => connect(name),
|
||||||
|
showAlerts: () => {
|
||||||
|
setSidebar(true);
|
||||||
|
$('widget-alerts').scrollIntoView({ block: 'start', behavior: 'smooth' });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
$('inbox-toggle').addEventListener('click', (event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
const open = !inbox.isOpen;
|
||||||
|
closeMenus();
|
||||||
|
inbox.setOpen(open);
|
||||||
|
});
|
||||||
|
$('inbox-panel').addEventListener('click', (event) => event.stopPropagation());
|
||||||
wireMenu(ui.sessionChip, ui.switcher, () => {
|
wireMenu(ui.sessionChip, ui.switcher, () => {
|
||||||
renderSwitcher();
|
renderSwitcher();
|
||||||
sessionsPanel.refresh();
|
sessionsPanel.refresh();
|
||||||
@@ -608,8 +888,16 @@ function wireChrome() {
|
|||||||
|
|
||||||
// Esc closes menus and the narrow-screen drawer before the terminal sees it.
|
// Esc closes menus and the narrow-screen drawer before the terminal sees it.
|
||||||
document.addEventListener('keydown', (event) => {
|
document.addEventListener('keydown', (event) => {
|
||||||
if (event.key !== 'Escape') return;
|
if (event.key !== 'Escape' || dialogOpen()) return;
|
||||||
const menuOpen = menus.some(({ menu }) => !menu.hidden);
|
// Files pane: Esc goes back / closes, unless the terminal or CodeMirror's
|
||||||
|
// own search panel has the focus.
|
||||||
|
if (files?.isOpen && !event.target.closest?.('.xterm, .cm-panels') && !menus.some(({ menu }) => !menu.hidden) && !inbox.isOpen) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
files.escape();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const menuOpen = menus.some(({ menu }) => !menu.hidden) || inbox.isOpen;
|
||||||
const drawerOpen = isNarrow() && ui.body.classList.contains('dd-sidebar-open');
|
const drawerOpen = isNarrow() && ui.body.classList.contains('dd-sidebar-open');
|
||||||
if (!menuOpen && !drawerOpen) return;
|
if (!menuOpen && !drawerOpen) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -680,6 +968,7 @@ function defaultSession(data) {
|
|||||||
// ---------------------------------------------------------------- boot
|
// ---------------------------------------------------------------- boot
|
||||||
|
|
||||||
async function boot() {
|
async function boot() {
|
||||||
|
initTheme();
|
||||||
$('version').textContent = `devdesk ${__DEVDESK_VERSION__}`;
|
$('version').textContent = `devdesk ${__DEVDESK_VERSION__}`;
|
||||||
const fontSize = Math.min(24, Math.max(10, Number(store.get('fontSize', 14)) || 14));
|
const fontSize = Math.min(24, Math.max(10, Number(store.get('fontSize', 14)) || 14));
|
||||||
$('font-size').textContent = String(fontSize);
|
$('font-size').textContent = String(fontSize);
|
||||||
@@ -687,8 +976,14 @@ async function boot() {
|
|||||||
|
|
||||||
({ term, fit } = createTerminal($('terminal'), {
|
({ term, fit } = createTerminal($('terminal'), {
|
||||||
fontSize,
|
fontSize,
|
||||||
|
theme: getTheme(),
|
||||||
onShiftEnter: () => state.conn?.sendInput('\n'),
|
onShiftEnter: () => state.conn?.sendInput('\n'),
|
||||||
}));
|
}));
|
||||||
|
onThemeChange((theme) => {
|
||||||
|
term.options.theme = THEMES[theme];
|
||||||
|
files?.themeChanged();
|
||||||
|
});
|
||||||
|
$('theme-toggle').addEventListener('click', toggleTheme);
|
||||||
term.onData((data) => state.conn?.sendInput(data));
|
term.onData((data) => state.conn?.sendInput(data));
|
||||||
term.onBinary((data) => state.conn?.sendBinary(data));
|
term.onBinary((data) => state.conn?.sendBinary(data));
|
||||||
term.onResize(({ cols, rows }) => state.conn?.resize(cols, rows));
|
term.onResize(({ cols, rows }) => state.conn?.resize(cols, rows));
|
||||||
@@ -700,6 +995,7 @@ async function boot() {
|
|||||||
notify.ring(state.session, ui.paneTitle.textContent || 'Claude needs your attention');
|
notify.ring(state.session, ui.paneTitle.textContent || 'Claude needs your attention');
|
||||||
refreshSoon(); // Claude finished a turn: states and context just changed
|
refreshSoon(); // Claude finished a turn: states and context just changed
|
||||||
setTimeout(refreshRepo, 2000); // …and maybe committed or pushed
|
setTimeout(refreshRepo, 2000); // …and maybe committed or pushed
|
||||||
|
setTimeout(() => files?.claudeTurnEnded(), 1200); // …or edited files
|
||||||
});
|
});
|
||||||
|
|
||||||
let fitFrame = 0;
|
let fitFrame = 0;
|
||||||
|
|||||||
+105
-40
@@ -4,6 +4,10 @@
|
|||||||
import { fetchSessionList, sessionAction } from './connection.js';
|
import { fetchSessionList, sessionAction } from './connection.js';
|
||||||
import { slugify } from './protocol.js';
|
import { slugify } from './protocol.js';
|
||||||
import { share } from './shared.js';
|
import { share } from './shared.js';
|
||||||
|
import { el } from './dom.js';
|
||||||
|
import { confirmDialog, openDialog, toast } from './ui.js';
|
||||||
|
|
||||||
|
export { el };
|
||||||
|
|
||||||
const RECENTS_KEY = 'devdesk.recents';
|
const RECENTS_KEY = 'devdesk.recents';
|
||||||
const MAX_RECENTS = 12;
|
const MAX_RECENTS = 12;
|
||||||
@@ -51,17 +55,6 @@ export function ago(epochSeconds) {
|
|||||||
return `${Math.floor(s / 86400)}d`;
|
return `${Math.floor(s / 86400)}d`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function el(tag, attrs = {}, ...children) {
|
|
||||||
const node = document.createElement(tag);
|
|
||||||
for (const [key, value] of Object.entries(attrs)) {
|
|
||||||
if (value === undefined || value === null || value === false) continue;
|
|
||||||
if (key === 'class') node.className = value;
|
|
||||||
else if (key.startsWith('on')) node.addEventListener(key.slice(2), value);
|
|
||||||
else node.setAttribute(key, value === true ? '' : value);
|
|
||||||
}
|
|
||||||
node.append(...children.filter((c) => c !== null && c !== undefined));
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
// What Claude is doing in a session, from the devdesk-state-hook snapshot.
|
// What Claude is doing in a session, from the devdesk-state-hook snapshot.
|
||||||
// Returns { key, label, dot } for display; key is one of
|
// Returns { key, label, dot } for display; key is one of
|
||||||
@@ -114,6 +107,12 @@ export class SessionsPanel {
|
|||||||
return this.pending;
|
return this.pending;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// After an action: a poll already in flight may predate it, so fetch again.
|
||||||
|
async reload() {
|
||||||
|
await this.pending;
|
||||||
|
return this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
let fetched = false;
|
let fetched = false;
|
||||||
try {
|
try {
|
||||||
@@ -135,14 +134,13 @@ export class SessionsPanel {
|
|||||||
this.hooks.onData?.(this.data, { fetched: false });
|
this.hooks.onData?.(this.data, { fetched: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
async act(label, action, ...args) {
|
// Side-channel action; failures become an error toast (devdesk#34).
|
||||||
this.setStatus(`${label}…`);
|
async act(action, ...args) {
|
||||||
try {
|
try {
|
||||||
await sessionAction(action, ...args);
|
await sessionAction(action, ...args);
|
||||||
this.setStatus('');
|
|
||||||
return true;
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.setStatus(err.message, true);
|
toast.error(err.message);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,43 +149,116 @@ export class SessionsPanel {
|
|||||||
const project = this.select.value;
|
const project = this.select.value;
|
||||||
const name = slugify(this.nameInput.value) || project;
|
const name = slugify(this.nameInput.value) || project;
|
||||||
if (!name) {
|
if (!name) {
|
||||||
this.setStatus('Type a session name or pick a project.', true);
|
toast.warning('Type a session name or pick a project.');
|
||||||
this.nameInput.focus();
|
this.nameInput.focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// With a project the session starts in that folder; without one, in the default folder.
|
if (!(await this.create(name, project))) return;
|
||||||
if (project && !(await this.act('creating', 'new', name, project))) return;
|
|
||||||
this.nameInput.value = '';
|
this.nameInput.value = '';
|
||||||
this.select.value = '';
|
this.select.value = '';
|
||||||
this.toggleForm(false);
|
this.toggleForm(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// With a project the session starts in that folder; without one, opening it
|
||||||
|
// creates it in the default folder (or its own project folder, by name).
|
||||||
|
async create(name, project) {
|
||||||
|
if (project && !(await this.act('new', name, project))) return false;
|
||||||
this.hooks.onOpen(name);
|
this.hooks.onOpen(name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
projectOptions(select) {
|
||||||
|
const projects = this.data?.projects ?? [];
|
||||||
|
const chosen = select.value;
|
||||||
|
select.replaceChildren(
|
||||||
|
el('option', { value: '' }, `No project (${this.data?.root ?? 'default folder'})`),
|
||||||
|
...projects.filter((p) => p.name !== this.data?.default)
|
||||||
|
.map((p) => el('option', { value: p.name, title: p.dir }, p.name)));
|
||||||
|
select.value = chosen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// "+ New session…" from the switcher or the command palette (devdesk#33).
|
||||||
|
async newDialog() {
|
||||||
|
const name = el('input', { class: 'lt-input', maxlength: '64', placeholder: 'e.g. pbs-upgrade', spellcheck: 'false', autocomplete: 'off', 'aria-describedby': 'dd-new-hint' });
|
||||||
|
const project = el('select', { class: 'lt-select' });
|
||||||
|
this.projectOptions(project);
|
||||||
|
const hint = el('p', { class: 'dd-dialog-hint', id: 'dd-new-hint' }, 'Letters, numbers, - and _. Any name works; pick a project to start in its folder.');
|
||||||
|
project.addEventListener('change', () => {
|
||||||
|
if (!name.value.trim()) name.placeholder = project.value || 'e.g. pbs-upgrade';
|
||||||
|
});
|
||||||
|
const result = await openDialog({
|
||||||
|
title: 'New session',
|
||||||
|
body: el('div', { class: 'dd-dialog-fields' },
|
||||||
|
el('label', { class: 'dd-field' }, el('span', {}, 'Name'), name),
|
||||||
|
el('label', { class: 'dd-field' }, el('span', {}, 'Project folder'), project),
|
||||||
|
hint),
|
||||||
|
actions: [{ label: 'Cancel' }, { label: 'Open', primary: true }],
|
||||||
|
submit: () => {
|
||||||
|
const value = slugify(name.value) || project.value;
|
||||||
|
if (!value) {
|
||||||
|
hint.textContent = 'Type a name or pick a project.';
|
||||||
|
hint.classList.add('is-error');
|
||||||
|
name.focus();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return { name: value, project: project.value };
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (result) await this.create(result.name, result.project);
|
||||||
}
|
}
|
||||||
|
|
||||||
async rename(name) {
|
async rename(name) {
|
||||||
const answer = window.prompt(`Rename session "${name}" to:`, name);
|
const input = el('input', { class: 'lt-input', maxlength: '64', value: name, spellcheck: 'false', autocomplete: 'off', 'aria-describedby': 'dd-rename-hint' });
|
||||||
if (answer === null) return;
|
const hint = el('p', { class: 'dd-dialog-hint', id: 'dd-rename-hint' }, 'Claude keeps running; the conversation moves with the session.');
|
||||||
const next = slugify(answer);
|
const next = await openDialog({
|
||||||
if (!next || next === name) {
|
title: `Rename ${name}`,
|
||||||
if (!next) this.setStatus('Names use letters, numbers, - and _.', true);
|
size: 'sm',
|
||||||
return;
|
body: el('div', { class: 'dd-dialog-fields' }, el('label', { class: 'dd-field' }, el('span', {}, 'New name'), input), hint),
|
||||||
}
|
actions: [{ label: 'Cancel' }, { label: 'Rename', primary: true }],
|
||||||
if (await this.act('renaming', 'rename', name, next)) {
|
onOpen: () => {
|
||||||
|
input.select();
|
||||||
|
return input;
|
||||||
|
},
|
||||||
|
submit: () => {
|
||||||
|
const value = slugify(input.value);
|
||||||
|
if (!value) {
|
||||||
|
hint.textContent = 'Names use letters, numbers, - and _.';
|
||||||
|
hint.classList.add('is-error');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (value !== name && this.data?.sessions?.some((x) => x.name === value)) {
|
||||||
|
hint.textContent = `A session called ${value} already exists.`;
|
||||||
|
hint.classList.add('is-error');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!next || next === name) return;
|
||||||
|
if (await this.act('rename', name, next)) {
|
||||||
renameRecent(name, next);
|
renameRecent(name, next);
|
||||||
this.hooks.onRenamed(name, next);
|
this.hooks.onRenamed(name, next);
|
||||||
await this.refresh();
|
toast.success(`Renamed ${name} → ${next}`);
|
||||||
|
await this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async end(session) {
|
async end(session) {
|
||||||
const question = session.running
|
const ok = await confirmDialog({
|
||||||
? `End session "${session.name}"?\n\nClaude in this session stops. The conversation stays in Claude's history (claude --resume).`
|
title: session.running ? `End ${session.name}?` : `Forget ${session.name}?`,
|
||||||
: `Forget dormant session "${session.name}"?`;
|
text: session.running
|
||||||
if (!window.confirm(question)) return;
|
? 'Claude in this session stops and the session closes. The conversation stays in Claude\'s history (claude --resume).'
|
||||||
|
: 'This dormant session is removed from the list. Its conversation stays in Claude\'s history.',
|
||||||
|
confirmLabel: session.running ? 'End session' : 'Forget',
|
||||||
|
danger: true,
|
||||||
|
});
|
||||||
|
if (!ok) return;
|
||||||
if (session.name === this.current) this.hooks.onEnding?.(session.name);
|
if (session.name === this.current) this.hooks.onEnding?.(session.name);
|
||||||
if (await this.act(session.running ? 'ending' : 'forgetting', 'end', session.name)) {
|
if (await this.act('end', session.name)) {
|
||||||
forgetRecent(session.name);
|
forgetRecent(session.name);
|
||||||
this.hooks.onEnded(session.name);
|
this.hooks.onEnded(session.name);
|
||||||
await this.refresh();
|
toast.success(session.running ? `Ended ${session.name}` : `Forgot ${session.name}`);
|
||||||
|
await this.reload();
|
||||||
} else if (session.name === this.current) {
|
} else if (session.name === this.current) {
|
||||||
this.hooks.onEndAborted?.();
|
this.hooks.onEndAborted?.();
|
||||||
}
|
}
|
||||||
@@ -250,12 +321,6 @@ export class SessionsPanel {
|
|||||||
if (!items.length) items.push(el('li', { class: 'dd-empty' }, 'No sessions yet.'));
|
if (!items.length) items.push(el('li', { class: 'dd-empty' }, 'No sessions yet.'));
|
||||||
this.list.replaceChildren(...items);
|
this.list.replaceChildren(...items);
|
||||||
|
|
||||||
const projects = this.data?.projects ?? [];
|
this.projectOptions(this.select);
|
||||||
const chosen = this.select.value;
|
|
||||||
this.select.replaceChildren(
|
|
||||||
el('option', { value: '' }, `No project (${this.data?.root ?? 'default folder'})`),
|
|
||||||
...projects.filter((p) => p.name !== this.data?.default)
|
|
||||||
.map((p) => el('option', { value: p.name, title: p.dir }, p.name)));
|
|
||||||
this.select.value = chosen;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+61
-26
@@ -15,30 +15,65 @@ const writeOnlyClipboard = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// LotusGuild TDS tokens (web_template base.css :root) mapped onto the ANSI palette.
|
// Terminal palettes from the LotusGuild TDS tokens (devdesk#31).
|
||||||
export const THEME = Object.freeze({
|
//
|
||||||
background: '#010304',
|
// DevDesk runs Claude with its `dark-ansi` theme, so Claude draws with these 16
|
||||||
foreground: '#c4d9ee',
|
// colours instead of fixed RGB: body text is bright white, secondary text is
|
||||||
cursor: '#FF6B00',
|
// white, the band behind your messages is bright black, and text on coloured
|
||||||
cursorAccent: '#010304',
|
// backgrounds is black. Claude's theme is per process and printed text keeps its
|
||||||
selectionBackground: 'rgba(0, 212, 255, 0.30)',
|
// colours, so instead of switching Claude, the light palette inverts the grey
|
||||||
selectionInactiveBackground: 'rgba(0, 212, 255, 0.15)',
|
// ramp: bright white is ink, white is muted ink, bright black a light band and
|
||||||
black: '#0d1520',
|
// black the page. Anything written for dark terminals, Claude's scrollback
|
||||||
red: '#FF2D55',
|
// included, stays readable, and toggling is instant.
|
||||||
green: '#00FF88',
|
export const THEMES = Object.freeze({
|
||||||
yellow: '#FFB300',
|
dark: Object.freeze({
|
||||||
blue: '#3A8DFF',
|
background: '#010304',
|
||||||
magenta: '#BF5FFF',
|
foreground: '#c4d9ee',
|
||||||
cyan: '#00D4FF',
|
cursor: '#FF6B00',
|
||||||
white: '#c4d9ee',
|
cursorAccent: '#010304',
|
||||||
brightBlack: '#3e607a',
|
selectionBackground: 'rgba(0, 212, 255, 0.30)',
|
||||||
brightRed: '#FF5C7A',
|
selectionInactiveBackground: 'rgba(0, 212, 255, 0.15)',
|
||||||
brightGreen: '#33FFAA',
|
black: '#0d1520',
|
||||||
brightYellow: '#FFD700',
|
red: '#FF2D55',
|
||||||
brightBlue: '#6AA8FF',
|
green: '#00FF88',
|
||||||
brightMagenta: '#D08CFF',
|
yellow: '#FFB300',
|
||||||
brightCyan: '#33DFFF',
|
blue: '#3A8DFF',
|
||||||
brightWhite: '#FFFFFF',
|
magenta: '#BF5FFF',
|
||||||
|
cyan: '#00D4FF',
|
||||||
|
white: '#9fb6cc',
|
||||||
|
brightBlack: '#3e607a',
|
||||||
|
brightRed: '#FF5C7A',
|
||||||
|
brightGreen: '#33FFAA',
|
||||||
|
brightYellow: '#FFD700',
|
||||||
|
brightBlue: '#6AA8FF',
|
||||||
|
brightMagenta: '#D08CFF',
|
||||||
|
brightCyan: '#33DFFF',
|
||||||
|
brightWhite: '#FFFFFF',
|
||||||
|
}),
|
||||||
|
light: Object.freeze({
|
||||||
|
background: '#f4f6fa',
|
||||||
|
foreground: '#16202e',
|
||||||
|
cursor: '#c44e00',
|
||||||
|
cursorAccent: '#f4f6fa',
|
||||||
|
selectionBackground: 'rgba(0, 98, 184, 0.22)',
|
||||||
|
selectionInactiveBackground: 'rgba(0, 98, 184, 0.12)',
|
||||||
|
black: '#eef1f6',
|
||||||
|
red: '#b5001f',
|
||||||
|
green: '#006d35',
|
||||||
|
yellow: '#8a5a00',
|
||||||
|
blue: '#1f4fbf',
|
||||||
|
magenta: '#6b2fb8',
|
||||||
|
cyan: '#006b86',
|
||||||
|
white: '#556578',
|
||||||
|
brightBlack: '#c9d1dc',
|
||||||
|
brightRed: '#cc1f3d',
|
||||||
|
brightGreen: '#00803e',
|
||||||
|
brightYellow: '#9a6400',
|
||||||
|
brightBlue: '#0062b8',
|
||||||
|
brightMagenta: '#7e3fd0',
|
||||||
|
brightCyan: '#007f9e',
|
||||||
|
brightWhite: '#16202e',
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const FONT_FAMILY = '"JetBrains Mono", "Fira Code", "Cascadia Code", monospace';
|
export const FONT_FAMILY = '"JetBrains Mono", "Fira Code", "Cascadia Code", monospace';
|
||||||
@@ -55,7 +90,7 @@ export async function loadFonts(size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTerminal(container, { fontSize, onShiftEnter }) {
|
export function createTerminal(container, { fontSize, theme = 'dark', onShiftEnter }) {
|
||||||
const term = new Terminal({
|
const term = new Terminal({
|
||||||
fontFamily: FONT_FAMILY,
|
fontFamily: FONT_FAMILY,
|
||||||
fontSize,
|
fontSize,
|
||||||
@@ -65,7 +100,7 @@ export function createTerminal(container, { fontSize, onShiftEnter }) {
|
|||||||
allowProposedApi: true, // unicode11
|
allowProposedApi: true, // unicode11
|
||||||
macOptionIsMeta: true,
|
macOptionIsMeta: true,
|
||||||
drawBoldTextInBrightColors: false,
|
drawBoldTextInBrightColors: false,
|
||||||
theme: THEME,
|
theme: THEMES[theme],
|
||||||
});
|
});
|
||||||
|
|
||||||
const fit = new FitAddon();
|
const fit = new FitAddon();
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
// Dark / light theme, interchangeable with web_template's lt.theme (devdesk#31):
|
||||||
|
// same localStorage key (lt_theme), same data-theme attribute on <html>, the OS
|
||||||
|
// preference while nothing is saved, and tabs follow each other via `storage`.
|
||||||
|
// The inline script in index.template.html applies it before first paint.
|
||||||
|
|
||||||
|
const KEY = 'lt_theme';
|
||||||
|
const prefersLight = window.matchMedia('(prefers-color-scheme: light)');
|
||||||
|
const listeners = new Set();
|
||||||
|
|
||||||
|
function saved() {
|
||||||
|
try {
|
||||||
|
const value = localStorage.getItem(KEY);
|
||||||
|
return value === 'light' || value === 'dark' ? value : null;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getTheme() {
|
||||||
|
return document.documentElement.getAttribute('data-theme') === 'light' ? 'light' : 'dark';
|
||||||
|
}
|
||||||
|
|
||||||
|
function apply(theme) {
|
||||||
|
const root = document.documentElement;
|
||||||
|
root.setAttribute('data-theme', theme);
|
||||||
|
root.style.colorScheme = theme;
|
||||||
|
document.querySelector('meta[name="theme-color"]')?.setAttribute('content', theme === 'light' ? '#edf0f5' : '#030508');
|
||||||
|
const next = theme === 'light' ? 'dark' : 'light';
|
||||||
|
for (const button of document.querySelectorAll('.lt-theme-btn')) {
|
||||||
|
button.textContent = theme === 'light' ? '◐' : '☀';
|
||||||
|
button.setAttribute('aria-label', `Switch to ${next} mode`);
|
||||||
|
button.title = `Switch to ${next} mode`;
|
||||||
|
}
|
||||||
|
for (const listener of listeners) listener(theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setTheme(theme) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(KEY, theme);
|
||||||
|
} catch {
|
||||||
|
// Private mode: the choice lasts until the tab closes.
|
||||||
|
}
|
||||||
|
apply(theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toggleTheme() {
|
||||||
|
setTheme(getTheme() === 'light' ? 'dark' : 'light');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function onThemeChange(listener) {
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initTheme() {
|
||||||
|
apply(saved() ?? (prefersLight.matches ? 'light' : 'dark'));
|
||||||
|
prefersLight.addEventListener('change', (event) => {
|
||||||
|
if (!saved()) apply(event.matches ? 'light' : 'dark');
|
||||||
|
});
|
||||||
|
window.addEventListener('storage', (event) => {
|
||||||
|
if (event.key === KEY) apply(saved() ?? (prefersLight.matches ? 'light' : 'dark'));
|
||||||
|
});
|
||||||
|
}
|
||||||
+295
@@ -0,0 +1,295 @@
|
|||||||
|
// House UI pieces built on web_template's base.css classes, without base.js
|
||||||
|
// (its global key handler swallows Esc, which interrupts Claude, and every toast
|
||||||
|
// beeps): toasts (devdesk#34), dialogs (#33) and the command palette (#32).
|
||||||
|
|
||||||
|
import { el } from './dom.js';
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- toasts
|
||||||
|
|
||||||
|
const ICONS = { success: '✓', error: '✗', warning: '!', info: 'i' };
|
||||||
|
|
||||||
|
function toastContainer() {
|
||||||
|
let box = document.getElementById('lt-toast-container');
|
||||||
|
if (!box) {
|
||||||
|
box = el('div', { id: 'lt-toast-container', 'aria-live': 'polite' });
|
||||||
|
document.body.append(box);
|
||||||
|
}
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
function dismiss(node) {
|
||||||
|
if (!node.isConnected) return;
|
||||||
|
clearTimeout(node.dismissTimer);
|
||||||
|
node.classList.add('is-leaving');
|
||||||
|
setTimeout(() => node.remove(), 250);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toast(message, type = 'info', duration = 4000) {
|
||||||
|
const box = toastContainer();
|
||||||
|
// At most four on screen: the oldest goes first.
|
||||||
|
while (box.children.length >= 4) box.firstElementChild.remove();
|
||||||
|
const node = el('div', { class: `lt-toast lt-toast-${type}`, role: type === 'error' ? 'alert' : 'status' },
|
||||||
|
el('span', { class: 'lt-toast-icon', 'aria-hidden': 'true' }, `[${ICONS[type] || 'i'}]`),
|
||||||
|
el('span', { class: 'lt-toast-msg' }, message),
|
||||||
|
el('button', { type: 'button', class: 'lt-toast-close', 'aria-label': 'Dismiss', onclick: () => dismiss(node) }, '✕'),
|
||||||
|
el('div', { class: 'lt-toast-progress', style: `animation-duration:${duration}ms` }));
|
||||||
|
box.append(node);
|
||||||
|
node.dismissTimer = setTimeout(() => dismiss(node), duration);
|
||||||
|
node.addEventListener('mouseenter', () => clearTimeout(node.dismissTimer));
|
||||||
|
node.addEventListener('mouseleave', () => { node.dismissTimer = setTimeout(() => dismiss(node), 1500); });
|
||||||
|
}
|
||||||
|
|
||||||
|
toast.success = (message, duration) => toast(message, 'success', duration);
|
||||||
|
toast.error = (message, duration = 8000) => toast(message, 'error', duration);
|
||||||
|
toast.warning = (message, duration) => toast(message, 'warning', duration);
|
||||||
|
toast.info = (message, duration) => toast(message, 'info', duration);
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- dialogs
|
||||||
|
|
||||||
|
let openDialogs = 0;
|
||||||
|
export const dialogOpen = () => openDialogs > 0 || document.getElementById('lt-cmd-overlay')?.classList.contains('is-open');
|
||||||
|
|
||||||
|
// A .lt-modal dialog. `body` is a node; `actions` are { label, value, primary,
|
||||||
|
// danger }. Resolves with the chosen action's value (or `submit()`'s value when
|
||||||
|
// a form is submitted), or null when dismissed (✕, Esc, backdrop).
|
||||||
|
export function openDialog({ title, body, actions = [], danger = false, size = '', onOpen, submit }) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const opener = document.activeElement;
|
||||||
|
let done = false;
|
||||||
|
const close = (value) => {
|
||||||
|
if (done) return;
|
||||||
|
done = true;
|
||||||
|
openDialogs -= 1;
|
||||||
|
overlay.remove();
|
||||||
|
if (opener?.isConnected) opener.focus();
|
||||||
|
resolve(value);
|
||||||
|
};
|
||||||
|
const titleId = `dd-dialog-${Date.now()}`;
|
||||||
|
const form = el('form', { class: 'lt-modal-body dd-dialog-body', novalidate: '' }, body);
|
||||||
|
form.addEventListener('submit', (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const value = submit ? submit() : true;
|
||||||
|
if (value !== undefined && value !== null && value !== false) close(value);
|
||||||
|
});
|
||||||
|
const buttons = actions.map((action) => el('button', {
|
||||||
|
type: action.primary ? 'submit' : 'button',
|
||||||
|
class: `lt-btn lt-btn-sm${action.primary ? (action.danger ? ' lt-btn-danger' : ' lt-btn-primary') : ' lt-btn-ghost'}`,
|
||||||
|
onclick: action.primary ? null : () => close(action.value ?? null),
|
||||||
|
}, action.label));
|
||||||
|
// The primary button submits the form, so Enter in a field does the same.
|
||||||
|
for (const button of buttons) {
|
||||||
|
if (button.type === 'submit') button.setAttribute('form', titleId);
|
||||||
|
}
|
||||||
|
form.id = titleId;
|
||||||
|
const overlay = el('div', { class: 'lt-modal-overlay is-open dd-dialog', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': `${titleId}-title` },
|
||||||
|
el('div', { class: `lt-modal${size ? ` lt-modal-${size}` : ''}` },
|
||||||
|
el('div', { class: `lt-modal-header${danger ? ' lt-modal-header--danger' : ''}` },
|
||||||
|
el('h2', { class: 'lt-modal-title', id: `${titleId}-title` }, title),
|
||||||
|
el('button', { type: 'button', class: 'lt-modal-close', 'aria-label': 'Close', onclick: () => close(null) }, '✕')),
|
||||||
|
form,
|
||||||
|
buttons.length ? el('div', { class: 'lt-modal-footer' }, ...buttons) : null));
|
||||||
|
overlay.addEventListener('mousedown', (event) => {
|
||||||
|
if (event.target === overlay) close(null);
|
||||||
|
});
|
||||||
|
overlay.addEventListener('keydown', (event) => {
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
close(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.key === 'Tab') trapFocus(overlay, event);
|
||||||
|
});
|
||||||
|
openDialogs += 1;
|
||||||
|
document.body.append(overlay);
|
||||||
|
(onOpen?.(overlay) ?? overlay.querySelector('input, select, textarea, .lt-btn-primary, .lt-btn-danger, .lt-modal-close'))?.focus?.();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function trapFocus(root, event) {
|
||||||
|
const items = [...root.querySelectorAll('button, input, select, textarea, a[href], [tabindex]:not([tabindex="-1"])')]
|
||||||
|
.filter((node) => !node.disabled && node.offsetParent !== null);
|
||||||
|
if (!items.length) return;
|
||||||
|
const first = items[0];
|
||||||
|
const last = items[items.length - 1];
|
||||||
|
if (event.shiftKey && document.activeElement === first) {
|
||||||
|
event.preventDefault();
|
||||||
|
last.focus();
|
||||||
|
} else if (!event.shiftKey && document.activeElement === last) {
|
||||||
|
event.preventDefault();
|
||||||
|
first.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function confirmDialog({ title, text, confirmLabel = 'OK', danger = false }) {
|
||||||
|
return openDialog({
|
||||||
|
title,
|
||||||
|
danger,
|
||||||
|
size: 'sm',
|
||||||
|
body: el('p', { class: 'dd-dialog-text' }, text),
|
||||||
|
actions: [{ label: 'Cancel', value: false }, { label: confirmLabel, primary: true, danger }],
|
||||||
|
}).then(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- command palette
|
||||||
|
|
||||||
|
const RECENT_KEY = 'lt_cmd_recent';
|
||||||
|
|
||||||
|
function readRecent() {
|
||||||
|
try {
|
||||||
|
const list = JSON.parse(localStorage.getItem(RECENT_KEY) || '[]');
|
||||||
|
return Array.isArray(list) ? list : [];
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pushRecent(id) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(RECENT_KEY, JSON.stringify([id, ...readRecent().filter((x) => x !== id)].slice(0, 5)));
|
||||||
|
} catch {
|
||||||
|
// Private mode: no recents.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commands: { id, label, group, icon?, hint?, kbd?, keywords?, run }. `getCommands`
|
||||||
|
// is called on every open, so the list reflects the current sessions and state.
|
||||||
|
export class CommandPalette {
|
||||||
|
constructor(getCommands) {
|
||||||
|
this.getCommands = getCommands;
|
||||||
|
this.commands = [];
|
||||||
|
this.visible = [];
|
||||||
|
this.selected = 0;
|
||||||
|
this.opener = null;
|
||||||
|
this.input = el('input', {
|
||||||
|
class: 'lt-cmd-input', type: 'text', placeholder: 'Type a command or a session name…',
|
||||||
|
autocomplete: 'off', spellcheck: 'false', 'aria-label': 'Command', role: 'combobox',
|
||||||
|
'aria-controls': 'dd-cmd-results', 'aria-expanded': 'true',
|
||||||
|
});
|
||||||
|
this.results = el('div', { class: 'lt-cmd-results', id: 'dd-cmd-results', role: 'listbox' });
|
||||||
|
this.overlay = el('div', { class: 'lt-cmd-overlay', id: 'lt-cmd-overlay', role: 'dialog', 'aria-modal': 'true', 'aria-label': 'Command palette' },
|
||||||
|
el('div', { class: 'lt-cmd-palette', id: 'lt-cmd-palette' },
|
||||||
|
el('div', { class: 'lt-cmd-input-wrap' }, el('span', { class: 'lt-cmd-prompt', 'aria-hidden': 'true' }, '>'), this.input),
|
||||||
|
this.results,
|
||||||
|
el('div', { class: 'lt-cmd-footer' },
|
||||||
|
el('span', {}, el('kbd', {}, '↑'), el('kbd', {}, '↓'), ' move'),
|
||||||
|
el('span', {}, el('kbd', {}, '⏎'), ' run'),
|
||||||
|
el('span', {}, el('kbd', {}, 'Esc'), ' close'))));
|
||||||
|
document.body.append(this.overlay);
|
||||||
|
this.input.addEventListener('input', () => this.render());
|
||||||
|
this.input.addEventListener('keydown', (event) => this.onKey(event));
|
||||||
|
this.overlay.addEventListener('mousedown', (event) => {
|
||||||
|
if (event.target === this.overlay) this.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get isOpen() {
|
||||||
|
return this.overlay.classList.contains('is-open');
|
||||||
|
}
|
||||||
|
|
||||||
|
open(query = '') {
|
||||||
|
this.opener = document.activeElement;
|
||||||
|
this.commands = this.getCommands();
|
||||||
|
this.overlay.classList.add('is-open');
|
||||||
|
this.input.value = query;
|
||||||
|
this.render();
|
||||||
|
this.input.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
close({ restoreFocus = true } = {}) {
|
||||||
|
if (!this.isOpen) return;
|
||||||
|
this.overlay.classList.remove('is-open');
|
||||||
|
if (restoreFocus && this.opener?.isConnected) this.opener.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
onKey(event) {
|
||||||
|
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
||||||
|
event.preventDefault();
|
||||||
|
this.move(event.key === 'ArrowDown' ? 1 : -1);
|
||||||
|
} else if (event.key === 'Enter') {
|
||||||
|
event.preventDefault();
|
||||||
|
this.run(this.visible[this.selected]);
|
||||||
|
} else if (event.key === 'Escape') {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
this.close();
|
||||||
|
} else if (event.key === 'Tab') {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
move(step) {
|
||||||
|
if (!this.visible.length) return;
|
||||||
|
this.selected = (this.selected + step + this.visible.length) % this.visible.length;
|
||||||
|
this.highlight();
|
||||||
|
}
|
||||||
|
|
||||||
|
highlight() {
|
||||||
|
const items = this.results.querySelectorAll('.lt-cmd-item');
|
||||||
|
items.forEach((item, i) => {
|
||||||
|
item.classList.toggle('is-selected', i === this.selected);
|
||||||
|
item.setAttribute('aria-selected', String(i === this.selected));
|
||||||
|
});
|
||||||
|
const current = items[this.selected];
|
||||||
|
if (current) {
|
||||||
|
current.scrollIntoView({ block: 'nearest' });
|
||||||
|
this.input.setAttribute('aria-activedescendant', current.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
run(command) {
|
||||||
|
if (!command) return;
|
||||||
|
pushRecent(command.id);
|
||||||
|
// The command decides where focus goes (usually the terminal).
|
||||||
|
this.close({ restoreFocus: false });
|
||||||
|
command.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const words = this.input.value.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
||||||
|
const matches = this.commands.filter((c) => {
|
||||||
|
const text = `${c.label} ${c.group} ${c.keywords ?? ''} ${c.hint ?? ''}`.toLowerCase();
|
||||||
|
return words.every((w) => text.includes(w));
|
||||||
|
});
|
||||||
|
const groups = new Map();
|
||||||
|
if (!words.length) {
|
||||||
|
const recent = readRecent().map((id) => matches.find((c) => c.id === id)).filter(Boolean).slice(0, 3);
|
||||||
|
if (recent.length) groups.set('Recent', recent);
|
||||||
|
}
|
||||||
|
for (const command of matches) {
|
||||||
|
if (!groups.has(command.group)) groups.set(command.group, []);
|
||||||
|
groups.get(command.group).push(command);
|
||||||
|
}
|
||||||
|
this.visible = [...groups.values()].flat();
|
||||||
|
this.selected = 0;
|
||||||
|
if (!this.visible.length) {
|
||||||
|
this.results.replaceChildren(el('div', { class: 'lt-cmd-empty' }, `No command matches “${this.input.value.trim()}”`));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let index = 0;
|
||||||
|
const nodes = [];
|
||||||
|
for (const [group, commands] of groups) {
|
||||||
|
nodes.push(el('div', { class: 'lt-cmd-group-label', role: 'presentation' }, group));
|
||||||
|
for (const command of commands) {
|
||||||
|
const i = index;
|
||||||
|
nodes.push(el('div', {
|
||||||
|
class: 'lt-cmd-item', id: `dd-cmd-${i}`, role: 'option',
|
||||||
|
onclick: () => this.run(command),
|
||||||
|
onmousemove: () => {
|
||||||
|
if (this.selected !== i) {
|
||||||
|
this.selected = i;
|
||||||
|
this.highlight();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
el('span', { class: 'lt-cmd-item-icon', 'aria-hidden': 'true' }, command.icon || '◦'),
|
||||||
|
el('span', { class: 'lt-cmd-item-label' }, command.label),
|
||||||
|
command.hint ? el('span', { class: 'dd-cmd-hint' }, command.hint) : null,
|
||||||
|
command.kbd ? el('span', { class: 'lt-cmd-item-kbd' }, command.kbd) : null));
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.results.replaceChildren(...nodes);
|
||||||
|
this.highlight();
|
||||||
|
}
|
||||||
|
}
|
||||||
+275
-14
@@ -100,20 +100,7 @@ body.dd-app::after {
|
|||||||
color: var(--accent-orange);
|
color: var(--accent-orange);
|
||||||
border-color: var(--accent-orange-border);
|
border-color: var(--accent-orange-border);
|
||||||
}
|
}
|
||||||
.dd-badge {
|
|
||||||
margin-left: 6px;
|
|
||||||
min-width: 16px;
|
|
||||||
padding: 0 4px;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: var(--accent-amber);
|
|
||||||
color: var(--bg-primary);
|
|
||||||
font-size: 0.62rem;
|
|
||||||
font-weight: 700;
|
|
||||||
line-height: 16px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.dd-badge.is-urgent { background: var(--accent-red); box-shadow: 0 0 8px var(--accent-red); }
|
|
||||||
.dd-badge[hidden] { display: none; }
|
|
||||||
|
|
||||||
/* ---- menus (session switcher, ⋯) ----------------------------------------------- */
|
/* ---- menus (session switcher, ⋯) ----------------------------------------------- */
|
||||||
.dd-session,
|
.dd-session,
|
||||||
@@ -569,3 +556,277 @@ body.dd-touch .dd-footer {
|
|||||||
.dd-footer .lt-footer-hints .lt-footer-hint:nth-child(n + 5),
|
.dd-footer .lt-footer-hints .lt-footer-hint:nth-child(n + 5),
|
||||||
.dd-footer .lt-footer-sep:nth-child(n + 4) { display: none; }
|
.dd-footer .lt-footer-sep:nth-child(n + 4) { display: none; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---- light theme (devdesk#31) ---------------------------------------------------
|
||||||
|
base.css restyles every lt- component; these cover DevDesk's own pieces. */
|
||||||
|
html[data-theme="light"] .dd-sidebar,
|
||||||
|
html[data-theme="light"] .dd-footer { background-image: none; }
|
||||||
|
html[data-theme="light"] .dd-overlay { background: rgba(237, 240, 245, 0.82); }
|
||||||
|
html[data-theme="light"] .dd-backdrop { background: rgba(17, 24, 39, 0.28); }
|
||||||
|
html[data-theme="light"] .dd-menu { box-shadow: 0 8px 28px rgba(50, 80, 130, 0.22), var(--box-glow-cyan); }
|
||||||
|
html[data-theme="light"] .dd-drop-overlay { background: var(--accent-cyan-dim); }
|
||||||
|
html[data-theme="light"] .dd-upload-status { box-shadow: 0 4px 16px rgba(50, 80, 130, 0.18); }
|
||||||
|
html[data-theme="light"] .dd-session-item.is-waiting,
|
||||||
|
html[data-theme="light"] .dd-session-chip[data-state="waiting"],
|
||||||
|
html[data-theme="light"] .dd-upload-status.is-error { border-color: rgba(181, 0, 31, 0.35); }
|
||||||
|
html[data-theme="light"] .dd-session-chip[data-state="working"] .dd-state-dot,
|
||||||
|
html[data-theme="light"] .dd-session-chip[data-state="waiting"] .dd-state-dot { box-shadow: none; }
|
||||||
|
@media (max-width: 1099px) {
|
||||||
|
html[data-theme="light"] .dd-sidebar { box-shadow: -8px 0 28px rgba(50, 80, 130, 0.22); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.dd-header .lt-theme-btn { flex: 0 0 auto; }
|
||||||
|
|
||||||
|
/* ---- command palette, dialogs, toasts (devdesk#32-#34) ---------------------------- */
|
||||||
|
.dd-cmd-btn { font-size: 0.8rem; letter-spacing: 0.02em; }
|
||||||
|
.dd-cmd-kbd { font-size: 0.62rem; opacity: 0.7; }
|
||||||
|
.lt-cmd-item.is-selected .dd-cmd-hint { color: inherit; }
|
||||||
|
.dd-cmd-hint { color: var(--text-muted); font-size: 0.66rem; white-space: nowrap; }
|
||||||
|
html[data-theme="light"] .lt-cmd-item.is-selected { background: var(--accent-cyan-dim); color: var(--accent-cyan); }
|
||||||
|
.lt-cmd-results { max-height: min(420px, 60vh); }
|
||||||
|
.lt-cmd-footer span { display: inline-flex; align-items: center; gap: 2px; }
|
||||||
|
|
||||||
|
.dd-dialog-body { display: flex; flex-direction: column; gap: var(--space-sm); }
|
||||||
|
.dd-dialog-fields { display: flex; flex-direction: column; gap: var(--space-md); }
|
||||||
|
.dd-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.72rem; color: var(--text-secondary); }
|
||||||
|
.dd-field .lt-input,
|
||||||
|
.dd-field .lt-select { width: 100%; font-size: 0.8rem; }
|
||||||
|
.dd-dialog-text { color: var(--text-secondary); font-size: 0.8rem; line-height: 1.5; }
|
||||||
|
.dd-dialog-hint { color: var(--text-muted); font-size: 0.7rem; }
|
||||||
|
.dd-dialog-hint.is-error { color: var(--accent-red); }
|
||||||
|
|
||||||
|
.dd-keys { display: grid; gap: var(--space-lg); }
|
||||||
|
.dd-keys-title {
|
||||||
|
margin: 0 0 var(--space-sm);
|
||||||
|
font-size: 0.68rem;
|
||||||
|
letter-spacing: 0.12em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--accent-orange);
|
||||||
|
}
|
||||||
|
.dd-keys-list { display: grid; grid-template-columns: 10.5rem 1fr; gap: 6px var(--space-md); margin: 0; font-size: 0.76rem; }
|
||||||
|
.dd-keys-list dt { white-space: nowrap; }
|
||||||
|
.dd-keys-list dd { margin: 0; color: var(--text-secondary); }
|
||||||
|
.dd-keys kbd {
|
||||||
|
padding: 1px 6px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
background: var(--bg-tertiary);
|
||||||
|
color: var(--accent-cyan);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 0.72rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dd-footer-help {
|
||||||
|
margin-left: var(--space-sm);
|
||||||
|
padding: 0 6px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
background: none;
|
||||||
|
color: var(--accent-cyan);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 0.64rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.dd-footer-help:hover { border-color: var(--accent-cyan); }
|
||||||
|
|
||||||
|
/* Toasts sit above the footer (and the phone key bar); names keep their case. */
|
||||||
|
#lt-toast-container {
|
||||||
|
right: var(--space-md);
|
||||||
|
bottom: calc(var(--dd-footer-height) + var(--dd-kb, 0px) + env(safe-area-inset-bottom, 0px) + var(--space-md));
|
||||||
|
max-width: calc(100vw - 2 * var(--space-md));
|
||||||
|
}
|
||||||
|
.lt-toast {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
text-transform: none;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
font-size: 0.74rem;
|
||||||
|
transition: opacity 0.25s ease;
|
||||||
|
}
|
||||||
|
.lt-toast.is-leaving { opacity: 0; }
|
||||||
|
.lt-toast-msg { flex: 1; overflow-wrap: anywhere; }
|
||||||
|
.lt-toast-icon { flex: 0 0 auto; }
|
||||||
|
.lt-toast-close {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
background: none;
|
||||||
|
border: 0;
|
||||||
|
color: inherit;
|
||||||
|
opacity: 0.6;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
.lt-toast-close:hover { opacity: 1; }
|
||||||
|
|
||||||
|
@media (max-width: 719px) {
|
||||||
|
.dd-cmd-kbd { display: none; }
|
||||||
|
#lt-toast-container { left: var(--space-sm); right: var(--space-sm); }
|
||||||
|
.lt-toast { min-width: 0; max-width: none; }
|
||||||
|
.dd-keys-list { grid-template-columns: 1fr; gap: 2px; }
|
||||||
|
.dd-keys-list dd { margin-bottom: var(--space-sm); }
|
||||||
|
}
|
||||||
|
/* One highlight only: the row under a resting pointer isn't "selected" until the
|
||||||
|
pointer moves (mousemove updates the selection). */
|
||||||
|
.lt-cmd-item:hover:not(.is-selected) { background: none; color: inherit; }
|
||||||
|
|
||||||
|
/* ---- inbox (bell) ---------------------------------------------------------------- */
|
||||||
|
.dd-inbox .lt-notif-bell-btn { font-size: 0.9rem; line-height: 1; padding-inline: 8px; }
|
||||||
|
.dd-inbox .lt-notif-badge { top: -5px; right: -5px; }
|
||||||
|
.dd-inbox .lt-notif-badge.is-calm { background: var(--accent-amber); animation: none; }
|
||||||
|
.dd-inbox-panel { width: min(360px, calc(100vw - 16px)); z-index: 40; }
|
||||||
|
.dd-inbox-panel .lt-notif-panel-list { max-height: min(460px, calc(100vh - 140px)); }
|
||||||
|
.dd-notif-section {
|
||||||
|
padding: 6px 0.75rem 4px;
|
||||||
|
font-size: 0.62rem;
|
||||||
|
letter-spacing: 0.12em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--accent-orange);
|
||||||
|
border-bottom: 1px solid var(--border-dim);
|
||||||
|
background: var(--bg-primary);
|
||||||
|
}
|
||||||
|
.dd-notif-red { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }
|
||||||
|
.dd-notif-amber { background: var(--accent-amber); box-shadow: 0 0 6px var(--accent-amber); }
|
||||||
|
.dd-notif-green { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
|
||||||
|
.dd-notif-cyan { background: var(--accent-cyan); }
|
||||||
|
.dd-notif-read { background: var(--border-color); box-shadow: none; }
|
||||||
|
html[data-theme="light"] .lt-notif-dot { box-shadow: none; }
|
||||||
|
.dd-notif-empty,
|
||||||
|
.dd-notif-more { padding: 0.75rem; color: var(--text-muted); font-size: 0.72rem; line-height: 1.5; }
|
||||||
|
.dd-panels-icon { display: none; }
|
||||||
|
|
||||||
|
@media (max-width: 719px) {
|
||||||
|
/* Phone header: theme lives in the ⋯ menu; Panels becomes an icon. */
|
||||||
|
.dd-header .lt-theme-btn { display: none; }
|
||||||
|
.dd-inbox .lt-notif-badge { top: 1px; right: 1px; }
|
||||||
|
.dd-panels-label { display: none; }
|
||||||
|
.dd-panels-icon { display: inline; font-size: 1rem; }
|
||||||
|
.dd-inbox-panel { position: fixed; top: calc(var(--header-height) + 4px); right: 8px; left: 8px; width: auto; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---- files pane (devdesk#19) -------------------------------------------------------- */
|
||||||
|
.dd-files {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 0 0 var(--dd-files-w, 46%);
|
||||||
|
min-width: 0;
|
||||||
|
margin: 0;
|
||||||
|
background: var(--bg-terminal);
|
||||||
|
}
|
||||||
|
.dd-files[hidden] { display: none; }
|
||||||
|
body.dd-resizing { cursor: col-resize; user-select: none; }
|
||||||
|
body.dd-resizing .dd-terminal { pointer-events: none; }
|
||||||
|
.dd-files-resizer {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: calc(-1 * var(--dd-gap) - 2px);
|
||||||
|
width: calc(var(--dd-gap) + 6px);
|
||||||
|
cursor: col-resize;
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
.dd-files-resizer:hover,
|
||||||
|
.dd-files-resizer:focus-visible,
|
||||||
|
body.dd-resizing .dd-files-resizer { background: linear-gradient(90deg, transparent 40%, var(--accent-cyan) 40%, var(--accent-cyan) 60%, transparent 60%); outline: none; }
|
||||||
|
#files-toggle[aria-expanded="true"] { color: var(--accent-orange); border-color: var(--accent-orange-border); }
|
||||||
|
|
||||||
|
.dd-files-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 2px 6px 0 6px; border-bottom: 1px solid var(--border-dim); }
|
||||||
|
.dd-files-tabs { display: flex; }
|
||||||
|
.dd-files-tabs button {
|
||||||
|
padding: 7px 10px 6px;
|
||||||
|
border: 0;
|
||||||
|
border-bottom: 2px solid transparent;
|
||||||
|
background: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 0.7rem;
|
||||||
|
letter-spacing: 0.1em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.dd-files-tabs button:hover { color: var(--text-primary); }
|
||||||
|
.dd-files-tabs button[aria-selected="true"] { color: var(--accent-orange); border-bottom-color: var(--accent-orange); }
|
||||||
|
.dd-files-count:not(:empty) { margin-left: 4px; padding: 0 5px; border-radius: 8px; background: var(--accent-amber-dim); color: var(--accent-amber); font-size: 0.62rem; }
|
||||||
|
.dd-files-actions { display: flex; gap: 2px; padding-bottom: 4px; }
|
||||||
|
|
||||||
|
.dd-files-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; min-height: 28px; padding: 4px 10px; border-bottom: 1px solid var(--border-dim); font-family: var(--font-mono); font-size: 0.72rem; }
|
||||||
|
.dd-crumb { padding: 1px 3px; border: 0; background: none; color: var(--accent-cyan); font: inherit; cursor: pointer; }
|
||||||
|
.dd-crumb:hover { text-decoration: underline; }
|
||||||
|
.dd-crumb.is-current,
|
||||||
|
.dd-crumb.is-file { color: var(--text-primary); text-decoration: none; cursor: default; }
|
||||||
|
.dd-crumb-sep { color: var(--text-dim); }
|
||||||
|
|
||||||
|
.dd-files-body { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: auto; outline: none; }
|
||||||
|
.dd-file-list { margin: 0; padding: 4px 0; list-style: none; }
|
||||||
|
.dd-file {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 4px 10px;
|
||||||
|
border: 0;
|
||||||
|
background: none;
|
||||||
|
color: var(--text-primary);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 0.76rem;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.dd-file:hover:not(:disabled),
|
||||||
|
.dd-file:focus-visible { background: var(--accent-cyan-dim); outline: none; }
|
||||||
|
.dd-file:disabled { opacity: 0.55; cursor: default; }
|
||||||
|
.dd-file-icon { flex: 0 0 12px; color: var(--text-dim); text-align: center; }
|
||||||
|
.dd-file.is-dir .dd-file-icon,
|
||||||
|
.dd-file.is-dir .dd-file-name { color: var(--accent-cyan); }
|
||||||
|
.dd-file.is-up .dd-file-name { color: var(--text-muted); }
|
||||||
|
.dd-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
.dd-file-meta { color: var(--text-muted); font-size: 0.66rem; white-space: nowrap; }
|
||||||
|
.dd-file-age { flex: 0 0 2.6em; text-align: right; }
|
||||||
|
.dd-file-status { flex: 0 0 1.2em; font-weight: 700; text-align: center; }
|
||||||
|
.dd-file-status.is-amber { color: var(--accent-amber); }
|
||||||
|
.dd-file-status.is-green { color: var(--accent-green); }
|
||||||
|
.dd-file-status.is-red { color: var(--accent-red); }
|
||||||
|
.dd-file-status.is-cyan { color: var(--accent-cyan); }
|
||||||
|
.dd-claude-chip { padding: 0 4px; border: 1px solid var(--accent-orange-border); color: var(--accent-orange); font-size: 0.6rem; font-weight: 700; }
|
||||||
|
.dd-add { color: var(--accent-green); }
|
||||||
|
.dd-del { color: var(--accent-red); }
|
||||||
|
.dd-files-msg { padding: 14px; color: var(--text-muted); font-size: 0.76rem; line-height: 1.5; }
|
||||||
|
.dd-files-msg.is-error { color: var(--accent-red); }
|
||||||
|
|
||||||
|
.dd-viewer-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 4px 8px; border-bottom: 1px solid var(--border-dim); }
|
||||||
|
.dd-viewer-meta { flex: 1; min-width: 8em; color: var(--text-muted); font-size: 0.68rem; }
|
||||||
|
.dd-viewer-actions { display: flex; flex-wrap: wrap; gap: 4px; }
|
||||||
|
.dd-viewer-btn {
|
||||||
|
padding: 2px 8px;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
background: none;
|
||||||
|
color: var(--accent-cyan);
|
||||||
|
font-family: var(--font-mono);
|
||||||
|
font-size: 0.68rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.dd-viewer-btn:hover { border-color: var(--accent-cyan); background: var(--accent-cyan-dim); }
|
||||||
|
.dd-viewer-back { font-size: 0.8rem; }
|
||||||
|
.dd-viewer-stale { padding: 4px 10px; background: var(--accent-amber-dim); color: var(--accent-amber); font-size: 0.72rem; }
|
||||||
|
.dd-viewer-stale[hidden] { display: none; }
|
||||||
|
.dd-viewer-content { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
|
||||||
|
.dd-viewer-content > .cm-editor { flex: 1; min-height: 0; }
|
||||||
|
.dd-viewer-content .cm-editor.cm-focused { outline: none; }
|
||||||
|
.dd-viewer-content.is-image {
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: auto;
|
||||||
|
padding: 12px;
|
||||||
|
background: repeating-conic-gradient(var(--bg-secondary) 0 25%, var(--bg-terminal) 0 50%) 0 0 / 20px 20px;
|
||||||
|
}
|
||||||
|
.dd-viewer-content.is-image img { max-width: 100%; height: auto; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3); }
|
||||||
|
.dd-md-frame { flex: 1; width: 100%; border: 0; background: var(--bg-terminal); }
|
||||||
|
.dd-plain { flex: 1; margin: 0; padding: 10px; overflow: auto; font-size: 0.76rem; white-space: pre; }
|
||||||
|
|
||||||
|
@media (max-width: 1099px) {
|
||||||
|
/* Narrow: the pane covers the terminal instead of squeezing it (squeezing
|
||||||
|
would resize tmux for every client). */
|
||||||
|
.dd-files { position: absolute; inset: var(--dd-gap); z-index: 18; flex: none; }
|
||||||
|
.dd-files-resizer { display: none; }
|
||||||
|
}
|
||||||
|
@media (max-width: 719px) {
|
||||||
|
.dd-cmd-btn { display: none; }
|
||||||
|
.dd-file-age { display: none; }
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user