Welcome to the final chapter of our tutorial series!
In the previous chapter, Billing Authorization Gate, we learned how to check if a user has enough credits to run a review. We acted like a toll booth: the road existed, but you had to pay to use it.
But what if the road isn't finished yet? What if we are still building the feature and only want developers to see it? Or what if we want to turn it off instantly during a system outage?
We need a way to hide the feature entirely. This brings us to Feature Visibility Control.
Imagine you go to a fast-food restaurant. You look at the menu board. You order a burger.
Now, imagine the restaurant is testing a new "Ultra Burger." They don't want to print it on the main menu yet because they might run out of ingredients, or the recipe isn't perfect.
Feature Visibility Control is that switch.
In software development, we often merge code before it is 100% ready for the public. We use Feature Flags (remote switches) to control who sees what.
Before the user can even type /ultrareview (as described in Command Execution Flow), the application has to decide: "Should I even put this command in the list?"
It checks a remote configuration system called GrowthBook.
The logic for this is very simple but powerful. It lives in a file called ultrareviewEnabled.ts.
Let's break down how we check the visibility status.
We use a helper function to talk to our remote configuration system. We don't want to make a slow network request every single time, so we use a "Cached" value.
// ultrareviewEnabled.ts
import { getFeatureValue_CACHED_MAY_BE_STALE } from '../../services/analytics/growthbook.js';
_CACHED_MAY_BE_STALE: This long name tells us that the value might be a few minutes old. That is okay! Speed is more important than being up-to-the-second precise for UI visibility.
We define a function isUltrareviewEnabled. This is the function that the main application calls when building the command menu.
export function isUltrareviewEnabled(): boolean {
// 1. Fetch the specific configuration object
const cfg = getFeatureValue_CACHED_MAY_BE_STALE<Record<string, unknown> | null>(
'tengu_review_bughunter_config',
null
);
// ... continued below ...
'tengu_review_bughunter_config': This is the unique ID (key) of our feature flag in the cloud dashboard.null: This is the default value if we can't connect to the server. By default, the feature is hidden (safe mode).
Finally, we look inside that configuration object to see if the enabled property is true.
// 2. Return true ONLY if explicitly enabled
return cfg?.enabled === true;
}
cfg?.enabled: The ? means "if cfg exists, check enabled."false. The command disappears from the user's view.This check happens at the very top level of the application.
isUltrareviewEnabled().true: The command system registers /ultrareview. The flow described in Command Execution Flow is now possible.false: The command is ignored. If a user types it, the system says "Command not found."Congratulations! You have completed the Review Project Tutorial.
Let's recap the journey of a single command:
You now understand the full lifecycle of the ultrareview command, from a hidden flag in the cloud to a completed code review in your terminal.
Happy Coding!
Generated by Code IQ