Skip to content

Conversation

@Balcan
Copy link
Collaborator

@Balcan Balcan commented Jan 20, 2026

Description

Link the JIRA issue.

Please provide a clear definition of the problem and explain your solution.

@Balcan Balcan changed the title ANDROAPP-7449 task: [ANDROAPP-7449] Add InputCustomIntent to TrackerInputProvider Jan 20, 2026
@xavimolloy xavimolloy requested a review from Copilot January 21, 2026 11:18
Copy link
Contributor

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 pull request adds support for custom intent input fields to the TrackerInputProvider, enabling custom intent functionality in search parameter screens. The implementation follows the existing pattern from the form module and integrates custom intent handling into the tracker-based search flow.

Changes:

  • Implemented InputCustomIntent component in TrackerInputProvider for handling custom intent fields
  • Added new UI event (OnLaunchCustomIntent) and input type (CUSTOM_INTENT) to support custom intents
  • Integrated custom intent launching and result handling in SearchTEIViewModel and SearchParametersScreen

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tracker/src/commonMain/kotlin/org/dhis2/tracker/ui/input/provider/TrackerInputProvider.kt Added CUSTOM_INTENT case with InputCustomIntent component and state management
tracker/src/commonMain/kotlin/org/dhis2/tracker/ui/input/model/TrackerInputUiEvent.kt Added OnLaunchCustomIntent event for triggering custom intent actions
tracker/src/commonMain/kotlin/org/dhis2/tracker/ui/input/model/TrackerInputType.kt Added CUSTOM_INTENT enum value
tracker/src/commonMain/kotlin/org/dhis2/tracker/ui/input/model/TrackerInputModel.kt Added customIntentUid field to support custom intent identification
tracker/src/commonMain/composeResources/values/strings.xml Added "custom_intent_launch" string resource
tracker/src/commonMain/composeResources/values-zh/strings.xml Added Chinese translation for custom intent launch button
tracker/src/commonMain/composeResources/values-cs/strings.xml Added Czech translation for custom intent launch button
form/src/main/java/org/dhis2/form/ui/provider/inputfield/FieldProvider.kt Removed unused resources parameter
form/src/main/java/org/dhis2/form/ui/provider/inputfield/CustomIntentProvider.kt Migrated from ResourceManager to stringResource for compose resources
app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/mapper/ParameterInputModelMapper.kt Updated mapper to handle custom intent fields and map to CUSTOM_INTENT type
app/src/main/java/org/dhis2/usescases/searchTrackEntity/searchparameters/SearchParametersScreen.kt Added custom intent launcher, result handling, and event dispatching
app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchTEIViewModel.kt Added onLaunchCustomIntent and handleCustomIntentResult methods
app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchRepositoryKt.kt Added getCustomIntent interface method
app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchRepositoryImplKt.kt Implemented getCustomIntent method delegating to customIntentRepository
app/src/main/java/org/dhis2/usescases/searchTrackEntity/SearchAction.kt Created new sealed interface for search actions including LaunchCustomIntent

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

Comment on lines 614 to 615
)
}
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The customIntentState is not being updated when the result is received. Unlike the form module's CustomIntentProvider which handles CustomIntentResult callbacks and updates the state accordingly, this implementation only sets the state to LOADING when launching the intent but never updates it back to LAUNCH or LOADED based on success or error.

When the result is processed in SearchTEIViewModel.handleCustomIntentResult, it updates the input value and error but has no way to reset the customIntentState in the TrackerInputProvider. This means the button will remain in a loading state indefinitely even after the custom intent completes.

Consider adding a mechanism to propagate the result state back to the UI component, similar to how the form module tracks isLoadingData in the FieldUiModel and uses it in getCustomIntentState.

Copilot uses AI. Check for mistakes.
Comment on lines +1205 to +1222
fun handleCustomIntentResult(customIntentResult: CustomIntentResult) {
when (customIntentResult) {
is CustomIntentResult.Error -> {
updateSearchParameters(
customIntentResult.fieldUid,
null,
resourceManager.getString(R.string.custom_intent_error),
)
}

is CustomIntentResult.Success -> {
updateSearchParameters(
customIntentResult.fieldUid,
listOf(customIntentResult.value),
)
}
}
}
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The new method handleCustomIntentResult lacks test coverage. Given that SearchTEIViewModel has comprehensive existing test coverage in SearchTEIViewModelTest.kt, this method should have tests to verify both success and error paths, including:

  • Successful custom intent result updates the search parameters with the returned value
  • Error result updates the search parameters with the error message and clears the value

Copilot uses AI. Check for mistakes.
Comment on lines +436 to +443
override suspend fun getCustomIntent(fieldUid: FieldUid) =
withContext(dispatcher.io()) {
customIntentRepository.getCustomIntent(
triggerUid = fieldUid,
orgUnitUid = null,
actionType = CustomIntentActionTypeModel.SEARCH,
)
}
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The new method getCustomIntent lacks test coverage. Given that SearchRepositoryImplKt has existing test coverage in SearchRepositoryTest.kt, this method should be tested to verify it correctly delegates to customIntentRepository.getCustomIntent with the appropriate parameters (triggerUid, orgUnitUid as null, and actionType as SEARCH).

Copilot uses AI. Check for mistakes.
Comment on lines 614 to 615
)
}
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The customIntentState uses remember(inputModel) but this won't recalculate the state when inputModel.value changes, since remember only re-executes when the key instance changes, not when properties change. This means:

  1. When onClear is called and inputModel.onValueChange(null) is invoked, the customIntentState will remain as LOADED instead of reverting to LAUNCH
  2. When a value is successfully loaded after being empty, the state won't automatically update from LAUNCH to LOADED

Compare this to the form module's CustomIntentProvider which uses remember(values, fieldUiModel) and has the values as a separate state that can trigger recomposition.

Consider using derivedStateOf or adding inputModel.value as a remember key: remember(inputModel, inputModel.value).

Copilot uses AI. Check for mistakes.
@xavimolloy xavimolloy force-pushed the feature/tracker-search-refactor branch from 5660492 to e43d1ea Compare January 22, 2026 07:37
@xavimolloy xavimolloy force-pushed the feature/tracker-search-refactor branch from e43d1ea to 3100f7d Compare January 23, 2026 06:37
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
3 New issues
3 New Code Smells (required ≤ 0)
1 New Critical Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

4 participants