fix/ADFA-3613 externalize template strings#1218
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 38 minutes and 13 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR changes template warning handling from plain strings to structured, localized Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant UI as TemplateListFragment
participant Provider as TemplateProviderImpl
participant Reader as ZipTemplateReader
participant Executor as ZipRecipeExecutor
participant Res as AndroidResources
User->>UI: open Template list / reload
UI->>Provider: request templates
Provider->>Reader: read archive (collect TemplateWarning[])
Reader-->>Provider: templates + warnings
Provider->>UI: return templates + warnings
UI->>Res: resolve each TemplateWarning (resId,args) -> localized string
UI-->>User: display templates and localized warnings
alt execute template
UI->>Executor: execute recipe (requires non-null Context)
Executor->>Res: fetch localized messages during processing
Executor->>Reader: read entries / params (passes Context)
Executor-->>UI: report localized info/warn/error messages
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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/main/java/com/itsaky/androidide/fragments/TemplateListFragment.kt`:
- Around line 144-149: The flash message currently shows only the detailed
warning lines and drops the intended summary/prefix (msg_template_warnings) that
includes leading newlines for spacing; update the code around the warnings
handling in TemplateListFragment (where requireActivity().flashError is called)
to prepend the localized summary string
requireContext().getString(R.string.msg_template_warnings) (or similar resource
id msg_template_warnings) to the joined warning details so the final message is
getString(msg_template_warnings) + warnings.joinToString("\n") { ... },
preserving the leading spacing and original banner prefix.
In `@resources/src/main/res/values/strings.xml`:
- Around line 1297-1300: The user-facing string resources use
inconsistent/missing separators ("%1$s %2$s") and extra spaces; update each
template resource (e.g., template_exec_error_evaluate,
template_exec_error_write, template_exec_error_copy,
template_exec_error_process) to use a normalized separator like "%1$s: %2$s"
(single colon and single space) so messages render as "context: details"; apply
the same normalization to the other template_exec_error_* entries mentioned in
the comment.
In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kt`:
- Around line 195-198: In ZipRecipeExecutor replace the write-specific error
resource with the copy-specific one in the catch handling the
input.copyTo(output) path: change the error(...) call that currently uses
R.string.template_exec_error_write to use R.string.template_exec_error_copy
(keep the same parameters like ctx, entry.name and e.toString()) so copy
failures log the correct string resource.
- Around line 52-57: The code currently force-unwraps executor.context with
"executor.context!!"; replace that with an explicit null-check using
requireNotNull(executor.context) { "Context required for template execution" }
and assign it to ctx (val ctx = requireNotNull(executor.context) { ... }) inside
the execute(RecipeExecutor) method so the contract is documented and any missing
context throws a clear error; reference the execute method and the ctx variable
when making this change (calling requireNotNull in place of the existing !!).
In
`@templates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt`:
- Around line 40-43: The code currently adds a TemplateWarning for missing
ARCHIVE_JSON inside the requireNotNull lambda and then lets requireNotNull
throw, causing the outer catch to also add template_read_error_archive_load —
remove the warning from the requireNotNull call and either (A) perform an
explicit null check on zip.getEntry(ARCHIVE_JSON) to add a single
TemplateWarning and return/fail early, or (B) keep requireNotNull so it throws
and let the outer catch add the single template_read_error_archive_load; modify
the code around zip.getEntry(ARCHIVE_JSON), requireNotNull, and warnings so only
one warning is emitted for the missing ARCHIVE_JSON (reference ARCHIVE_JSON,
zip.getEntry, requireNotNull, warnings, TemplateWarning,
template_read_error_archive_json, template_read_error_archive_load).
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 65aa4f6b-f389-4763-b139-a260ddd88f60
📒 Files selected for processing (6)
app/src/main/java/com/itsaky/androidide/fragments/TemplateListFragment.ktresources/src/main/res/values/strings.xmltemplates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateProviderImpl.kttemplates-impl/src/main/java/com/itsaky/androidide/templates/impl/TemplateWarning.kttemplates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipRecipeExecutor.kttemplates-impl/src/main/java/com/itsaky/androidide/templates/impl/zip/ZipTemplateReader.kt
745f216 to
04ff43b
Compare
externalize template string