Skip to content

refactor(comments): slim verbose comments in mobile - #9547

Merged
nwparker merged 1 commit into
mainfrom
nwparker/slim-comments-mobile
Jul 20, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/slim-comments-mobile

Conversation

@nwparker

@nwparker nwparker commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Slim verbose code comments — mobile

Part of a codebase-wide sweep to slim over-verbose comments per AGENTS.md → Document the "Why", Briefly. Comments should state the non-obvious why, not narrate the what/how when the code is already clear; multi-line blocks collapse to a single line.

This PR — mobile: 11 files changed, 339 insertions(+), 1137 deletions(-).

What changed

  • Multi-line Why: paragraphs → one-line why-statements.
  • Deleted comments that merely restated the adjacent code.
  • Kept: license headers, directives (eslint-disable, @ts-expect-error, oxlint-disable, …), TODO/FIXME, JSDoc tags, and every genuine non-obvious reason / external reference (issue numbers, platform quirks, race & ordering constraints).
  • useEffect / regex / bitwise / concurrency: kept a ≤1-line summary where it aids reading.
  • JSX {/* … */} comment text shortened; comments inside template-literal strings left untouched.

Safety

Every file in this PR is comments-only — enforced deterministically by stripping all comments (incl. JSX {/* */}) from both origin/main and the change and confirming the remaining code tokens are identical. pnpm typecheck ✅ · oxlint ✅ (no new findings vs main).

Part of a set of 6 area PRs from one sweep.

🤖 Generated with Claude Code

Made with Orca 🐋

Collapse multi-line explanatory comment blocks into single-line "why" statements
per AGENTS.md ("Document the Why, Briefly"): drop restatements of the code and
mechanism narration; keep the non-obvious reason, external refs, and directives.

Comments-only — verified no code changed via a Babel/esbuild comment-strip
token-equality gate against origin/main; typecheck and oxlint clean.

Area: mobile. 11 files changed, 339 insertions(+), 1137 deletions(-).

Co-authored-by: Orca <help@stably.ai>
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request updates mobile home, host, session, transport, notification, and source-control code. Behavioral changes include cache hydration and preservation, client replacement tracking, foreground notification handling, worktree limits, host removal retry state, usage rendering, bottom inset handling, connection logging, and action labels. Most remaining changes revise inline documentation for lifecycle, synchronization, keyboard, terminal, notification, persistence, and PR-loading behavior.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description lacks the required template sections for Screenshots, Testing, AI Review Report, Security Audit, and Notes. Add the missing template sections and fill in screenshots, testing, AI review, security audit, and notes to match the repository format.
Docstring Coverage ⚠️ Warning Docstring coverage is 27.03% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: slimming comments in mobile.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
mobile/app/index.tsx (1)

327-332: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Move ref mutation into an effect to preserve render purity.

Mutating allClientsRef.current directly during render violates React's purity rules and can lead to inconsistent state in Concurrent Mode (and multiple invocations in Strict Mode).

Move this assignment into a useEffect block, matching the pattern used for clientRef in the host screen.

♻️ Proposed fix
-  allClientsRef.current = allClients.map((entry) => ({
-    hostId: entry.hostId,
-    client: entry.client
-  }))
+  useEffect(() => {
+    allClientsRef.current = allClients.map((entry) => ({
+      hostId: entry.hostId,
+      client: entry.client
+    }))
+  }, [allClients])

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: dc005ffe-8956-40a5-b3b6-5e963eb4aa9f

📥 Commits

Reviewing files that changed from the base of the PR and between 53aeeb7 and 5f5b78e.

📒 Files selected for processing (11)
  • mobile/app/h/[hostId]/index.tsx
  • mobile/app/h/[hostId]/session/[worktreeId].tsx
  • mobile/app/index.tsx
  • mobile/src/notifications/mobile-notifications.ts
  • mobile/src/session/use-mobile-pr-sidebar-controller.ts
  • mobile/src/source-control/MobileSourceControlPanel.tsx
  • mobile/src/terminal/terminal-viewport-refit.ts
  • mobile/src/terminal/terminal-webview-html.ts
  • mobile/src/transport/client-context.tsx
  • mobile/src/transport/host-store.ts
  • mobile/src/transport/rpc-client.ts

Comment thread mobile/app/index.tsx
Comment on lines +667 to 670
// Why: ConfirmModal closes on confirm; re-open for retry so the failure isn't silent.
setConfirmRemove(hostToRemove)
Alert.alert('Could not remove host', 'Please try again.')
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Clear state to prevent the confirm modal from getting stuck.

In both files, the host removal catch block attempts to update the confirm state using the exact same value it already holds (hostToRemove or true). Because React uses Object.is for state comparisons, it will bail out of the update and skip re-rendering.

Since ConfirmModal closes internally on confirm, the parent state is left out of sync. This prevents the user from opening the modal again on subsequent removal attempts because setting the state to the identical value will continually be ignored.

Clear the state instead so it matches the closed modal, relying on the Alert to inform the user of the failure:

  • mobile/app/index.tsx#L667-L670: change setConfirmRemove(hostToRemove) to setConfirmRemove(null).
  • mobile/app/h/[hostId]/index.tsx#L665-L668: change setConfirmRemoveHost(true) to setConfirmRemoveHost(false).
📍 Affects 2 files
  • mobile/app/index.tsx#L667-L670 (this comment)
  • mobile/app/h/[hostId]/index.tsx#L665-L668

@nwparker
nwparker merged commit c6f0ac4 into main Jul 20, 2026
3 checks passed
@nwparker
nwparker deleted the nwparker/slim-comments-mobile branch July 20, 2026 10:18
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Collapse multi-line explanatory comment blocks into single-line "why" statements
per AGENTS.md ("Document the Why, Briefly"): drop restatements of the code and
mechanism narration; keep the non-obvious reason, external refs, and directives.

Comments-only — verified no code changed via a Babel/esbuild comment-strip
token-equality gate against origin/main; typecheck and oxlint clean.

Area: mobile. 11 files changed, 339 insertions(+), 1137 deletions(-).

Co-authored-by: Orca <help@stably.ai>
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.

1 participant