Skip to content

Fix/skill start issue#498

Merged
M3gA-Mind merged 9 commits intotinyhumansai:mainfrom
M3gA-Mind:fix/skill-start-issue
Apr 10, 2026
Merged

Fix/skill start issue#498
M3gA-Mind merged 9 commits intotinyhumansai:mainfrom
M3gA-Mind:fix/skill-start-issue

Conversation

@M3gA-Mind
Copy link
Copy Markdown
Contributor

@M3gA-Mind M3gA-Mind commented Apr 10, 2026

Summary

  • What changed and why.
  • Keep this to 3-6 bullets focused on user-visible or architecture-impacting changes.

Problem

  • What issue or risk this PR addresses.
  • Include context needed for reviewers to evaluate correctness quickly.

Solution

  • How the implementation solves the problem.
  • Note important design decisions and tradeoffs.

Submission Checklist

  • Unit tests — Vitest (app/) and/or cargo test (core) for logic you add or change
  • E2E / integration — Where behavior is user-visible or crosses UI → Tauri → sidecar → JSON-RPC; use existing harnesses (app/test/e2e, mock backend, tests/json_rpc_e2e.rs as appropriate)
  • N/A — If truly not applicable, say why (e.g. change is documentation-only)
  • Doc comments/// / //! (Rust), JSDoc or brief file/module headers (TS) on public APIs and non-obvious modules
  • Inline comments — Where logic, invariants, or edge cases aren’t clear from names alone (keep them grep-friendly; avoid restating the code)

(Any feature related checklist can go in here)

Impact

  • Runtime/platform impact (desktop/mobile/web/CLI), if any.
  • Performance, security, migration, or compatibility implications.

Related

  • Issue(s):
  • Follow-up PR(s)/TODOs:

Summary by CodeRabbit

  • New Features

    • More reliable OAuth completion that auto-advances once the runtime is running and shows “You can close this window.”
    • UI now synthesizes offline skill snapshots so status remains visible if runtime calls fail.
  • Bug Fixes

    • Prevents duplicate auto-advance and surfaces start/setup failures; removes extra post‑OAuth syncing and ensures runtime workspace is applied on start/install.
  • Tests

    • Added E2E and integration tests plus shared test mocks covering setup completion, OAuth flows, and status behavior.

- Added `overlay/src-tauri/target/` to .gitignore to prevent tracking of build artifacts.
- Updated the openhuman package version from 0.52.0 to 0.52.2 in Cargo.lock files for both the main and app/src-tauri directories.
- Enhanced entitlements for macOS Hardened Runtime to allow outbound HTTPS calls and server connections.
- Refactored registry operations to use rustls explicitly, improving network reliability on macOS.
…s function

- Updated the logging statement in the fetch_url_bytes function to enhance readability by formatting the debug message across multiple lines. This change improves clarity in log outputs, making it easier to track the number of bytes fetched from URLs.
…ation

- Introduced a managed OAuth auto-advance mechanism to ensure it runs only once per login attempt, improving user experience during authentication.
- Updated the SkillSetupWizard to handle skill runtime checks more effectively, ensuring that the skill starts correctly and transitions to the setup phase seamlessly.
- Enhanced the useSkillSnapshot hook to provide a synthesized offline snapshot when the skill is not yet running, preventing UI stalls during loading.
- Implemented background synchronization after OAuth completion to ensure users see fresh data immediately without blocking the UI.
- Added tests to validate the new behavior for skills setup completion and status retrieval without requiring the skill to be started first.
…s_status function

- Simplified the retrieval of the `setup_complete` variable by removing unnecessary line breaks, enhancing code readability and maintainability.
- This change improves the clarity of the function's logic without altering its functionality.
…om OAuth flow

- Updated the success message in the SkillSetupWizard to remove references to background syncing, streamlining user communication.
- Removed the initial sync trigger from the SkillManager after OAuth completion, shifting the responsibility for data synchronization to the user interface or cron jobs.
- Adjusted comments in the desktopDeepLinkListener to reflect the new sync behavior, clarifying that initial data sync is no longer automatic.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3c1a5c2b-638c-46fb-a010-5cb87821651b

📥 Commits

Reviewing files that changed from the base of the PR and between 55a7eaa and 4781b16.

📒 Files selected for processing (2)
  • app/src/components/skills/SkillSetupWizard.tsx
  • app/src/test/mockDefaultSkillStatusHooks.ts
✅ Files skipped from review due to trivial changes (1)
  • app/src/test/mockDefaultSkillStatusHooks.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/components/skills/SkillSetupWizard.tsx

📝 Walkthrough

Walkthrough

Refactors OAuth completion and skill startup flows to always start skills and poll for a running state, remove fire‑and‑forget post‑OAuth syncs, synthesize offline snapshots on RPC failures, sync QuickJS workspace_dir during install/start, and add Rust and Playwright E2E tests plus shared frontend test mocks.

Changes

Cohort / File(s) Summary
Skill setup & OAuth flow
app/src/components/skills/SkillSetupWizard.tsx, app/src/utils/desktopDeepLinkListener.ts, app/src/lib/skills/manager.ts
Always call startSkill and wait for running (polling helper); remove fire‑and‑forget initial syncs after OAuth; introduce guarded refs (managedOAuthAdvancedRef, legacyOAuthAdvancedRef) to prevent duplicate auto-advance; errors set wizard to error with logs; desktop deep link now best‑effort starts skill then calls notifyOAuthComplete without extra sync.
Offline snapshot & hook behavior
app/src/lib/skills/hooks.ts
Added offlineSkillSnapshot helper and changed useSkillSnapshot to set a synthesized offline snapshot on RPC/runtime failures so hooks return non-null snapshots.
Runtime engine workspace & status synthesis
src/openhuman/skills/schemas.rs
Set QuickJS workspace_dir from config during skills_install and skills_start; skills_status now returns a synthesized Pending snapshot (derives setup_complete from persisted preferences) when runtime lacks the skill instead of returning an error.
JSON-RPC & Rust E2E tests
tests/json_rpc_e2e.rs
Extended test skill JS with start() handler; added wait_for_skill_status_running polling helper; added tests validating skills_set_setup_complete reflects without runtime and oauth/complete returns skill start() result after start.
Playwright E2E tests
app/test/e2e/specs/skill-execution-flow.spec.ts, app/test/e2e/specs/skill-oauth.spec.ts
Added E2E spec that sets setup_complete without starting runtime and checks status; clarified comments about broader JSON‑RPC OAuth coverage.
Frontend tests: shared status hook mocks
app/src/test/mockDefaultSkillStatusHooks.ts, app/src/pages/__tests__/Skills.third-party-gmail-sync.test.tsx, app/src/pages/__tests__/Skills.third-party-notion-debug-tools.test.tsx
Added a shared Vitest mock module providing consistent offline skill-status hook returns and imported it into two tests (no other test logic changes).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as SkillSetupWizard (UI)
  participant Deep as DesktopDeepLinkListener
  participant Manager as SkillManager
  participant Engine as RuntimeEngine/Skill

  User->>UI: Initiate OAuth / open external URL
  Note right of User: Complete OAuth in browser
  User->>Deep: Deep link (openhuman://oauth/success)
  Deep->>Manager: notifyOAuthComplete(oauthParams)
  Deep->>Manager: best-effort startSkill(skillId)
  Manager->>Engine: engine.start_skill(skillId)
  Engine-->>Manager: start result (success / error)
  Manager->>Manager: emitSkillStateChange(skillId)  rgba(60,120,180,0.5)
  Manager-->>UI: persist/emit setup_complete state
  UI->>User: Show "Connected — You can close this window."
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 I hopped through OAuth, tidy and bright,
I start, I wait, I don't take flight,
When runtimes nap I stitch a snap,
Workspace set, no stray callback,
One advance, one cheer — carrot delight! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix/skill start issue' is vague and generic, using non-descriptive terms that don't convey meaningful information about the specific changes made to the codebase. Replace with a more specific, descriptive title that captures the main change, such as 'Add waitForSkillRunning polling and fix OAuth/setup control flow' or 'Improve skill startup reliability with polling and simplified async sequences'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown
Contributor

@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: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/components/skills/SkillSetupWizard.tsx`:
- Around line 191-212: Currently the UI sets phase "complete" before running
async setup; instead, keep the wizard non-terminal until
skillManager.startSetup(skillId) resolves: start or fire-and-forget
startSkill(skillId) if you need it concurrently, but await
skillManager.startSetup(skillId) and then if it returns null call setState({
phase: "complete", message: ... }), otherwise call setState({ phase: "step",
step: firstStep }); on any exception from skillManager.startSetup catch it,
console.warn it and call setState({ phase: "error", message: "Setup failed" })
so the wizard doesn't show success when setup failed (refer to startSkill,
skillManager.startSetup, setState and the "complete"/"step"/"error" phase
values).

In `@app/src/lib/skills/hooks.ts`:
- Around line 22-33: The offlineSkillSnapshot helper currently hard-codes
setup_complete:false and resets previous snapshot data; change it to a const
arrow that preserves the last known snapshot values (at minimum carry forward
setup_complete and any non-empty name/tools/state/connection fields) when
available instead of overwriting them, e.g. accept an optional previousSnapshot
parameter or read the cached snapshot used by useSkillSnapshot and merge fields
into the offline fallback; update the declaration to a const arrow named
offlineSkillSnapshot and apply the same preservation/arrow-fn change to the
other occurrence mentioned (lines ~95-100) so transient RPC failures don't flip
the UI.

In `@app/test/e2e/specs/skill-execution-flow.spec.ts`:
- Around line 116-128: The test "skills_set_setup_complete + skills_status
without start (OAuth persistence path)" sets setup_complete to true for the
shared E2E_RUNTIME_SKILL_ID and never clears it; wrap the
callOpenhumanRpc('openhuman.skills_set_setup_complete', { skill_id:
E2E_RUNTIME_SKILL_ID, complete: true }) and subsequent assertions in a
try/finally and in the finally call
callOpenhumanRpc('openhuman.skills_set_setup_complete', { skill_id:
E2E_RUNTIME_SKILL_ID, complete: false }) to restore state; use the same
callOpenhumanRpc helper and E2E_RUNTIME_SKILL_ID constant so the test is
isolated and does not leak setup_complete across specs.

In `@tests/json_rpc_e2e.rs`:
- Around line 1549-1551: The test currently defines a JS helper function
onOAuthComplete and asserts its return value, but the production oauth/complete
runtime handler injects the credential, calls start(), and returns its own
payload without invoking onOAuthComplete; remove the test-only onOAuthComplete
helper and its { ok: true } assertion, and instead call the real oauth/complete
handler (the same pathway that injects the credential and calls start()) and
assert the actual handler response; update the duplicated cases (also around the
1839-1901 range) to validate the real handler result rather than the non-invoked
onOAuthComplete hook.
🪄 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: 16d4c9ed-80ee-4906-a5d0-902d96ecff42

📥 Commits

Reviewing files that changed from the base of the PR and between b8ded44 and c006557.

📒 Files selected for processing (8)
  • app/src/components/skills/SkillSetupWizard.tsx
  • app/src/lib/skills/hooks.ts
  • app/src/lib/skills/manager.ts
  • app/src/utils/desktopDeepLinkListener.ts
  • app/test/e2e/specs/skill-execution-flow.spec.ts
  • app/test/e2e/specs/skill-oauth.spec.ts
  • src/openhuman/skills/schemas.rs
  • tests/json_rpc_e2e.rs
💤 Files with no reviewable changes (1)
  • app/src/lib/skills/manager.ts

Comment thread app/src/components/skills/SkillSetupWizard.tsx Outdated
Comment thread app/src/lib/skills/hooks.ts Outdated
Comment thread app/test/e2e/specs/skill-execution-flow.spec.ts
Comment thread tests/json_rpc_e2e.rs Outdated
- SkillSetupWizard: only show complete after startSetup succeeds; error on failures
- hooks: merge prior snapshot into offline fallback; use const arrow for helper
- E2E: reset skills_set_setup_complete in finally for isolation
- json_rpc_e2e: assert oauth/complete returns start() result; add minimal start()
- Skills page tests: mock screen-intelligence/autocomplete/voice hooks (CoreStateProvider)

Made-with: Cursor
Copy link
Copy Markdown
Contributor

@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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/src/components/skills/SkillSetupWizard.tsx (1)

69-88: ⚠️ Potential issue | 🟠 Major

Wait for the skill to be ready before calling startSetup().

startSkill() does not guarantee the runtime is already setup-ready here. The repo’s own E2E coverage treats openhuman.skills_start as asynchronous and allows "initializing" before later interactions, so both of these new startSkill(skillId) -> startSetup(skillId) sequences can still race and show a false setup error right after auth/OAuth on slower machines. Gate startSetup() on a confirmed running snapshot/status, or centralize this in a helper that waits until startup finishes.

🛠️ Suggested direction
+async function waitForSkillRunning(skillId: string): Promise<void> {
+  const deadline = Date.now() + 10_000;
+  while (Date.now() < deadline) {
+    const snapshot = await getSkillSnapshot(skillId);
+    if (snapshot.status === "running") return;
+    if (snapshot.status === "error") {
+      throw new Error(snapshot.error ?? "Skill failed to start");
+    }
+    await new Promise(resolve => setTimeout(resolve, 250));
+  }
+  throw new Error("Timed out waiting for skill to start");
+}
+
 const transitionToSetup = useCallback(async () => {
   try {
     await startSkill(skillId);
+    await waitForSkillRunning(skillId);
 
     const firstStep = await skillManager.startSetup(skillId);

Also applies to: 187-214

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

In `@app/src/components/skills/SkillSetupWizard.tsx` around lines 69 - 88,
transitionToSetup can race because startSkill(skillId) may return before the
runtime is ready, causing skillManager.startSetup(skillId) to fail; fix by
gating startSetup on a readiness check: after startSkill(skillId) completes,
poll or call a helper like waitForSkillReady(skillId) (or implement one) that
queries the runtime/status until it reports running/ready (with
timeout/retries), then call skillManager.startSetup(skillId); centralize this
logic into a reusable helper (e.g., waitForSkillReady) and use it in
transitionToSetup (and the other similar block around lines 187-214) so
startSetup is only invoked when the skill is confirmed ready.
🧹 Nitpick comments (1)
app/src/pages/__tests__/Skills.third-party-notion-debug-tools.test.tsx (1)

49-86: Extract the shared skill-status mocks into a test helper.

These three vi.mock(...) blocks are effectively the same ones added in app/src/pages/__tests__/Skills.third-party-gmail-sync.test.tsx. Keeping them duplicated will make these specs drift the next time one of the status-hook return shapes changes. Pulling them behind a shared helper in app/src/test/ would keep both tests aligned from one place.

As per coding guidelines, "use existing helpers from app/src/test/ before adding new harness code."

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

In `@app/src/pages/__tests__/Skills.third-party-notion-debug-tools.test.tsx`
around lines 49 - 86, Extract the three duplicated vi.mock(...) blocks for
useScreenIntelligenceSkillStatus, useAutocompleteSkillStatus, and
useVoiceSkillStatus into a single shared test helper (e.g.,
registerDefaultSkillStatusMocks) under the test helpers and export it; replace
the three vi.mock blocks in this test with a single import-and-call of that
helper and update the other spec that had the same mocks to import the same
helper so both tests use the centralized mock implementations.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/json_rpc_e2e.rs`:
- Around line 1872-1880: Replace the fixed
tokio::time::sleep(Duration::from_millis(400)).await with a readiness poll that
repeatedly calls post_json_rpc for "openhuman.skills_status" (similar to how
"skills_start" was invoked) and uses assert_no_jsonrpc_error to check the
response; parse the returned JSON status field and loop until status ==
"running" or a reasonable timeout is reached (failing the test on timeout). Keep
using the existing helpers post_json_rpc and assert_no_jsonrpc_error and ensure
the poll breaks as soon as "running" is observed to avoid flakiness.

---

Outside diff comments:
In `@app/src/components/skills/SkillSetupWizard.tsx`:
- Around line 69-88: transitionToSetup can race because startSkill(skillId) may
return before the runtime is ready, causing skillManager.startSetup(skillId) to
fail; fix by gating startSetup on a readiness check: after startSkill(skillId)
completes, poll or call a helper like waitForSkillReady(skillId) (or implement
one) that queries the runtime/status until it reports running/ready (with
timeout/retries), then call skillManager.startSetup(skillId); centralize this
logic into a reusable helper (e.g., waitForSkillReady) and use it in
transitionToSetup (and the other similar block around lines 187-214) so
startSetup is only invoked when the skill is confirmed ready.

---

Nitpick comments:
In `@app/src/pages/__tests__/Skills.third-party-notion-debug-tools.test.tsx`:
- Around line 49-86: Extract the three duplicated vi.mock(...) blocks for
useScreenIntelligenceSkillStatus, useAutocompleteSkillStatus, and
useVoiceSkillStatus into a single shared test helper (e.g.,
registerDefaultSkillStatusMocks) under the test helpers and export it; replace
the three vi.mock blocks in this test with a single import-and-call of that
helper and update the other spec that had the same mocks to import the same
helper so both tests use the centralized mock implementations.
🪄 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: a0d54b26-3094-4bad-94ad-02d07b28e112

📥 Commits

Reviewing files that changed from the base of the PR and between c006557 and 3f4bf37.

📒 Files selected for processing (6)
  • app/src/components/skills/SkillSetupWizard.tsx
  • app/src/lib/skills/hooks.ts
  • app/src/pages/__tests__/Skills.third-party-gmail-sync.test.tsx
  • app/src/pages/__tests__/Skills.third-party-notion-debug-tools.test.tsx
  • app/test/e2e/specs/skill-execution-flow.spec.ts
  • tests/json_rpc_e2e.rs
✅ Files skipped from review due to trivial changes (1)
  • app/test/e2e/specs/skill-execution-flow.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/lib/skills/hooks.ts

Comment thread tests/json_rpc_e2e.rs Outdated
- SkillSetupWizard: waitForSkillRunning after startSkill before startSetup/auth RPC
- json_rpc_e2e: poll skills_status until running instead of fixed 400ms sleep
- Consolidate Skills page vi.mocks in test/mockDefaultSkillStatusHooks.ts

Made-with: Cursor
Copy link
Copy Markdown
Contributor

@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: 1

🧹 Nitpick comments (2)
app/src/test/mockDefaultSkillStatusHooks.ts (1)

8-17: Optional: Extract a shared offline-status base object

The repeated status literals are consistent now, but centralizing them would reduce drift and simplify future updates.

♻️ Optional refactor
 import { vi } from 'vitest';
 
+const defaultOfflineStatus = {
+  connectionStatus: 'offline',
+  statusDot: 'bg-stone-400',
+  statusLabel: 'Offline',
+  statusColor: 'text-stone-500',
+  ctaLabel: 'Enable',
+  ctaVariant: 'sage',
+};
+
 vi.mock('../features/screen-intelligence/useScreenIntelligenceSkillStatus', () => ({
   useScreenIntelligenceSkillStatus: () => ({
-    connectionStatus: 'offline',
-    statusDot: 'bg-stone-400',
-    statusLabel: 'Offline',
-    statusColor: 'text-stone-500',
-    ctaLabel: 'Enable',
-    ctaVariant: 'sage',
+    ...defaultOfflineStatus,
     allPermissionsGranted: false,
     platformUnsupported: false,
   }),
 }));
 
 vi.mock('../features/autocomplete/useAutocompleteSkillStatus', () => ({
   useAutocompleteSkillStatus: () => ({
-    connectionStatus: 'offline',
-    statusDot: 'bg-stone-400',
-    statusLabel: 'Offline',
-    statusColor: 'text-stone-500',
-    ctaLabel: 'Enable',
-    ctaVariant: 'sage',
+    ...defaultOfflineStatus,
     platformUnsupported: false,
   }),
 }));
 
 vi.mock('../features/voice/useVoiceSkillStatus', () => ({
   useVoiceSkillStatus: () => ({
-    connectionStatus: 'offline',
-    statusDot: 'bg-stone-400',
-    statusLabel: 'Offline',
-    statusColor: 'text-stone-500',
-    ctaLabel: 'Enable',
-    ctaVariant: 'sage',
+    ...defaultOfflineStatus,
     sttModelMissing: false,
     voiceStatus: null,
     serverStatus: null,
   }),
 }));

Also applies to: 21-29, 33-43

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

In `@app/src/test/mockDefaultSkillStatusHooks.ts` around lines 8 - 17, Extract a
shared constant object (e.g., offlineStatusBase) containing the repeated offline
literals (connectionStatus, statusDot, statusLabel, statusColor, ctaLabel,
ctaVariant, allPermissionsGranted, platformUnsupported) and replace the inline
literal in useScreenIntelligenceSkillStatus with a shallow clone/merge of that
constant; do the same for the other hook factories that use the same values (the
other occurrences referenced around the same file), so each hook returns {
...offlineStatusBase, <hook-specific overrides if any> } to centralize and avoid
drift.
app/src/components/skills/SkillSetupWizard.tsx (1)

31-44: Prefer a const arrow for waitForSkillRunning.

This new helper is module-level production code, so it should follow the repo’s TS style instead of introducing another function declaration.

♻️ Suggested refactor
-async function waitForSkillRunning(skillId: string): Promise<void> {
+const waitForSkillRunning = async (skillId: string): Promise<void> => {
   const deadline = Date.now() + SKILL_RUNNING_WAIT_MS;
   while (Date.now() < deadline) {
     const snapshot = await getSkillSnapshot(skillId);
     if (snapshot.status === "running") return;
     if (snapshot.status === "error") {
       throw new Error(snapshot.error ? String(snapshot.error) : "Skill failed to start");
     }
     await new Promise<void>(resolve => {
       setTimeout(resolve, SKILL_RUNNING_POLL_MS);
     });
   }
   throw new Error("Timed out waiting for skill to start");
-}
+};

As per coding guidelines, **/*.{js,jsx,ts,tsx}: “Use const by default, let if reassignment is needed, avoid var” and “Prefer arrow functions over function declarations.”

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

In `@app/src/components/skills/SkillSetupWizard.tsx` around lines 31 - 44, The
function declaration waitForSkillRunning should be converted to a module-level
const arrow per project TS style: replace the `async function
waitForSkillRunning(skillId: string): Promise<void> { ... }` declaration with a
`const waitForSkillRunning = async (skillId: string): Promise<void> => { ... }`
arrow so the behavior remains identical but follows the "use const" and "prefer
arrow functions" rules; ensure any consumers still reference the same identifier
and that no hoisting-dependent code relies on the old declaration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/src/components/skills/SkillSetupWizard.tsx`:
- Around line 244-250: Do not move the wizard to the "complete" state until
persistence succeeds: call setSetupComplete(skillId, true) and wait for it to
resolve (or handle its rejection) before calling setState({ phase: "complete",
message: "Successfully connected! You can close this window." }); if
setSetupComplete fails, surface an error state/message instead of swallowing the
error (remove the empty .catch(() => {}) and either await the promise or chain
.then/.catch to only set the success state on success and set an error
phase/message on failure).

---

Nitpick comments:
In `@app/src/components/skills/SkillSetupWizard.tsx`:
- Around line 31-44: The function declaration waitForSkillRunning should be
converted to a module-level const arrow per project TS style: replace the `async
function waitForSkillRunning(skillId: string): Promise<void> { ... }`
declaration with a `const waitForSkillRunning = async (skillId: string):
Promise<void> => { ... }` arrow so the behavior remains identical but follows
the "use const" and "prefer arrow functions" rules; ensure any consumers still
reference the same identifier and that no hoisting-dependent code relies on the
old declaration.

In `@app/src/test/mockDefaultSkillStatusHooks.ts`:
- Around line 8-17: Extract a shared constant object (e.g., offlineStatusBase)
containing the repeated offline literals (connectionStatus, statusDot,
statusLabel, statusColor, ctaLabel, ctaVariant, allPermissionsGranted,
platformUnsupported) and replace the inline literal in
useScreenIntelligenceSkillStatus with a shallow clone/merge of that constant; do
the same for the other hook factories that use the same values (the other
occurrences referenced around the same file), so each hook returns {
...offlineStatusBase, <hook-specific overrides if any> } to centralize and avoid
drift.
🪄 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: 3f7d557a-3956-4d94-bc3c-a61fb8e9055f

📥 Commits

Reviewing files that changed from the base of the PR and between 3f4bf37 and 55a7eaa.

📒 Files selected for processing (5)
  • app/src/components/skills/SkillSetupWizard.tsx
  • app/src/pages/__tests__/Skills.third-party-gmail-sync.test.tsx
  • app/src/pages/__tests__/Skills.third-party-notion-debug-tools.test.tsx
  • app/src/test/mockDefaultSkillStatusHooks.ts
  • tests/json_rpc_e2e.rs
✅ Files skipped from review due to trivial changes (1)
  • app/src/pages/tests/Skills.third-party-notion-debug-tools.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/pages/tests/Skills.third-party-gmail-sync.test.tsx

Comment thread app/src/components/skills/SkillSetupWizard.tsx Outdated
…SkillRunning, mock base

- Legacy OAuth: await persistence before complete; error on failure; guard ref + reset on skillId
- waitForSkillRunning: const arrow per TS style
- mockDefaultSkillStatusHooks: offlineStatusBase spread for shared literals

Made-with: Cursor
@M3gA-Mind M3gA-Mind merged commit 9118bfb into tinyhumansai:main Apr 10, 2026
8 of 9 checks passed
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