feat: rename organizations → workspaces in CLI#85
Conversation
chore: sync dev → main (publish workflow fix)
chore: sync dev → main (trusted publishing)
chore: sync dev to main (oidc environment fix)
chore: sync dev to main
Updates all org-related terminology across auth, whoami, and repl flows to match the workspace rebrand from timberlogs-core#863.
📝 WalkthroughWalkthroughThis PR systematically renames organizational concepts to workspace concepts across the CLI codebase. API response fields (organization_name → workspace_name), type definitions, state variables (orgName → workspaceName), helper functions, and UI labels are updated consistently across five files to align with backend rebranding. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/commands/whoami.tsx (1)
58-65:⚠️ Potential issue | 🟠 MajorRoute successful JSON output through the shared JSON-mode helper.
This branch still depends on
options.jsonand writes JSON manually, so non-TTY stdout can miss JSON mode and still render Ink output before completion.As per coding guidelines, "Use isJsonMode(options) to detect JSON output mode (when stdout is not a TTY or --json flag is set)" and "use jsonOutput(data) for success".Suggested fix
const info: Result = { authenticated: true, ...(workspaceName ? {workspace: workspaceName} : {}), }; - if (options.json) { - console.log(JSON.stringify(info)); - process.exit(0); + if (isJsonMode(options)) { + jsonOutput(info); + return; }Add the corresponding helper imports at the top of the file.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/commands/whoami.tsx` around lines 58 - 65, Replace the manual JSON branch that checks options.json and does console.log/ process.exit with the shared helpers: import isJsonMode and jsonOutput at the top, then use if (isJsonMode(options)) { jsonOutput(info); return; } instead of console.log(JSON.stringify(info)); process.exit(0); so JSON output is routed through the common JSON-mode detection and formatting; update the surrounding code to return after jsonOutput to avoid Ink rendering.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/commands/login.tsx`:
- Around line 116-121: Replace the direct options.json check and console.log in
the successful auth branch with the shared JSON path: call isJsonMode(options)
to detect JSON mode and use jsonOutput({...}) to emit the machine-readable
object (including token.workspace_name as workspace when present) instead of
console.log; ensure you import isJsonMode and jsonOutput at the top of the file
and retain the process.exit(0) behavior if needed.
In `@src/components/ReplView.tsx`:
- Around line 78-82: The fetchWorkspaceName function only sets workspace name on
truthy responses, so when the token changes or the /v1/whoami call fails you
must clear any stale value; update fetchWorkspaceName (and the other place that
sets workspaceName) to setWorkspaceName(undefined) before/when starting the
fetch and also in the catch/failure branch (or when whoami.workspaceName is
absent) so the header cannot display a previous session's workspace; reference
the fetchWorkspaceName function and setWorkspaceName state updater when making
these changes.
---
Outside diff comments:
In `@src/commands/whoami.tsx`:
- Around line 58-65: Replace the manual JSON branch that checks options.json and
does console.log/ process.exit with the shared helpers: import isJsonMode and
jsonOutput at the top, then use if (isJsonMode(options)) { jsonOutput(info);
return; } instead of console.log(JSON.stringify(info)); process.exit(0); so JSON
output is routed through the common JSON-mode detection and formatting; update
the surrounding code to return after jsonOutput to avoid Ink rendering.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a9f539d1-f468-4e0d-a4fa-b7769bbd4327
📒 Files selected for processing (5)
src/commands/login.tsxsrc/commands/whoami.tsxsrc/components/ReplView.tsxsrc/components/commandViews/LoginView.tsxsrc/components/commandViews/WhoamiView.tsx
| if (options.json) { | ||
| console.log(JSON.stringify({ | ||
| authenticated: true, | ||
| ...(token.organization_name ? {organization: token.organization_name} : {}), | ||
| ...(token.workspace_name ? {workspace: token.workspace_name} : {}), | ||
| })); | ||
| process.exit(0); |
There was a problem hiding this comment.
Use the shared JSON-mode path here instead of options.json + console.log.
This success branch still keys off --json only and bypasses jsonOutput(...), so redirected stdout can miss the machine-readable path and still emit Ink output.
Suggested fix
- if (options.json) {
- console.log(JSON.stringify({
- authenticated: true,
- ...(token.workspace_name ? {workspace: token.workspace_name} : {}),
- }));
- process.exit(0);
- }
+ if (isJsonMode(options)) {
+ jsonOutput({
+ authenticated: true,
+ ...(token.workspace_name ? {workspace: token.workspace_name} : {}),
+ });
+ return;
+ }Add the corresponding helper imports at the top of the file.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/commands/login.tsx` around lines 116 - 121, Replace the direct
options.json check and console.log in the successful auth branch with the shared
JSON path: call isJsonMode(options) to detect JSON mode and use
jsonOutput({...}) to emit the machine-readable object (including
token.workspace_name as workspace when present) instead of console.log; ensure
you import isJsonMode and jsonOutput at the top of the file and retain the
process.exit(0) behavior if needed.
| const fetchWorkspaceName = useCallback(async (t: string) => { | ||
| try { | ||
| const client = createApiClient({token: t}); | ||
| const whoami = await client.get<{organizationName?: string}>('/v1/whoami'); | ||
| if (whoami.organizationName) setOrgName(whoami.organizationName); | ||
| const whoami = await client.get<{workspaceName?: string}>('/v1/whoami'); | ||
| if (whoami.workspaceName) setWorkspaceName(whoami.workspaceName); |
There was a problem hiding this comment.
Clear stale workspaceName when the token changes or the fetch fails.
This branch only writes truthy values, so a previous workspace can survive a failed /v1/whoami call or a response without workspaceName. The header can then show the wrong workspace for the current session.
Suggested fix
const fetchWorkspaceName = useCallback(async (t: string) => {
try {
const client = createApiClient({token: t});
const whoami = await client.get<{workspaceName?: string}>('/v1/whoami');
- if (whoami.workspaceName) setWorkspaceName(whoami.workspaceName);
+ setWorkspaceName(whoami.workspaceName ?? null);
} catch {
+ setWorkspaceName(null);
// silently fail — header shows "Authenticated" fallback
}
}, []);
useEffect(() => {
- if (!token) { setWorkspaceName(null); return; }
+ if (!token) { setWorkspaceName(null); return; }
+ setWorkspaceName(null);
void fetchWorkspaceName(token);
-}, [token]);
+}, [token, fetchWorkspaceName]);Also applies to: 94-95
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/components/ReplView.tsx` around lines 78 - 82, The fetchWorkspaceName
function only sets workspace name on truthy responses, so when the token changes
or the /v1/whoami call fails you must clear any stale value; update
fetchWorkspaceName (and the other place that sets workspaceName) to
setWorkspaceName(undefined) before/when starting the fetch and also in the
catch/failure branch (or when whoami.workspaceName is absent) so the header
cannot display a previous session's workspace; reference the fetchWorkspaceName
function and setWorkspaceName state updater when making these changes.
Summary
organization/orgName/organizationNamereferences toworkspace/workspaceNameacross auth and whoami flowsOrganization:→Workspace:/v1/whoami(organizationName→workspaceName)organization_name→workspace_name)Closes #84. Part of timberlogs-core#863.
Files changed
src/commands/whoami.tsxsrc/commands/login.tsxsrc/components/ReplView.tsxsrc/components/commandViews/LoginView.tsxsrc/components/commandViews/WhoamiView.tsxTest plan
timberlogs login— success message shows✓ Workspace: <name>timberlogs whoami— output showsWorkspace:label--jsonflag onwhoamioutputsworkspacekey (notorganization)Summary by CodeRabbit