Skip to content

Fix 6 dogfooding bugs from session 38#49

Merged
ractive merged 2 commits intomainfrom
iter-47/dogfood-bugfixes
Apr 17, 2026
Merged

Fix 6 dogfooding bugs from session 38#49
ractive merged 2 commits intomainfrom
iter-47/dogfood-bugfixes

Conversation

@ractive
Copy link
Copy Markdown
Owner

@ractive ractive commented Apr 17, 2026

Summary

  • launch: Auto-create temp profile with devtools prefs when no --profile/--temp-profile given, so ff-rdp launch --headless --port 6000 works on first use without manual user.js setup
  • scroll: Use requestAnimationFrame to defer position reads after scrollTo/scrollBy/scrollIntoView, fixing stale viewport.y reporting (e.g. scroll bottom reporting y: 0)
  • text formatters: Add --format text for geometry (tabular with overlaps), network summary (sections: totals, by-cause-type, slowest), and dom tree (indented tree matching snapshot --format text style)
  • responsive: Replace fixed 50ms sleep with JS layout stabilization (requestAnimationFrame + setTimeout(0)) to prevent implausible negative rect.y on complex pages
  • recipes/llm-help: Hide irrelevant global flags (--host, --port, --timeout, etc.) from --help output via custom help_template
  • reload --wait-idle: Verified already fixed in prior iteration (idle timer only arms after first network event)

Test plan

  • cargo fmt — clean
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo test --workspace -q — 693 tests pass
  • Unit tests for launch auto-profile creation and devtools pref writing
  • Scroll JS templates verified to contain requestAnimationFrame and Promise
  • Text formatter smoke tests for geometry, network summary, dom tree (empty/full/edge cases)
  • Responsive e2e tests updated for extra layout-wait eval call (3×N+2 sequence)
  • Static command help tests assert --host/--port/--timeout hidden from recipes --help and llm-help --help

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added readable text output for DOM tree, geometry, and network summary (use --format text)
    • ff-rdp launch now auto-creates a Firefox profile when none is specified
  • Bug Fixes

    • Fixed scroll viewport position reporting (measurements now reflect post-scroll state)
    • Improved responsive layout timing for stable geometry captures
    • Fixed fresh Firefox profile initialization issues
    • Hid irrelevant global flags from static command help outputs
  • Documentation

    • Added dogfooding and iteration notes for recent fixes and tests

1. launch: auto-create temp profile with devtools prefs when no
   --profile/--temp-profile given, so debugger server always starts
2. scroll: use requestAnimationFrame to read post-scroll position,
   fixing stale viewport.y reporting in top/bottom/by/to/container
3. text formatters: add --format text for geometry (tabular), network
   summary (sections), and dom tree (indented tree)
4. reload --wait-idle: already fixed (prior iter); task verified
5. responsive: replace fixed 50ms sleep with JS layout stabilization
   (rAF + setTimeout) to prevent negative rect.y on complex pages
6. recipes/llm-help: hide irrelevant global flags via help_template

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ee900a15-b42a-433f-96ec-e69f14025bec

📥 Commits

Reviewing files that changed from the base of the PR and between c3bd9b1 and 1c92b99.

📒 Files selected for processing (4)
  • crates/ff-rdp-cli/src/commands/dom_tree.rs
  • crates/ff-rdp-cli/src/commands/geometry.rs
  • kb/dogfooding/dogfooding-session-38.md
  • kb/iterations/iteration-47-dogfood-bugfixes.md

📝 Walkthrough

Walkthrough

Adds text-format short-circuits for geometry/network/dom-tree, auto-creates temporary Firefox profiles with required user.js prefs in launch, replaces fixed sleep with requestAnimationFrame-based layout wait in responsive, defers scroll measurements to rAF Promises, hides global flags in static help, and adds related e2e tests and docs.

Changes

Cohort / File(s) Summary
Command Help Output
crates/ff-rdp-cli/src/cli/args.rs
Added help_template to Recipes and LlmHelp subcommands to change help rendering (shows {about-with-newline} and {usage} blocks), removing irrelevant inherited global flags from those helps.
DOM Tree Text Output
crates/ff-rdp-cli/src/commands/dom_tree.rs
When --format text (and no jq) short-circuits JSON envelope and prints an indented DOM tree; added render_dom_tree_text, render_dom_node, and unit tests.
Geometry Text Output
crates/ff-rdp-cli/src/commands/geometry.rs
When --format text (and no jq) prints a formatted geometry table (viewport header, elements, overlaps) via render_geometry_text; handles empty elements and truncation; added unit tests.
Network Summary Text
crates/ff-rdp-cli/src/commands/network.rs
When --format text (and no jq) prints a human-readable network summary via render_network_summary_text; defensive handling of missing fields; added unit tests.
Launch: Auto Temp Profile
crates/ff-rdp-cli/src/commands/launch.rs
build_command auto-creates a temp Firefox profile when neither --profile nor --temp-profile is provided, writes user.js with remote-debug prefs, updates auto_consent behavior and reports effective temp_profile in JSON; tests updated/added.
Async Layout & Scroll Timing
crates/ff-rdp-cli/src/commands/responsive.rs, crates/ff-rdp-cli/src/commands/scroll.rs
Replaced fixed sleep with WAIT_LAYOUT_STABLE_JS (rAF + setTimeout) and surface JS errors; scroll JS now wraps measurements in requestAnimationFrame Promises to defer sampling to next frame; updated test expectations.
E2E Tests
crates/ff-rdp-cli/tests/e2e/main.rs, .../responsive.rs, .../static_commands.rs
Added mod static_commands;; updated responsive e2e to expect extra layout wait evaluate call; added static help tests verifying recipes --help and llm-help --help hide global flags.
Documentation / KB
kb/dogfooding/dogfooding-session-38.md, kb/iterations/iteration-47-dogfood-bugfixes.md
New dogfooding session and iteration writeups documenting fixes, regressions, acceptance criteria, and recommendations.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through code and left a trail of light,
Text trees and tables now print just right.
Temp profiles sprout where none were sown,
rAF sleeps, scrolls resolve when grown—
Hooray! Help hides flags; the rabbit dances tonight. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix 6 dogfooding bugs from session 38' directly summarizes the main objective: addressing six bugs identified during dogfooding session 38, which aligns perfectly with the changeset content.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch iter-47/dogfood-bugfixes

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
crates/ff-rdp-cli/src/commands/launch.rs (1)

246-271: Consider extracting shared temp-profile creation logic.

The code in this else branch (lines 247-270) is nearly identical to the else if temp_profile branch (lines 225-245). Both create a temp directory, write USER_JS, and add --profile to the command.

This duplication is minor but could be consolidated into a helper function.

♻️ Suggested refactor to reduce duplication
fn create_temp_profile_dir() -> Result<PathBuf, AppError> {
    let nonce = std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .map(|d| d.as_micros())
        .unwrap_or(0);
    let tmp = std::env::temp_dir().join(format!("ff-rdp-profile-{}-{nonce}", std::process::id()));
    std::fs::create_dir_all(&tmp).map_err(|e| {
        AppError::User(format!(
            "failed to create temporary profile directory {}: {e}",
            tmp.display()
        ))
    })?;
    std::fs::write(tmp.join("user.js"), USER_JS).map_err(|e| {
        AppError::User(format!(
            "failed to write user.js to temporary profile {}: {e}",
            tmp.display()
        ))
    })?;
    Ok(tmp)
}

Then both branches can call create_temp_profile_dir().

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/ff-rdp-cli/src/commands/launch.rs` around lines 246 - 271, Extract the
duplicated temp-profile creation logic into a helper function (e.g.,
create_temp_profile_dir) and call it from both the temp_profile branch and the
final else branch that currently builds `tmp`, creates the directory, writes
`USER_JS`, and sets `--profile` on `cmd`; the helper should return a
Result<PathBuf, AppError>, perform the nonce/timestamp and pid naming, create
the directory, write `USER_JS`, and let callers set
`cmd.arg("--profile").arg(&tmp)` and handle the returned PathBuf (or propagate
the AppError).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/ff-rdp-cli/src/commands/dom_tree.rs`:
- Around line 109-156: The truncation of attribute value in render_dom_node
currently slices by byte index (&value[..37]) which can panic on multi-byte
UTF-8; replace the byte-slice with a safe Unicode-aware truncate (e.g., build a
truncated string via value.chars().take(37).collect::<String>() and append "..."
when original value.len() in chars() > 37, or use the unicode-truncate crate)
and update the local variable `val` assignment where `value` is processed so all
attribute truncation is UTF-8 safe.

In `@kb/dogfooding/dogfooding-session-38.md`:
- Around line 27-31: The fenced code block containing the Firefox prefs lines
(user_pref("devtools.debugger.remote-enabled", true);
user_pref("devtools.debugger.prompt-connection", false);
user_pref("devtools.chrome.enabled", true);) lacks a language identifier; update
the opening fence to include a language (e.g., js) so the block becomes ```js to
satisfy MD040 and improve rendering.

---

Nitpick comments:
In `@crates/ff-rdp-cli/src/commands/launch.rs`:
- Around line 246-271: Extract the duplicated temp-profile creation logic into a
helper function (e.g., create_temp_profile_dir) and call it from both the
temp_profile branch and the final else branch that currently builds `tmp`,
creates the directory, writes `USER_JS`, and sets `--profile` on `cmd`; the
helper should return a Result<PathBuf, AppError>, perform the nonce/timestamp
and pid naming, create the directory, write `USER_JS`, and let callers set
`cmd.arg("--profile").arg(&tmp)` and handle the returned PathBuf (or propagate
the AppError).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ddf17df2-90a5-490c-be66-d6dceec8d4d2

📥 Commits

Reviewing files that changed from the base of the PR and between 3f4deb2 and c3bd9b1.

📒 Files selected for processing (12)
  • crates/ff-rdp-cli/src/cli/args.rs
  • crates/ff-rdp-cli/src/commands/dom_tree.rs
  • crates/ff-rdp-cli/src/commands/geometry.rs
  • crates/ff-rdp-cli/src/commands/launch.rs
  • crates/ff-rdp-cli/src/commands/network.rs
  • crates/ff-rdp-cli/src/commands/responsive.rs
  • crates/ff-rdp-cli/src/commands/scroll.rs
  • crates/ff-rdp-cli/tests/e2e/main.rs
  • crates/ff-rdp-cli/tests/e2e/responsive.rs
  • crates/ff-rdp-cli/tests/e2e/static_commands.rs
  • kb/dogfooding/dogfooding-session-38.md
  • kb/iterations/iteration-47-dogfood-bugfixes.md

Comment thread crates/ff-rdp-cli/src/commands/dom_tree.rs
Comment thread kb/dogfooding/dogfooding-session-38.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses several dogfooding-session bugs by improving first-run launch behavior, fixing scroll position staleness, adding missing --format text outputs, stabilizing responsive layout measurement, and reducing irrelevant flags shown in help for static-output commands.

Changes:

  • Auto-create a temporary Firefox profile (with required devtools prefs) when ff-rdp launch is run without --profile/--temp-profile.
  • Fix scroll commands’ stale viewport readings by deferring position reads via requestAnimationFrame.
  • Add/extend --format text support (geometry table, network summary text, DOM tree text) and stabilize responsive geometry via a layout-wait JS snippet; add e2e coverage for static-help output.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
kb/iterations/iteration-47-dogfood-bugfixes.md Adds iteration writeup and acceptance criteria for the dogfood bugfix set.
kb/dogfooding/dogfooding-session-38.md Adds session notes that motivated the fixes and documents observed issues.
crates/ff-rdp-cli/tests/e2e/static_commands.rs Adds e2e tests asserting recipes/llm-help --help omit irrelevant global flags.
crates/ff-rdp-cli/tests/e2e/responsive.rs Updates responsive test server expectations to include a per-width layout-wait eval call.
crates/ff-rdp-cli/tests/e2e/main.rs Registers the new static_commands e2e module.
crates/ff-rdp-cli/src/commands/scroll.rs Defers post-scroll viewport reads with requestAnimationFrame to avoid stale positions.
crates/ff-rdp-cli/src/commands/responsive.rs Replaces fixed sleep with JS-based layout stabilization before geometry capture.
crates/ff-rdp-cli/src/commands/network.rs Adds a text-rendered network summary path for --format text in summary mode.
crates/ff-rdp-cli/src/commands/launch.rs Auto-creates a temp profile with devtools prefs when no profile flag is provided.
crates/ff-rdp-cli/src/commands/geometry.rs Adds a text-rendered geometry table path for --format text.
crates/ff-rdp-cli/src/commands/dom_tree.rs Adds an indented DOM tree text renderer for --format text.
crates/ff-rdp-cli/src/cli/args.rs Uses custom clap help_template for recipes and llm-help to reduce irrelevant flag output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to +33
### 1. Fix `ff-rdp launch` to write remote debugging prefs [0/3]

`ff-rdp launch --headless --port 6000` fails to connect on a fresh profile because Firefox's remote debugging prefs aren't set. Users must manually create a `user.js` with `devtools.debugger.remote-enabled`, `devtools.debugger.prompt-connection`, and `devtools.chrome.enabled`. The `launch` command should handle this automatically.

- [x] When creating/using a profile, write the required `user.js` prefs (`devtools.debugger.remote-enabled=true`, `devtools.debugger.prompt-connection=false`, `devtools.chrome.enabled=true`) before launching Firefox
- [x] Only write prefs if the profile doesn't already have them (avoid clobbering user customizations)
- [x] Add e2e test that verifies `launch` creates a connectable Firefox instance with a fresh temp profile
Comment on lines +124 to +125
let val = if value.len() > 40 {
format!("{}...", &value[..37])
Comment on lines +111 to +113
let tag = node_name.to_lowercase();
let mut line = format!("{indent}<{tag}");

Comment on lines +155 to +159
// Text short-circuit: render a human-readable table instead of JSON.
if cli.format == "text" && cli.jq.is_none() {
render_geometry_text(&results);
return Ok(());
}
…xt path

- Fix potential panic in dom_tree text renderer: byte-slice truncation
  (&value[..37]) replaced with char-based truncation to handle multi-byte
  UTF-8 safely (found by all three reviewers)
- Add missing closing `>` on element tags in dom_tree text output
- Fix geometry --format text not applying to zero-match early return path
- Update iteration-47 task progress headers to match completed checkboxes
- Add language identifier to fenced code block in dogfooding session notes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ractive ractive merged commit be0fe01 into main Apr 17, 2026
2 of 6 checks passed
@ractive ractive deleted the iter-47/dogfood-bugfixes branch April 17, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants