Skip to content

Commit b5c68d1

Browse files
committed
Tighten preview safety and quiet smoke tests
1 parent cd3b5a5 commit b5c68d1

12 files changed

Lines changed: 384 additions & 16 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ check: validate-desktop
1010
bash -n scripts/install-electron-local.sh
1111
bash -n scripts/install-local.sh
1212
bash -n scripts/build-deb.sh
13+
bash -n tests/electron_wrapper_smoke.sh
1314
bash -n tests/install_electron_local_smoke.sh
1415
bash -n tests/launcher_smoke.sh
1516

@@ -28,6 +29,7 @@ validate-desktop:
2829
rm -f "$$tmpfile"
2930

3031
test: check
32+
bash tests/electron_wrapper_smoke.sh
3133
bash tests/install_electron_local_smoke.sh
3234
bash tests/launcher_smoke.sh
3335

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ The current repository is not just a design memo. It already ships:
5555
| Updater | Not yet |
5656
| Stable v1 release | Not yet |
5757

58+
## Package reality today
59+
60+
`make build-deb` currently builds the **browser fallback utility package**, not the Electron desktop app.
61+
62+
That means the `.deb` is useful as a preview/recovery install, but it is **not** yet the main Electron product this repository is aiming for.
63+
5864
## What it is not claiming
5965

6066
This repository is not yet:
@@ -106,7 +112,7 @@ See [providers/contract.md](providers/contract.md), [providers/browser-shell.md]
106112
| XDG state layout | Yes | Config, cache, and state are separated |
107113
| Local install | Yes | `make install-local` installs the fallback utility |
108114
| Local Electron install | Yes | `make install-electron-local` swaps the active desktop launcher to repo code with rollback preserved |
109-
| Debian package build | Yes | Today this packages the fallback utility |
115+
| Debian package build | Yes | Today this packages the fallback utility, not `Codex Desktop` |
110116
| CI | Yes | Syntax, smoke tests, packaging |
111117
| Desktop-payload provider | Not yet | Main implementation target |
112118
| App Server provider | Not yet | Optional future provider |
@@ -121,6 +127,11 @@ See [providers/contract.md](providers/contract.md), [providers/browser-shell.md]
121127
| Browser fallback | People who want the current fully repo-owned path | Yes | Lowest-fidelity UX, but easiest to run from this repo today |
122128
| Electron developer path | People who want the real desktop feel | Yes | Best UX, with a staged local build bridge and local install flow |
123129

130+
Important:
131+
132+
- `make build-deb` packages the browser fallback path today
133+
- `Codex Desktop` is currently built and installed through the local Electron build/install flow, not through the `.deb`
134+
124135
### What you need locally
125136

126137
Browser fallback:
@@ -225,6 +236,7 @@ Strict behavior:
225236

226237
- invalid explicit runtime or browser overrides fail loudly
227238
- non-loopback bind values require `CODEX_UBUNTU_ALLOW_NON_LOOPBACK=1`
239+
- set `CODEX_UBUNTU_DISABLE_NOTIFICATIONS=1` if you want failure handling to stay terminal-only
228240

229241
Install it locally:
230242

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.0
1+
0.2.1

electron/codex-desktop

Lines changed: 92 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
3+
umask 077
34

45
DISPLAY_NAME="Codex Desktop"
56
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
@@ -9,16 +10,101 @@ LOG_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/codex-ubuntu"
910
LOG_FILE="${LOG_DIR}/electron-wrapper.log"
1011

1112
mkdir -p "$LOG_DIR"
12-
13-
if [ -f "$CONFIG_FILE" ]; then
14-
# shellcheck disable=SC1090
15-
. "$CONFIG_FILE"
16-
fi
13+
chmod 700 "$LOG_DIR" >/dev/null 2>&1 || true
14+
mkdir -p "$CONFIG_DIR"
15+
chmod 700 "$CONFIG_DIR" >/dev/null 2>&1 || true
1716

1817
log() {
1918
printf '[%s] %s\n' "$(date -Is)" "$*" >>"$LOG_FILE"
2019
}
2120

21+
load_config_file() {
22+
local config_output=""
23+
local line=""
24+
local key=""
25+
local value=""
26+
27+
[ -f "$CONFIG_FILE" ] || return 0
28+
29+
chmod 600 "$CONFIG_FILE" >/dev/null 2>&1 || true
30+
31+
if ! config_output="$(python3 - "$CONFIG_FILE" <<'PY'
32+
from pathlib import Path
33+
import shlex
34+
import sys
35+
36+
config_path = Path(sys.argv[1])
37+
allowed_keys = {
38+
"CODEX_UBUNTU_ELECTRON_APP_ROOT",
39+
"CODEX_UBUNTU_NODE_BIN_DIR",
40+
}
41+
42+
for line_number, raw_line in enumerate(
43+
config_path.read_text(encoding="utf-8").splitlines(),
44+
start=1,
45+
):
46+
stripped = raw_line.strip()
47+
if not stripped or stripped.startswith("#"):
48+
continue
49+
if "=" not in raw_line:
50+
print(
51+
f"Invalid config line in {config_path}:{line_number}",
52+
file=sys.stderr,
53+
)
54+
raise SystemExit(1)
55+
56+
key, raw_value = raw_line.split("=", 1)
57+
key = key.strip()
58+
if key not in allowed_keys:
59+
print(
60+
f"Unsupported key in {config_path}:{line_number}: {key}",
61+
file=sys.stderr,
62+
)
63+
raise SystemExit(1)
64+
65+
raw_value = raw_value.strip()
66+
if not raw_value:
67+
value = ""
68+
else:
69+
try:
70+
tokens = shlex.split(raw_value, posix=True)
71+
except ValueError as exc:
72+
print(
73+
f"Invalid shell-like value for {key} in {config_path}:{line_number}: {exc}",
74+
file=sys.stderr,
75+
)
76+
raise SystemExit(1)
77+
78+
if len(tokens) != 1:
79+
print(
80+
f"Invalid shell-like value for {key} in {config_path}:{line_number}",
81+
file=sys.stderr,
82+
)
83+
raise SystemExit(1)
84+
85+
value = tokens[0]
86+
87+
print(f"{key}={value}")
88+
PY
89+
)"; then
90+
return 1
91+
fi
92+
93+
while IFS= read -r line; do
94+
[ -n "$line" ] || continue
95+
key="${line%%=*}"
96+
value="${line#*=}"
97+
case "$key" in
98+
CODEX_UBUNTU_ELECTRON_APP_ROOT)
99+
CODEX_UBUNTU_ELECTRON_APP_ROOT="$value"
100+
;;
101+
CODEX_UBUNTU_NODE_BIN_DIR)
102+
CODEX_UBUNTU_NODE_BIN_DIR="$value"
103+
;;
104+
esac
105+
done <<<"$config_output"
106+
}
107+
22108
prepend_path_once() {
23109
local dir="$1"
24110
case ":$PATH:" in
@@ -86,6 +172,7 @@ main() {
86172
local node_bin_dir=""
87173
local app_root=""
88174

175+
load_config_file
89176
prepend_path_once "${HOME}/.local/bin"
90177
if node_bin_dir="$(resolve_node_bin_dir)"; then
91178
prepend_path_once "$node_bin_dir"

launcher/codex-ubuntu

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ umask 077
44

55
APP_ID="codex-ubuntu"
66
APP_NAME="Codex Ubuntu (Unofficial)"
7-
APP_VERSION="${CODEX_UBUNTU_VERSION:-0.2.0}"
7+
APP_VERSION="${CODEX_UBUNTU_VERSION:-0.2.1}"
88
PROVIDER="${CODEX_UBUNTU_PROVIDER:-browser-shell}"
99
WEB_BIND="${CODEX_UBUNTU_BIND:-127.0.0.1}"
1010
DEFAULT_WEB_PORT="${CODEX_UBUNTU_PORT:-8080}"
1111
ALLOW_NON_LOOPBACK="${CODEX_UBUNTU_ALLOW_NON_LOOPBACK:-0}"
1212
DEBUG_SHOW_TOKEN_URL="${CODEX_UBUNTU_DEBUG_SHOW_TOKEN_URL:-0}"
13+
LOCK_TIMEOUT_SECONDS="${CODEX_UBUNTU_LOCK_TIMEOUT_SECONDS:-15}"
14+
DISABLE_NOTIFICATIONS="${CODEX_UBUNTU_DISABLE_NOTIFICATIONS:-0}"
1315

1416
CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/${APP_ID}"
1517
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/${APP_ID}"
@@ -47,6 +49,11 @@ log() {
4749

4850
notify_failure() {
4951
local message="$1"
52+
case "$DISABLE_NOTIFICATIONS" in
53+
1|true|TRUE|yes|YES)
54+
return 0
55+
;;
56+
esac
5057
if command -v notify-send >/dev/null 2>&1; then
5158
notify-send "$APP_NAME" "$message" || true
5259
fi
@@ -57,13 +64,21 @@ ensure_dirs() {
5764
}
5865

5966
with_lock() {
67+
local message=""
68+
6069
ensure_dirs
6170
if command -v flock >/dev/null 2>&1; then
6271
if [ "$LOCK_HELD" = "1" ]; then
6372
return 0
6473
fi
6574
exec 9>"$LOCK_FILE"
66-
flock 9
75+
if ! flock -w "$LOCK_TIMEOUT_SECONDS" 9; then
76+
exec 9>&- || true
77+
message="Another ${APP_NAME} launcher operation is already in progress. Wait a moment or run codex-ubuntu --status."
78+
log "Timed out waiting ${LOCK_TIMEOUT_SECONDS}s for launcher lock"
79+
printf '%s\n' "$message" >&2
80+
return 1
81+
fi
6782
LOCK_HELD=1
6883
fi
6984
}
@@ -822,11 +837,9 @@ cleanup_stale_state() {
822837
}
823838

824839
stop_server() {
825-
local pid=""
826-
local port=""
827840
local status=0
828841

829-
with_lock
842+
with_lock || return $?
830843
stop_server_locked || status=$?
831844
release_lock
832845
return "$status"
@@ -862,7 +875,7 @@ ensure_server() {
862875
ENSURE_SERVER_ACTION=""
863876
validate_loopback_bind
864877
validate_port_number "$DEFAULT_WEB_PORT"
865-
with_lock
878+
with_lock || return $?
866879
ensure_dirs
867880
cleanup_stale_state
868881

packaging/deb/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@
33
Debian packaging templates for the Ubuntu app.
44

55
Today the packaged implementation is still the browser fallback utility.
6-
The main packaging direction is the Electron desktop path.
6+
7+
Important:
8+
9+
- this `.deb` does **not** install the Electron desktop app yet
10+
- this `.deb` does install the fallback/recovery launcher
11+
- the main packaging direction is still the Electron desktop path
12+
713
The local Electron build/install bridge exists now, but that path is not yet what the `.deb` installs.

scripts/build-deb.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ mkdir -p "$DIST_DIR"
3333
dpkg-deb --build "$PKGROOT" "$PACKAGE_PATH" >/dev/null
3434

3535
printf 'Built %s\n' "$PACKAGE_PATH"
36+
printf 'Package note: this preview .deb installs the browser fallback utility, not the Electron desktop app.\n'

scripts/install-electron-local.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
3+
umask 077
34

45
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
56
REPO_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
@@ -43,6 +44,7 @@ if [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
4344
fi
4445

4546
mkdir -p "$BIN_DIR" "$APP_DIR" "$ICON_DIR" "$CONFIG_DIR" "$(dirname "$TARGET_APP_ROOT")"
47+
chmod 700 "$CONFIG_DIR" >/dev/null 2>&1 || true
4648

4749
detect_config_value() {
4850
local wrapper_path="$1"
@@ -137,13 +139,17 @@ copy_app_root_into_local_opt() {
137139
write_config_file() {
138140
local app_root="$1"
139141
local node_bin_dir="$2"
142+
local temp_config="${CONFIG_FILE}.tmp.$$"
140143

141144
{
142145
printf 'CODEX_UBUNTU_ELECTRON_APP_ROOT=%q\n' "$app_root"
143146
if [ -n "$node_bin_dir" ]; then
144147
printf 'CODEX_UBUNTU_NODE_BIN_DIR=%q\n' "$node_bin_dir"
145148
fi
146-
} >"$CONFIG_FILE"
149+
} >"$temp_config"
150+
151+
chmod 600 "$temp_config"
152+
mv "$temp_config" "$CONFIG_FILE"
147153
}
148154

149155
write_primary_wrapper() {

0 commit comments

Comments
 (0)