Skip to content

Setup-tab BuildConfig wiring + .env policy + build-stamp logging#1

Merged
RomanLeshc merged 5 commits into
mainfrom
tf/setup-integration-and-ux-fixes
May 8, 2026
Merged

Setup-tab BuildConfig wiring + .env policy + build-stamp logging#1
RomanLeshc merged 5 commits into
mainfrom
tf/setup-integration-and-ux-fixes

Conversation

@phwizard
Copy link
Copy Markdown
Member

@phwizard phwizard commented May 8, 2026

Summary

Five commits cherry-picked from a local tf-dev branch, focused on two themes:

  1. Make @ethora/setup's output actually reach the running sample. The Setup tab currently hardcodes baseUrl = \"https://api.chat.ethora.com/v1\", appId = \"646cc8dc...\", email = \"colod20205@exweme.com\", password = \"12345678\" as defaults — so after running @ethora/setup against a developer's profile, the sample still shows dev-team credentials and the BASE app ID, ignoring the .env setup wrote.
  2. Stop committing real endpoints / credentials. .env (which @ethora/setup writes) was not in .gitignore, and the hardcoded defaults above are policy violations against the new "no Ethora default endpoints, no customer endpoints in SDK/sample source" rule.

Commits

Commit What it does
1 wire all Setup-tab defaults to BuildConfig Replaces every hardcoded PlaygroundSessionState default in MainActivity.kt with BuildConfig.ETHORA_* reads, plus matching buildConfigField entries in app/build.gradle.kts for the new keys (ETHORA_APP_TOKEN, ETHORA_USER_EMAIL, ETHORA_USER_PASSWORD). Adds windowSoftInputMode=\"adjustResize\" to AndroidManifest.xml to fix the Setup-tab keyboard-overlap scroll bug.
2 schema-version the persisted Setup-tab state Stamps CURRENT_SCHEMA_VERSION next to the saved JSON. After in-place reinstall with a new BuildConfig default set, old saved JSON falls through to the fresh defaults instead of permanently masking them. Without this, devs have to adb shell pm clear com.ethora after every @ethora/setup run.
3 stamp git SHA + branch + build time into logs New SAMPLE_GIT_SHA / SAMPLE_GIT_BRANCH / SAMPLE_BUILD_TIME buildConfigField constants. MainActivity logs them as the first line on launch — pasted logs and bug reports now self-identify the exact build. CI without git history falls through to \"unknown\".
4 compute build stamp via 'git log', not java.* packages Follow-up to #3: java.time.* doesn't always resolve in Gradle's Kotlin DSL classpath (Gradle 8.9 + JBR 17 — the java plugin extension shadows the java.* package namespace). Replaced with git log -1 --format=%cd + ProcessBuilder (the same pattern already used for SHA / branch). The timestamp is now the commit's own author date, so the same build always stamps the same string.
5 gitignore .env + add .env.example placeholder Adds .env, .env.local, .env.*.local, and google-services.json to .gitignore. Ships a .env.example with placeholder values + per-key comments so developers not using @ethora/setup know what to populate.

Why this matters now

After @ethora/setup writes a fresh profile's .env, the dev expects the sample to launch with that profile pre-filled. Today on main, the Setup tab still shows dev-team credentials regardless — the .env is partially read (XMPP / JWT / ROOM_JID) but the rest is shadowed by hardcoded literals. Commits 1+2 close that gap.

This PR is paired with two @ethora/setup PRs (forthcoming):

  • fix(presets): drop :5443 from XMPP WebSocket / BOSH URLs — the legacy port no longer accepts WebSocket connections post-chat.ethora.com migration; setup currently writes URLs that hang for 30s at TCP-connect.
  • fix(android): write ETHORA_APP_TOKEN/USER_EMAIL/USER_PASSWORD to .env — extends setup's patchSampleApp() to write the additional env keys this PR adds support for.

Without the setup-side changes, the new BuildConfig keys land empty, which is harmless (the Setup-tab fields just open blank). With the setup-side changes, a fresh setup → run flow opens a Setup tab fully pre-filled with the developer's profile.

What I deliberately did NOT include

Several commits from the same tf-dev branch are obsolete or need rework against main's current architecture:

  • LogsTab Copy-all + selectionmain refactored LogsTab to delegate to the SDK's LogsView component. If selection/copy is still missing in the user-facing experience, that's an SDK-side enhancement to com.ethora.chat.ui.components.LogsView.
  • ConnectionStatusBanner diagnostic — entangled with main's new EthoraChatProvider wrapper. Worth re-thinking as a toggleable dev-mode connection indicator inside the SDK rather than a sample-only patch.
  • Inline ConnectBar + keep-alive tab dispatch (and the paired zIndex hit-testing fix) — major restructuring conflict with main's EthoraChatProvider layout. Some of the underlying issues (long-JWT scroll-clipping, two-clients-racing log pattern) may have been addressed differently — needs re-evaluation.
  • Optional composite-build (includeBuild with sibling auto-detect)main already has a simpler includeBuild (commented out) with note "Disabled while we're testing the JitPack-published v1.0.33 artifact end-to-end." Re-enabling this with auto-detect would override that decision. Worth picking up after v1.0.33 testing settles.
  • AGP 8.5.2 → 8.6.1main is already on AGP 8.7.0 + Kotlin 2.3.0.

Test plan

  • ./gradlew :app:assembleDebug succeeds (verify build-stamp constants populate)
  • Run @ethora/setup against a test profile, confirm .env is written and gitignored
  • Launch the sample on a fresh install — Setup tab opens pre-filled with profile values from .env
  • In-place reinstall with a new .env — old saved JSON does not mask new defaults
  • First log line on launch shows sample-chat-app build=<sha> @<timestamp>UTC branch=<branch>
  • Soft keyboard lifts content instead of obscuring focused field on the Setup tab

phwizard added 5 commits May 8, 2026 14:18
[tf-dev branch: Taras's local testing work; do not merge without review]

When the Setup tab is opened, the form defaults to:
- baseUrl = prod (api.chat.ethora.com/v1)
- xmppHost / xmppConference = prod
- appId = 646cc8dc...f2d (the BASE app, not the developer's own app)
- email = colod20205@exweme.com / password = 12345678 (dev-team literal)
- authMode = email/password

Result: after running @ethora/setup against Cloud QA, the sample
ignores the .env that setup wrote and tries to log into prod with
leftover dev-team credentials — Connect returns 401. Only jwtToken
and singleRoomJid were already wired to BuildConfig, so the other
fields dangle.

Changes:

app/build.gradle.kts — add three buildConfigField entries so the
envOrDefault() pipeline can inject them from .env: ETHORA_APP_TOKEN,
ETHORA_USER_EMAIL, ETHORA_USER_PASSWORD. Existing env consumer in
@ethora/setup is being updated in the same-named branch on that
repo to write them.

MainActivity.kt (PlaygroundSessionState) — replace every hard-coded
default string with the corresponding BuildConfig.* constant.
authMode defaults to JWT_CUSTOM when ETHORA_USER_JWT is non-empty,
so a 'setup + run' flow lands on a connectable session without
manual field edits.

AndroidManifest.xml — add android:windowSoftInputMode="adjustResize"
on MainActivity. Likely cause of the reported scroll issue: without
it, the soft keyboard overlaps form fields instead of resizing the
window, so fields under the keyboard become unreachable.
[tf-dev branch]

Problem: PlaygroundSessionState.load() blindly re-applies any previously
saved JSON, so a build that introduces new BuildConfig-backed defaults
(like the ETHORA_APP_TOKEN / ETHORA_USER_EMAIL / ETHORA_USER_PASSWORD
additions in tf-dev) keeps showing the old saved values after an
in-place reinstall. Developers have to 'adb shell pm clear com.ethora'
for the new defaults to take effect — easy to miss and confusing.

Fix: stamp a CURRENT_SCHEMA_VERSION alongside the JSON. On load(),
only restore the saved JSON when the persisted schema matches; any
earlier schema falls through to the fresh BuildConfig defaults.
save() writes both keys atomically, so the first save after a fresh
default path seeds the new schema. Developer edits are still preserved
across restarts within the same schema.

Bump CURRENT_SCHEMA_VERSION whenever PlaygroundSessionState's default
set or semantics changes.
Inject SAMPLE_GIT_SHA, SAMPLE_GIT_BRANCH, and SAMPLE_BUILD_TIME (YY.MM.DD.HH:mm UTC)
as buildConfigField constants. MainActivity logs them as the first line on launch:

    sample-chat-app build=<short sha> @<timestamp>UTC branch=tf-dev

Pasted logs and bug reports now self-identify the exact build they came from.
The buildConfigField reads via ProcessBuilder('git rev-parse'); CI builds
without git history fall through to 'unknown' without failing.

Note: the timestamp here uses java.time.* which is known to fail in some
Gradle DSL classpath setups (Gradle 8.9 + JBR 17). The follow-up commit
'fix(gradle): compute build stamp via git log' replaces this with a
git-log + ProcessBuilder approach that pins to the commit's own author
date and works on every classpath we've tested.
[tf-dev branch]

Prior attempts with java.time.* and java.text.SimpleDateFormat both
failed with 'Unresolved reference: text / util / time' in the
Kotlin DSL compilation pass. Root cause is Gradle's built-in 'java'
plugin extension — when applied transitively via the Android plugin,
the DSL script's top-level scope has a property named 'java' that
shadows the java.* package namespace, so 'java.text.SimpleDateFormat'
is parsed as '<java extension>.text' and fails to resolve.

Workarounds all required either top-of-file imports (which interact
awkwardly with the 'plugins {}' block position) or fully-qualified
\`_root_ide_package_\` paths.

Simpler + more useful: read the commit's own author date via
'git log -1 --format=%cd --date=format-local:%y.%m.%d.%H:%M' with
TZ=UTC in the child process env. This reuses the ProcessBuilder
pattern that already works for SAMPLE_GIT_SHA and SAMPLE_GIT_BRANCH,
and the timestamp now pins to the commit rather than to wall-clock
rebuild time — same build always stamps the same string.

Verified locally: commit 889583d stamps as 26.04.23.12:13.
Real .env files written by @ethora/setup contain endpoint URLs, app IDs,
tokens, and test-user credentials — those must never be committed.

Adds .env / .env.local / .env.*.local + google-services.json patterns
to .gitignore and ships a placeholder .env.example so developers know
which keys to populate manually if they're not using @ethora/setup.

Implements the 'no Ethora default endpoints, no customer endpoints in
SDK/sample source' policy.
@phwizard phwizard requested a review from RomanLeshc May 8, 2026 13:54
@RomanLeshc RomanLeshc merged commit cb540c3 into main May 8, 2026
RomanLeshc added a commit that referenced this pull request May 11, 2026
Re-pin compileSdk/targetSdk to 35 (regressed after PR #1 merge)
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