Skip to content

Commit 4a8c17b

Browse files
committed
merge mv2
2 parents d9d10a0 + 98a5f3e commit 4a8c17b

6 files changed

Lines changed: 81 additions & 29 deletions

File tree

AGENTS.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- command: `npx -y chrome-devtools-mcp@latest --browserUrl=http://127.0.0.1:9222`
1414
- Use `scripts/codex-dev.sh watch` once per session to keep Chrome extension builds live in the background.
1515
- On `main`, this resolves to MV3 scripts (`dev:chrome`/`build:chrome`) and `build/chrome` output automatically.
16+
- On `mv2`, watcher mode prefers `npm run start:none` so build watch stays alive without separate browser autolaunch.
1617
- Start headless browser testing only when explicitly requested (for example: "go test", "test this", "run browser test").
1718
- For test runs, use `scripts/codex-dev.sh go-test`. This guarantees:
1819
- MCP configuration is present
@@ -31,6 +32,16 @@
3132
- settings/storage/messaging code under `src/ts/**`
3233
- The reload is intentionally hard (full browser restart) to avoid stale MV3 service-worker state, extension cache artifacts, and mixed-profile debugging drift.
3334

35+
## UI Name Formatting
36+
37+
- For chat author display, hide a leading `@` in UI text while keeping underlying identity data unchanged.
38+
- Use `src/ts/author-name.ts` (`formatAuthorName`) for this transformation and apply it at render points.
39+
40+
## Testbed URL
41+
42+
- Headless validation should open the same `startUrl` used by `vite.config.ts`.
43+
- `scripts/codex-dev.sh go-test` now does this automatically (defaulting by detected mode), and `TEST_URL` can override when needed.
44+
3445
## Operational Commands
3546

3647
- `scripts/codex-dev.sh status` shows watcher/MCP/browser states.

scripts/codex-dev.sh

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ STATE_DIR="$REPO_ROOT/.codex-runtime"
77
PROFILE_DIR="${USER_DATA_DIR:-$REPO_ROOT/.codex-profile}"
88
REMOTE_DEBUGGING_PORT="${REMOTE_DEBUGGING_PORT:-9222}"
99
CHROME_BIN="${CHROME_BIN:-google-chrome}"
10+
TEST_URL="${TEST_URL:-}"
1011

1112
WATCH_PID_FILE="$STATE_DIR/watch.pid"
1213
WATCH_LOG_FILE="$STATE_DIR/watch.log"
@@ -16,6 +17,7 @@ WATCH_NPM_SCRIPT=""
1617
BUILD_NPM_SCRIPT=""
1718
EXT_PATH=""
1819
MODE_LABEL=""
20+
DEFAULT_TEST_URL=""
1921

2022
mkdir -p "$STATE_DIR"
2123

@@ -28,6 +30,19 @@ detect_repo_scripts() {
2830
BUILD_NPM_SCRIPT="build:chrome"
2931
EXT_PATH="$REPO_ROOT/build/chrome"
3032
MODE_LABEL="mv3"
33+
DEFAULT_TEST_URL="https://www.youtube.com/watch?v=jfKfPfyJRdk"
34+
return 0
35+
fi
36+
37+
if (
38+
cd "$REPO_ROOT" &&
39+
node -e 'const s=require("./package.json").scripts||{}; process.exit(s["start:none"] && s["build"] ? 0 : 1);'
40+
); then
41+
WATCH_NPM_SCRIPT="start:none"
42+
BUILD_NPM_SCRIPT="build"
43+
EXT_PATH="$REPO_ROOT/build"
44+
MODE_LABEL="mv2"
45+
DEFAULT_TEST_URL="https://www.youtube.com/watch?v=5qap5aO4i9A"
3146
return 0
3247
fi
3348

@@ -39,6 +54,7 @@ detect_repo_scripts() {
3954
BUILD_NPM_SCRIPT="build"
4055
EXT_PATH="$REPO_ROOT/build"
4156
MODE_LABEL="mv2"
57+
DEFAULT_TEST_URL="https://www.youtube.com/watch?v=5qap5aO4i9A"
4258
return 0
4359
fi
4460

@@ -116,6 +132,9 @@ setup_mcp() {
116132
start_browser() {
117133
detect_repo_scripts
118134
resolve_chrome_bin
135+
if [[ -z "$TEST_URL" ]]; then
136+
TEST_URL="$DEFAULT_TEST_URL"
137+
fi
119138
if [[ ! -f "$EXT_PATH/manifest.json" ]]; then
120139
echo "browser: extension build not found, running npm run $BUILD_NPM_SCRIPT"
121140
(
@@ -127,32 +146,37 @@ start_browser() {
127146
rm -rf "$PROFILE_DIR"
128147
mkdir -p "$PROFILE_DIR"
129148

130-
echo "browser: starting headless Chrome with extension"
131-
nohup "$CHROME_BIN" \
132-
--user-data-dir="$PROFILE_DIR" \
133-
--remote-debugging-port="$REMOTE_DEBUGGING_PORT" \
134-
--disable-gpu \
135-
--headless=new \
136-
--disable-extensions-except="$EXT_PATH" \
137-
--load-extension="$EXT_PATH" \
138-
--no-first-run \
139-
--no-default-browser-check \
140-
--disable-background-timer-throttling \
141-
--disable-renderer-backgrounding \
142-
--disable-dev-shm-usage \
143-
--disable-features=IsolateOrigins,site-per-process,TranslateUI \
144-
--disable-web-security \
145-
--allow-running-insecure-content \
146-
--allow-insecure-localhost \
147-
--no-sandbox \
148-
--disable-setuid-sandbox \
149-
--noerrdialogs \
150-
--disable-notifications \
151-
--disable-translate \
152-
--disable-infobars \
153-
--autoplay-policy=no-user-gesture-required \
154-
--enable-automation \
155-
>"$BROWSER_LOG_FILE" 2>&1 &
149+
local browser_args=(
150+
--user-data-dir="$PROFILE_DIR"
151+
--remote-debugging-port="$REMOTE_DEBUGGING_PORT"
152+
--disable-gpu
153+
--headless=new
154+
--disable-extensions-except="$EXT_PATH"
155+
--load-extension="$EXT_PATH"
156+
--no-first-run
157+
--no-default-browser-check
158+
--disable-background-timer-throttling
159+
--disable-renderer-backgrounding
160+
--disable-dev-shm-usage
161+
--disable-features=IsolateOrigins,site-per-process,TranslateUI
162+
--disable-web-security
163+
--allow-running-insecure-content
164+
--allow-insecure-localhost
165+
--no-sandbox
166+
--disable-setuid-sandbox
167+
--noerrdialogs
168+
--disable-notifications
169+
--disable-translate
170+
--disable-infobars
171+
--autoplay-policy=no-user-gesture-required
172+
--enable-automation
173+
)
174+
if [[ -n "$TEST_URL" ]]; then
175+
browser_args+=("$TEST_URL")
176+
fi
177+
178+
echo "browser: starting headless Chrome with extension (url: $TEST_URL)"
179+
nohup "$CHROME_BIN" "${browser_args[@]}" >"$BROWSER_LOG_FILE" 2>&1 &
156180

157181
echo $! >"$BROWSER_PID_FILE"
158182
local pid
@@ -193,6 +217,10 @@ status() {
193217
echo "watch: stopped"
194218
fi
195219
echo "mode: $MODE_LABEL (watch=$WATCH_NPM_SCRIPT build=$BUILD_NPM_SCRIPT ext=$EXT_PATH)"
220+
if [[ -z "$TEST_URL" ]]; then
221+
TEST_URL="$DEFAULT_TEST_URL"
222+
fi
223+
echo "test-url: $TEST_URL"
196224
if codex mcp list 2>/dev/null | rg -q '^chrome-devtools'; then
197225
echo "mcp: configured in Codex as chrome-devtools"
198226
else
@@ -218,6 +246,9 @@ Commands:
218246
stop Stop browser and watcher.
219247
status Show process status and log directory.
220248
logs Print paths for watch/browser logs.
249+
250+
Environment:
251+
TEST_URL Optional override for the page opened in headless test browser.
221252
EOF
222253
}
223254

src/components/MembershipItem.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
22
import Message from './Message.svelte';
33
import MessageRun from './MessageRuns.svelte';
4+
import { formatAuthorName } from '../ts/author-name';
45
import { showProfileIcons } from '../ts/storage';
56
import { membershipBackground, milestoneChatBackground } from '../ts/chat-constants';
67
@@ -14,6 +15,7 @@
1415
console.error('Not a membership item', { message });
1516
}
1617
$: isMilestoneChat = message.message.length > 0;
18+
$: displayAuthorName = formatAuthorName(message.author.name);
1719
1820
$: primaryText = (membership ?? membershipGift)?.headerPrimaryText;
1921
</script>
@@ -32,7 +34,7 @@
3234
/>
3335
{/if}
3436
<span class="font-bold tracking-wide align-middle mr-3">
35-
{message.author.name}
37+
{displayAuthorName}
3638
</span>
3739
{#if primaryText && primaryText.length > 0}
3840
<MessageRun

src/components/Message.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
} from '../ts/storage';
1515
import { chatUserActionsItems, Theme } from '../ts/chat-constants';
1616
import { useBanHammer } from '../ts/chat-actions';
17+
import { formatAuthorName } from '../ts/author-name';
1718
import type { Chat } from '../ts/typings/chat';
1819
1920
export let message: Ytc.ParsedMessage;
@@ -58,6 +59,7 @@
5859
$: if (deleted != null) {
5960
message.message = deleted.replace;
6061
}
62+
$: displayAuthorName = formatAuthorName(message.author.name);
6163
6264
$: showUserMargin = $showProfileIcons || $showUsernames || $showTimestamps ||
6365
($showUserBadges && (moderator || verified || member));
@@ -107,7 +109,7 @@
107109
class="{nameClass} {nameColorClass}"
108110
class:hidden={!$showUsernames}
109111
>
110-
{message.author.name}
112+
{displayAuthorName}
111113
</span>
112114
</a>
113115
<span class="align-middle" class:hidden={!$showUserBadges}>

src/components/PaidMessage.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import Message from './Message.svelte';
33
import isDarkColor from 'is-dark-color';
44
import { Theme } from '../ts/chat-constants';
5+
import { formatAuthorName } from '../ts/author-name';
56
import { showProfileIcons } from '../ts/storage';
67
78
export let message: Ytc.ParsedMessage;
@@ -22,6 +23,7 @@
2223
}
2324
2425
const classes = 'inline-flex flex-col rounded break-words overflow-hidden w-full';
26+
$: displayAuthorName = formatAuthorName(message.author.name);
2527
2628
$: if (!paid) {
2729
console.error('Not a paid message', { message });
@@ -44,7 +46,7 @@
4446
{/if}
4547
<span class="mr-1 underline font-bold">{amount}</span>
4648
<span class="font-bold tracking-wide" style={nameColor}>
47-
{message.author.name}
49+
{displayAuthorName}
4850
</span>
4951
{#if message.superSticker}
5052
<img

src/ts/author-name.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const formatAuthorName = (name: string): string => {
2+
if (!name.startsWith('@')) return name;
3+
return name.slice(1);
4+
};

0 commit comments

Comments
 (0)