Skip to content

chg: show localhost port # in tab title#2566

Merged
peterchinman merged 1 commit into
mainfrom
peter/port-in-tab
Apr 14, 2026
Merged

chg: show localhost port # in tab title#2566
peterchinman merged 1 commit into
mainfrom
peter/port-in-tab

Conversation

@peterchinman
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 14, 2026

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Tab titles in local development mode now display port information when using non-standard ports, making it easier to distinguish between multiple local development instances running simultaneously.

Walkthrough

A compile-time ENV_PREFIX constant in the tab title module was replaced with a runtime getEnvPrefix() function that dynamically computes the environment prefix based on LOCAL_ONLY and DEV_MODE_ENV settings, optionally including port information for local environments.

Changes

Cohort / File(s) Summary
Tab Title Environment Prefix Computation
js/app/packages/core/signal/tabTitle.ts
Refactored ENV_PREFIX from a static ternary expression into a getEnvPrefix() function that executes at module initialization. When LOCAL_ONLY is enabled, the prefix conditionally includes the last digit of window.location.port (if present and not '3000') in format [L:<digit>] or [L] otherwise. Returns [D] when DEV_MODE_ENV is true, otherwise empty string.
🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a description explaining the changes, implementation details, and rationale for modifying the tab title prefix logic.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the conventional commits format (chg:) and is 39 characters, well under the 72-character limit. It clearly describes the main change: showing the localhost port number in the tab title.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@js/app/packages/core/signal/tabTitle.ts`:
- Around line 9-10: The prefix logic currently truncates the port to the last
digit and hides port 3000; update the conditional that builds the title prefix
(the code referencing port and port.slice(-1)) to include the full port string
instead of slicing and do not special-case '3000'—return `[L:${port}] ` when
port is truthy and not empty, otherwise fall back to `[L] ` so the full
localhost port is shown in the title.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 93828729-d152-4230-91b1-bb11c674d912

📥 Commits

Reviewing files that changed from the base of the PR and between 56482c6 and 929abed.

📒 Files selected for processing (1)
  • js/app/packages/core/signal/tabTitle.ts

Comment on lines +9 to +10
if (port && port !== '3000') return `[L:${port.slice(-1)}] `;
return '[L] ';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Show the full localhost port in the prefix.

Line 9 currently truncates to the last digit (port.slice(-1)) and Line 9/10 hides 3000, so the title can’t reliably identify which local instance is open. This misses the PR goal of showing the localhost port number.

Proposed fix
 function getEnvPrefix(): string {
   if (LOCAL_ONLY) {
     const port = window.location.port;
-    if (port && port !== '3000') return `[L:${port.slice(-1)}] `;
+    if (port) return `[L:${port}] `;
     return '[L] ';
   }
   return DEV_MODE_ENV ? '[D] ' : '';
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (port && port !== '3000') return `[L:${port.slice(-1)}] `;
return '[L] ';
function getEnvPrefix(): string {
if (LOCAL_ONLY) {
const port = window.location.port;
if (port) return `[L:${port}] `;
return '[L] ';
}
return DEV_MODE_ENV ? '[D] ' : '';
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@js/app/packages/core/signal/tabTitle.ts` around lines 9 - 10, The prefix
logic currently truncates the port to the last digit and hides port 3000; update
the conditional that builds the title prefix (the code referencing port and
port.slice(-1)) to include the full port string instead of slicing and do not
special-case '3000'—return `[L:${port}] ` when port is truthy and not empty,
otherwise fall back to `[L] ` so the full localhost port is shown in the title.

@peterchinman peterchinman merged commit bd3a916 into main Apr 14, 2026
24 checks passed
@peterchinman peterchinman deleted the peter/port-in-tab branch April 14, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant