openclaw - 💡(How to fix) Fix Dead code: 36 platform callback functions in apps/android + apps/macos [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#56210Fetched 2026-04-08 01:43:31
View on GitHub
Comments
1
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
closed ×1commented ×1cross-referenced ×1locked ×1

Code Example

For each function above, read the file and:

1. If it's a platform callback (overrides an OS interface like RecognitionListener,
   NsdManager.DiscoveryListener, NSView, WKScriptMessageHandler):
Add a one-line comment: // Platform callback — called by OS runtime
   
2. If the name starts with setTesting/setTest/_test/setSnapshot:
Grep for references in test files. If unused in tests too, delete it.
   
3. If it's neither:
Grep repo-wide. If nothing references it, delete it.

Run tests after each file. Commit per file.
RAW_BUFFERClick to expand / collapse

Static call graph analysis found 36 isolated functions across apps/android/ and apps/macos/ — zero callers and zero callees in the static call graph.

Nearly all are platform callbacks (Android lifecycle, NSD discovery, macOS NSView delegates, speech recognition). They're called by the OS, not by application code, so they correctly have zero static callers.

Android (18 functions, 8 files)

  • NodeForegroundService.kt: onBind
  • GatewayDiscovery.kt: onStartDiscoveryFailed, onStopDiscoveryFailed, onDiscoveryStarted, onDiscoveryStopped
  • GatewaySession.kt: currentMainSessionKey
  • CanvasController.kt: isDefaultCanvas
  • OpenClawTheme.kt: overlayIconColor
  • MicCaptureManager.kt: onReadyForSpeech, onBeginningOfSpeech, onBufferReceived
  • TalkModeManager.kt: onReadyForSpeech, onBeginningOfSpeech, onBufferReceived
  • VoiceWakeManager.kt: setTriggerWords, onReadyForSpeech, onBeginningOfSpeech, onBufferReceived

macOS (18 functions, 14 files)

  • AgentWorkspace.swift: blocked
  • AppState.swift: setWorking
  • CanvasChromeContainerView.swift: acceptsFirstMouse (2x)
  • DeepLinks.swift: currentCanvasKey
  • GatewayProcessManager.swift: setTestingConnection, setTestingDesiredActive, setTestingLastFailureReason
  • HealthStore.swift: __setSnapshotForTest
  • MenuBar.swift: userDidCancelDownload
  • MenuContextCardInjector.swift: _testSetCache
  • SessionMenuPreviewView.swift: _testReset
  • TailscaleIntegrationSection.swift: setTestingService
  • TalkOverlay.swift: currentWindowOrigin, acceptsFirstMouse
  • TalkOverlayView.swift: acceptsFirstMouse
  • VoiceWakeOverlayTextViews.swift: textDidChange
  • GatewayDiscoveryModel.swift: buildSSHTarget

Suggested action

For each function above, read the file and:

1. If it's a platform callback (overrides an OS interface like RecognitionListener,
   NsdManager.DiscoveryListener, NSView, WKScriptMessageHandler):
   → Add a one-line comment: // Platform callback — called by OS runtime
   
2. If the name starts with setTesting/setTest/_test/setSnapshot:
   → Grep for references in test files. If unused in tests too, delete it.
   
3. If it's neither:
   → Grep repo-wide. If nothing references it, delete it.

Run tests after each file. Commit per file.

Analysis: cqs v1.9.0 tree-sitter call graph extraction.

extent analysis

Fix Plan

To address the issue of isolated functions, follow these steps for each function:

  • For platform callbacks:
    • Add a comment: // Platform callback — called by OS runtime
  • For functions with names starting with setTesting, setTest, _test, or setSnapshot:
    • Search for references in test files
    • If unused, delete the function
  • For other functions:
    • Search for references across the repository
    • If unreferenced, delete the function

Example Code Changes

Platform Callback Example (Android)

// NodeForegroundService.kt
class NodeForegroundService : Service() {
    override fun onBind(intent: Intent): IBinder? {
        // Platform callback — called by OS runtime
        return null
    }
}

Platform Callback Example (macOS)

// AgentWorkspace.swift
class AgentWorkspace: NSObject {
    func blocked() {
        // Platform callback — called by OS runtime
    }
}

Deleting Unused Test Functions

// GatewayProcessManager.swift (before)
class GatewayProcessManager {
    func setTestingConnection() {
        // ...
    }
}

// GatewayProcessManager.swift (after)
class GatewayProcessManager {
    // Removed setTestingConnection() if unused in tests
}

Verification

After making changes to each file, run tests to ensure the application still functions as expected. Commit changes per file to track modifications and facilitate easier rollbacks if needed.

Extra Tips

  • Regularly review and update the codebase to prevent similar issues from arising.
  • Consider integrating static analysis tools into the CI/CD pipeline to catch isolated functions and other code quality issues early.
  • When deleting functions, ensure to also remove any related comments or documentation to keep the codebase clean and up-to-date.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING