@pi-archimedes/footer 2.11.1 → 2.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-archimedes/footer",
3
- "version": "2.11.1",
3
+ "version": "2.11.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/danielcherubini/pi-archimedes.git"
@@ -19,7 +19,7 @@
19
19
  "./config": "./src/config.ts"
20
20
  },
21
21
  "dependencies": {
22
- "@pi-archimedes/core": "2.11.1"
22
+ "@pi-archimedes/core": "2.11.2"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@earendil-works/pi-coding-agent": ">=0.84.4",
package/src/index.test.ts CHANGED
@@ -1,4 +1,6 @@
1
+ import { posix, win32 } from "node:path";
1
2
  import { describe, it, expect, vi, afterEach } from "vitest";
3
+ import { footerIcons } from "./utils/icons.js";
2
4
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
3
5
 
4
6
  /**
@@ -76,6 +78,8 @@ let builtFooters: FooterInstance[] = [];
76
78
  afterEach(() => {
77
79
  for (const footer of builtFooters) footer.dispose();
78
80
  builtFooters = [];
81
+ vi.restoreAllMocks();
82
+ vi.doUnmock("node:path");
79
83
  });
80
84
 
81
85
  async function loadFooter(options: HarnessOptions = {}): Promise<Harness> {
@@ -172,6 +176,36 @@ async function loadFooter(options: HarnessOptions = {}): Promise<Harness> {
172
176
  };
173
177
  }
174
178
 
179
+ describe("footer directory display", () => {
180
+ it.each([
181
+ {
182
+ platform: "Windows",
183
+ path: win32,
184
+ directory: "C:\\Users\\example\\project",
185
+ expected: "project",
186
+ },
187
+ { platform: "POSIX", path: posix, directory: "/home/example/project", expected: "project" },
188
+ { platform: "Windows root", path: win32, directory: "C:\\", expected: "C:\\" },
189
+ { platform: "POSIX root", path: posix, directory: "/", expected: "/" },
190
+ {
191
+ platform: "POSIX backslash",
192
+ path: posix,
193
+ directory: "/home/example/my\\project",
194
+ expected: "my\\project",
195
+ },
196
+ ])("shows the directory name for $platform", async ({ path: platformPath, directory, expected }) => {
197
+ vi.doMock("node:path", async (importOriginal) => {
198
+ const original = await importOriginal<typeof import("node:path")>();
199
+ return { ...original, basename: platformPath.basename };
200
+ });
201
+ const { factory } = await loadFooter();
202
+ vi.spyOn(process, "cwd").mockReturnValue(directory);
203
+ const footer = factory({ requestRender: vi.fn() }, THEME, makeFooterData());
204
+
205
+ expect(footer.render(200)[0]?.split(" · ")[0]).toBe(` ${footerIcons.directory}${expected}`);
206
+ });
207
+ });
208
+
175
209
  describe("footer repaint wiring", () => {
176
210
  it("requests a render when a background VCS refresh reports a change", async () => {
177
211
  const { factory, notify } = await loadFooter();
package/src/index.ts CHANGED
@@ -20,6 +20,7 @@
20
20
  * instead of truncating.
21
21
  */
22
22
 
23
+ import { basename } from "node:path";
23
24
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
24
25
  import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
25
26
  import { diag, describeError } from "@pi-archimedes/core/log";
@@ -73,7 +74,7 @@ export function registerFooter(pi: ExtensionAPI): void {
73
74
  // --- ours: jj support and the worktree marker have no pi equivalent ---
74
75
  const jjBookmark = getJjBookmark();
75
76
  const currentBranch = jjBookmark ?? footerData.getGitBranch(); // branch itself is pi's
76
- const currentDirectory = process.cwd().split("/").pop() || process.cwd();
77
+ const currentDirectory = basename(process.cwd()) || process.cwd();
77
78
  // jj repos never run git: jj's changed-file count fills the "unstaged" (~N) slot
78
79
  const gitStatus = jjBookmark !== null
79
80
  ? { staged: 0, unstaged: getJjChangedFiles(), untracked: 0, ahead: 0, behind: 0 }