Skip to content

Fce 2879/fix docs#485

Open
Magmusacy wants to merge 3 commits intomainfrom
FCE-2879/fix-docs
Open

Fce 2879/fix docs#485
Magmusacy wants to merge 3 commits intomainfrom
FCE-2879/fix-docs

Conversation

@Magmusacy
Copy link
Collaborator

Description

Fix documentation to tell the user where to get env variables from as well as remove env buttons from Room tab when env variable for VIDEOROOM_STAGING_SANDBOX_URL is not present. I also deleted some code that was left over from the times when we didn't use env variables to save in async storage preferred environment.

Motivation and Context

It helps outsiders build fishjam-chat example and cleans the code a little bit

Documentation impact

  • Documentation update required
  • Documentation updated in another PR
  • No documentation update required

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to
    not work as expected)

@linear
Copy link

linear bot commented Mar 3, 2026

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 PR fixes the documentation for the fishjam-chat example app to guide external contributors on how to obtain the required environment variables. It also cleans up leftover code by removing the AsyncStorage-based persistence of environment preferences (now managed purely via env variables), and conditionally hides the staging/prod environment toggle UI when the staging env variable is not set.

Changes:

  • Updated README.md to clarify which env variables are required, how to obtain them, and to distinguish the internal-only staging URL variable.
  • Removed AsyncStorage persistence logic and useFocusEffect from room.tsx, defaulting to "prod" environment and conditionally rendering environment toggle buttons only when EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL is set.
  • Added a console.error warning in _layout.tsx when EXPO_PUBLIC_FISHJAM_ID is not set.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
examples/mobile-client/fishjam-chat/README.md Reorders and clarifies env variable documentation for external developers
examples/mobile-client/fishjam-chat/app/(tabs)/room.tsx Removes AsyncStorage persistence, conditionally shows env toggle, defaults to prod env
examples/mobile-client/fishjam-chat/app/_layout.tsx Adds a diagnostic error log when EXPO_PUBLIC_FISHJAM_ID is missing

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

Comment on lines +16 to +18
if (!fishjamId) {
console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable.");
}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The console.error call is placed directly in the render function body (not inside a useEffect). This means it will fire on every render while fishjamId is falsy, causing repeated error messages to be logged (e.g., during normal re-renders while the app is waiting for the environment variable to be loaded, or if the user's context causes a re-render).

Since this is a diagnostic one-time warning (not a per-render concern), it should be placed inside the existing useEffect, or a separate useEffect with fishjamId as a dependency, so it fires only once when the condition is detected.

Suggested change
if (!fishjamId) {
console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable.");
}
useEffect(() => {
if (!fishjamId) {
console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable.");
}
}, [fishjamId]);

Copilot uses AI. Check for mistakes.
process.env.EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL ?? "";
const VIDEOROOM_PROD_SANDBOX_URL =
process.env.EXPO_PUBLIC_FISHJAM_ID ?? "";
process.env.EXPO_PUBLIC_FISHJAM_ID!;
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

Using the non-null assertion operator (!) on process.env.EXPO_PUBLIC_FISHJAM_ID only suppresses the TypeScript compiler warning — it does not guarantee the value is defined at runtime. If the environment variable is absent, VIDEOROOM_PROD_SANDBOX_URL will be undefined at runtime, which can cause silent failures when changeFishjamId is called with it (e.g., when the prod env button is pressed).

For consistency with how this env variable is handled elsewhere in the codebase (e.g., _layout.tsx line 7 uses ?? "", and livestream.tsx line 20 also uses ?? ""), consider using process.env.EXPO_PUBLIC_FISHJAM_ID ?? "" instead.

Suggested change
process.env.EXPO_PUBLIC_FISHJAM_ID!;
process.env.EXPO_PUBLIC_FISHJAM_ID ?? "";

Copilot uses AI. Check for mistakes.
- `EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL` - Sandbox URL for VideoRoom staging environment
- `EXPO_PUBLIC_FISHJAM_ID` - Fishjam ID for production environment

You can find value for this variable by creating an account on [fishjam.io](https://fishjam.io) and copying it from the sandbox dashboard.
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The sentence "You can find value for this variable..." is missing the article "the" before "value". It should read "You can find the value for this variable...".

Suggested change
You can find value for this variable by creating an account on [fishjam.io](https://fishjam.io) and copying it from the sandbox dashboard.
You can find the value for this variable by creating an account on [fishjam.io](https://fishjam.io) and copying it from the sandbox dashboard.

Copilot uses AI. Check for mistakes.

You can find value for this variable by creating an account on [fishjam.io](https://fishjam.io) and copying it from the sandbox dashboard.

There also exists this additional environment variable, which is used for internal testing purposes:
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

There is a trailing space at the end of the sentence "There also exists this additional environment variable, which is used for internal testing purposes: " (after the colon). This should be removed.

Suggested change
There also exists this additional environment variable, which is used for internal testing purposes:
There also exists this additional environment variable, which is used for internal testing purposes:

Copilot uses AI. Check for mistakes.
@Magmusacy Magmusacy force-pushed the FCE-2879/fix-docs branch 2 times, most recently from 8d7a896 to eb26f7c Compare March 3, 2026 15:25
@Magmusacy Magmusacy requested a review from Copilot March 3, 2026 15:32
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.


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

const [videoRoomEnv, setVideoRoomEnv] = useState<VideoRoomEnv>(
VIDEOROOM_PROD_SANDBOX_URL ? "prod" : "staging",
);

Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

There is a trailing whitespace on this line (line 32 in the new file, line 53 in the diff). While not a functional issue, this is inconsistent with the surrounding code style.

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +31
const [videoRoomEnv, setVideoRoomEnv] = useState<VideoRoomEnv>(
VIDEOROOM_PROD_SANDBOX_URL ? "prod" : "staging",
);
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

When only EXPO_PUBLIC_VIDEOROOM_STAGING_SANDBOX_URL is set and EXPO_PUBLIC_FISHJAM_ID is empty, the default videoRoomEnv is "staging" (line 30), but changeFishjamId(VIDEOROOM_STAGING_SANDBOX_URL) is never called on mount. This means the fishjamId in FishjamProvider (in _layout.tsx) starts as an empty string, so the staging URL is not actually applied until the user manually presses the "Staging" button. The old code handled this via useFocusEffect. A useEffect that calls changeFishjamId with the appropriate URL on mount (based on the initial videoRoomEnv value) would fix this regression.

Copilot uses AI. Check for mistakes.
Comment on lines 78 to +94
@@ -134,7 +91,7 @@ export default function RoomScreen() {
type={videoRoomEnv === 'prod' ? 'primary' : 'secondary'}
onPress={() => handleEnvChange('prod')}
/>
</View>
</View>)}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The env switcher (staging/prod buttons) is conditionally shown only when VIDEOROOM_STAGING_SANDBOX_URL is set, but it does not also check whether VIDEOROOM_PROD_SANDBOX_URL is set. When only staging is available, pressing the "Production" button calls changeFishjamId(""), which sets the Fishjam ID to an empty string and would cause connection errors. The condition should also verify that VIDEOROOM_PROD_SANDBOX_URL is non-empty before showing both buttons, or at minimum the "Production" button should be disabled/hidden when VIDEOROOM_PROD_SANDBOX_URL is absent.

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +20
if (!fishjamId) {
console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable.");
}
}, [fishjamId]);
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

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

The error message says "Please set the EXPO_PUBLIC_FISHJAM_ID environment variable" but fishjamId can also be legitimately changed to an empty string by changeFishjamId("") (e.g., via the "Production" button when no prod URL is configured). In such cases this error message is misleading. Additionally, this effect fires on every change to fishjamId, so if fishjamId goes empty after already being set, users would see a confusing console error. Consider restricting this log to mount only (using a ref to track initial mount), or making the message more general.

Suggested change
if (!fishjamId) {
console.error("Fishjam ID is not set. Please set the EXPO_PUBLIC_FISHJAM_ID environment variable.");
}
}, [fishjamId]);
if (!DEFAULT_FISHJAM_ID) {
console.error(
"Fishjam ID is not configured. Set the EXPO_PUBLIC_FISHJAM_ID environment variable or select a preset that provides a Fishjam ID.",
);
}
}, []);

Copilot uses AI. Check for mistakes.
@Magmusacy Magmusacy force-pushed the FCE-2879/fix-docs branch from eb26f7c to de9a6d0 Compare March 3, 2026 15:45
@Magmusacy Magmusacy marked this pull request as ready for review March 4, 2026 09:04
Copy link
Collaborator

@MiloszFilimowski MiloszFilimowski left a comment

Choose a reason for hiding this comment

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

Great work 🚀 Just one suggestion!

} from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { router, useFocusEffect } from "expo-router";
import AsyncStorage from "@react-native-async-storage/async-storage";
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: I think we don't use this library anymore and it could be removed.

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.

3 participants