Skip to content

fix: resolve NPE in CliConnectDialog due to constructor-time access of subclass state#16

Merged
DimazzzZ merged 2 commits into
mainfrom
fix/cli-connect-dialog-init-npe
Jul 8, 2026
Merged

fix: resolve NPE in CliConnectDialog due to constructor-time access of subclass state#16
DimazzzZ merged 2 commits into
mainfrom
fix/cli-connect-dialog-init-npe

Conversation

@DimazzzZ

@DimazzzZ DimazzzZ commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Root cause

The abstract class CliConnectDialog declared open/abstract properties (headerHtml, descriptionHtml, requirementsHtml) that were read during base-class init{}, before subclass field initializers had completed. In Kotlin/JVM this allows overridden non-null vals to be observed as null at construction time, causing a NullPointerException in RowImpl.label(text).

Fix

  1. CliConnectDialog.kt -- replaced abstract value properties with a constructor-parameter CliDialogSpec, eliminating constructor-time polymorphic access. Moved CLI detection start out of base init{} into a protected startDetection() method.
  2. CodexConnectDialog.kt -- now passes its static config via super(CliDialogSpec(...)) and calls startDetection() from its own init{}.
  3. ClaudeConnectDialog.kt -- same pattern.

Validation

  • ./gradlew compileKotlin -- BUILD SUCCESSFUL
  • ./gradlew test -- BUILD SUCCESSFUL (all tests pass)

…f subclass state

The abstract class CliConnectDialog declared open properties (headerHtml,
descriptionHtml, requirementsHtml) that were read during base-class init{},
before subclass field initializers had completed. In Kotlin/JVM this allows
overridden non-null vals to be observed as null at construction time,
causing a NullPointerException in RowImpl.label(text).

Fix:
- Replace abstract value properties with a constructor-parameter CliDialogSpec,
  eliminating constructor-time polymorphic access.
- Move CLI detection start out of base init{} into a protected startDetection()
  method, called from each subclass init{} after base construction finishes.

Affected dialogs (both updated accordingly):
  - CodexConnectDialog
  - ClaudeConnectDialog
@DimazzzZ DimazzzZ self-assigned this Jul 8, 2026
Comment thread src/main/kotlin/org/zhavoronkov/tokenpulse/ui/CliConnectDialog.kt Fixed
Comment thread src/main/kotlin/org/zhavoronkov/tokenpulse/ui/CliConnectDialog.kt Fixed
Comment thread src/main/kotlin/org/zhavoronkov/tokenpulse/ui/CliConnectDialog.kt Fixed
Comment thread src/main/kotlin/org/zhavoronkov/tokenpulse/ui/CliConnectDialog.kt Fixed
…ngth violations

Extracted long inline HTML strings in detectCli() into private helper methods (detectingStatusHtml, notFoundStatusHtml, detectedStatusHtml, errorMessageHtml, versionHtml). This eliminates the detekt line-length warnings reported on PR #16 while keeping the constructor-safety fix intact.
@DimazzzZ DimazzzZ merged commit 072b1b7 into main Jul 8, 2026
2 checks passed
@DimazzzZ DimazzzZ deleted the fix/cli-connect-dialog-init-npe branch July 8, 2026 15:59
@DimazzzZ DimazzzZ restored the fix/cli-connect-dialog-init-npe branch July 8, 2026 16:14
@DimazzzZ DimazzzZ deleted the fix/cli-connect-dialog-init-npe branch July 8, 2026 16:59
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