Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aaronvanston/c81755e3133b6d80fa352884dd5893fe to your computer and use it in GitHub Desktop.

Select an option

Save aaronvanston/c81755e3133b6d80fa352884dd5893fe to your computer and use it in GitHub Desktop.
agentation: add .localhost support to local-dev hostname detection

Agentation .localhost Support Patch — Install Instructions

What this fixes

agentation@2.2.1 only treats these as local by default:

  • localhost
  • 127.0.0.1
  • 0.0.0.0
  • *.local

It does not include *.localhost (for example: app.localhost, docs.localhost).

This patch adds window.location.hostname.endsWith(".localhost") to local hostname detection.

Where this file goes

Put the patch file at:

patches/agentation@2.2.1.patch

at the repository root.

Required package.json wiring (Bun)

In the root package.json, add/update:

{
  "patchedDependencies": {
    "agentation@2.2.1": "patches/agentation@2.2.1.patch"
  }
}

How to apply

  1. Save the patch to patches/agentation@2.2.1.patch.
  2. Ensure your agentation dependency version is 2.2.1.
  3. Add the patchedDependencies entry above in root package.json.
  4. Run:
bun install

Bun will apply the patch during install.

Other package managers (brief)

npm

Use patch-package.

mkdir -p patches
curl -L "https://gist.githubusercontent.com/aaronvanston/c81755e3133b6d80fa352884dd5893fe/raw/322198bb7344c9a45671ef2f209b76f6b3baa2a8/agentation-localhost-support.patch" \
  -o patches/agentation+2.2.1.patch
npm i -D patch-package
npm pkg set scripts.postinstall="patch-package"
npm install

yarn

Use patch-package.

mkdir -p patches
curl -L "https://gist.githubusercontent.com/aaronvanston/c81755e3133b6d80fa352884dd5893fe/raw/322198bb7344c9a45671ef2f209b76f6b3baa2a8/agentation-localhost-support.patch" \
  -o patches/agentation+2.2.1.patch
yarn add -D patch-package
# Add this to package.json scripts:
# "postinstall": "patch-package"
yarn install

pnpm

Option A: patch-package (same flow as npm/yarn).

mkdir -p patches
curl -L "https://gist.githubusercontent.com/aaronvanston/c81755e3133b6d80fa352884dd5893fe/raw/322198bb7344c9a45671ef2f209b76f6b3baa2a8/agentation-localhost-support.patch" \
  -o patches/agentation+2.2.1.patch
pnpm add -D patch-package
pnpm pkg set scripts.postinstall="patch-package"
pnpm install

Option B: native pnpm patch registration in package.json:

{
  "pnpm": {
    "patchedDependencies": {
      "agentation@2.2.1": "patches/agentation@2.2.1.patch"
    }
  }
}

Quick apply from gist

mkdir -p patches
curl -L "https://gist.githubusercontent.com/aaronvanston/c81755e3133b6d80fa352884dd5893fe/raw/322198bb7344c9a45671ef2f209b76f6b3baa2a8/agentation-localhost-support.patch" \
  -o patches/agentation@2.2.1.patch
bun install

Verify patch applied

rg -n "endsWith\\(\"\\.localhost\\"\)" node_modules/agentation/dist/index.mjs node_modules/agentation/dist/index.js

You should see matches in both files.

If patch does not apply

  • Confirm installed version is exactly agentation@2.2.1.
  • Re-run bun install after updating patchedDependencies.
  • For npm/yarn/pnpm + patch-package, make sure patch filename is patches/agentation+2.2.1.patch and postinstall runs patch-package.
diff --git a/dist/index.js b/dist/index.js
index d2da7488a4f74d9b57d7aee99929aa266a8e4c4c..b98ee0b5abc8ede0af8fc8948a0f64e40a948863 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -2730,7 +2730,7 @@ function PageFeedbackToolbarCSS({
const [settings, setSettings] = (0, import_react2.useState)(DEFAULT_SETTINGS);
const [isDarkMode, setIsDarkMode] = (0, import_react2.useState)(true);
const [showEntranceAnimation, setShowEntranceAnimation] = (0, import_react2.useState)(false);
- const isLocalhost = typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "0.0.0.0" || window.location.hostname.endsWith(".local"));
+ const isLocalhost = typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "0.0.0.0" || window.location.hostname.endsWith(".local") || window.location.hostname.endsWith(".localhost"));
const effectiveReactMode = isLocalhost && settings.reactEnabled ? OUTPUT_TO_REACT_MODE[settings.outputDetail] : "off";
const [currentSessionId, setCurrentSessionId] = (0, import_react2.useState)(
initialSessionId ?? null
diff --git a/dist/index.mjs b/dist/index.mjs
index aa62d2b8312af6f5ee03387ab265558153c00fe9..72a4993028094e3eba1c1dad8cee05ba19825328 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -2657,7 +2657,7 @@ function PageFeedbackToolbarCSS({
const [settings, setSettings] = useState2(DEFAULT_SETTINGS);
const [isDarkMode, setIsDarkMode] = useState2(true);
const [showEntranceAnimation, setShowEntranceAnimation] = useState2(false);
- const isLocalhost = typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "0.0.0.0" || window.location.hostname.endsWith(".local"));
+ const isLocalhost = typeof window !== "undefined" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" || window.location.hostname === "0.0.0.0" || window.location.hostname.endsWith(".local") || window.location.hostname.endsWith(".localhost"));
const effectiveReactMode = isLocalhost && settings.reactEnabled ? OUTPUT_TO_REACT_MODE[settings.outputDetail] : "off";
const [currentSessionId, setCurrentSessionId] = useState2(
initialSessionId ?? null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment