From 2704fd6d5395ab391da7abada1b104784a1fe269 Mon Sep 17 00:00:00 2001 From: Tom Friederich Date: Fri, 18 Sep 2026 13:53:21 +0200 Subject: [PATCH 1/4] ADD guideline for viewstateString usage feature/consistent-viewstatestring-usage --- .../nl/q42/template/core/ui/presentation/ViewStateString.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/presentation/ViewStateString.kt b/core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/presentation/ViewStateString.kt index 08361257..af4ef618 100644 --- a/core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/presentation/ViewStateString.kt +++ b/core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/presentation/ViewStateString.kt @@ -10,6 +10,9 @@ import org.jetbrains.compose.resources.StringResource * * There is one edge case: the formatArgs are not refreshed on config changes, so if you use a string with a * replacement parameter that is f.e. a localized date string, move your logic to the view instead of using [ViewStateString]. + * + * Guideline: Only use ViewStateString when needed. Keep UI components 'Blissfully unaware' of the string source: just pass resolved strings to them. + * (If you can use `stringResource` because you are in a composable context, you probably don't need [ViewStateString]). */ sealed class ViewStateString { data class Res( From e67c9f77e747e50bca85e788e37d98d89622c58b Mon Sep 17 00:00:00 2001 From: Tom Friederich Date: Fri, 18 Sep 2026 13:55:28 +0200 Subject: [PATCH 2/4] ADD directive for viewstateString usage to Agents.MD feature/consistent-viewstatestring-usage --- AGENTS.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.MD b/AGENTS.MD index a846b304..889dd7f9 100644 --- a/AGENTS.MD +++ b/AGENTS.MD @@ -58,7 +58,7 @@ See SKILL.md files in the [skills folders](.copilot/skills/) for available agent - `ApiResult` / `ActionResult` for error handling - Type-safe navigation: `Destination` sealed class with injected `Navigator` for ViewModel-initiated navigation. - Koin DI: `viewModelOf()`, `factoryOf()`, `singleOf()`, feature modules -- `ViewStateString` for string logic in ViewModel +- `ViewStateString` for string logic in ViewModel. Only use `ViewStateString` when needed. - `Res` object for shared resources (Compose Multiplatform Resources) ## Tech Stack From 72d444e2ccd2d6ebc927348f3167874017bbc7bf Mon Sep 17 00:00:00 2001 From: Tom Friederich Date: Fri, 18 Sep 2026 14:17:08 +0200 Subject: [PATCH 3/4] CHANGE clarify that a viewStateString in a viewstate as param is OK feature/consistent-viewstatestring-usage --- .../nl/q42/template/core/ui/presentation/ViewStateString.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/presentation/ViewStateString.kt b/core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/presentation/ViewStateString.kt index af4ef618..34b664a4 100644 --- a/core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/presentation/ViewStateString.kt +++ b/core/ui/src/commonMain/kotlin/nl/q42/template/core/ui/presentation/ViewStateString.kt @@ -11,8 +11,9 @@ import org.jetbrains.compose.resources.StringResource * There is one edge case: the formatArgs are not refreshed on config changes, so if you use a string with a * replacement parameter that is f.e. a localized date string, move your logic to the view instead of using [ViewStateString]. * - * Guideline: Only use ViewStateString when needed. Keep UI components 'Blissfully unaware' of the string source: just pass resolved strings to them. - * (If you can use `stringResource` because you are in a composable context, you probably don't need [ViewStateString]). + * Guideline: Only use ViewStateString when needed. UI components should either receive strings directly, or a ViewState, + * (but that ViewState that may still may contain a ViewStateString if needed). + * (If you can simply use the native `stringResource` because you are in a composable context, you probably don't need [ViewStateString]). */ sealed class ViewStateString { data class Res( From 31bbd17983cf23ebf5a210809e1c6d28fc8fd56f Mon Sep 17 00:00:00 2001 From: Tom Friederich Date: Fri, 18 Sep 2026 14:20:48 +0200 Subject: [PATCH 4/4] CHANGE refer agents.md to the dev guideline feature/consistent-viewstatestring-usage --- AGENTS.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.MD b/AGENTS.MD index 889dd7f9..ee8c8da4 100644 --- a/AGENTS.MD +++ b/AGENTS.MD @@ -58,7 +58,7 @@ See SKILL.md files in the [skills folders](.copilot/skills/) for available agent - `ApiResult` / `ActionResult` for error handling - Type-safe navigation: `Destination` sealed class with injected `Navigator` for ViewModel-initiated navigation. - Koin DI: `viewModelOf()`, `factoryOf()`, `singleOf()`, feature modules -- `ViewStateString` for string logic in ViewModel. Only use `ViewStateString` when needed. +- `ViewStateString` for string logic in ViewModel. See guideline in the `ViewStateString` class for usage. - `Res` object for shared resources (Compose Multiplatform Resources) ## Tech Stack