Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/windows-test-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Locations intentionally omit line numbers so unrelated edits do not invalidate t
| Classification | Count |
|---|---:|
| windows-backend-gap | 27 |
| portable-candidate | 12 |
| portable-candidate | 14 |
| platform-contract | 31 |

Total Windows-excluded declarations: **70**
Total Windows-excluded declarations: **72**

## Inventory

Expand All @@ -30,6 +30,8 @@ Total Windows-excluded declarations: **70**
| platform-contract | `apps/desktop/src/main/__tests__/shell-env.test.ts` keeps the inherited PATH and does not log shell stderr when capture fails | `process.platform === 'win32'` |
| platform-contract | `apps/desktop/src/main/__tests__/shell-env.test.ts` kills login-shell descendants when capture times out | `process.platform === 'win32'` |
| platform-contract | `apps/desktop/src/main/__tests__/shell-env.test.ts` bounds shell output instead of buffering until the global timeout | `process.platform === 'win32'` |
| portable-candidate | `packages/cli/src/__tests__/pi-transcript.test.ts` shortens POSIX paths under the home directory | `process.platform === 'win32'` |
| portable-candidate | `packages/cli/src/__tests__/pi-transcript.test.ts` keeps POSIX paths outside the home directory absolute | `process.platform === 'win32'` |
| portable-candidate | `packages/cli/src/__tests__/runtime-host-setup.test.ts` managed operator binds its Client Data Root and routes deployment cleanup | `process.platform === 'win32'` |
| portable-candidate | `packages/eval/src/__tests__/install-preflight.test.ts` rejects an unusable trials root before invoking external prerequisites | `process.platform === 'win32' \|\| process.geteuid?.() === 0` |
| windows-backend-gap | `packages/runtime-host/src/__tests__/connection-effect-coordinator.test.ts` leaves canonical onboarding state unchanged when the durable intent cannot be published | `process.platform === 'win32'` |
Expand Down
44 changes: 44 additions & 0 deletions packages/cli/src/__tests__/pi-transcript.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
makaPiToolPresentationStatus,
retireCancelledTransientMessages,
replaceTranscriptWithStoredMessages,
shortenCwd,
submitCompactToTranscript,
toggleAllThinkingExpansion,
toggleAllToolExpansion,
Expand Down Expand Up @@ -5141,3 +5142,46 @@ function subagentResult(
function stripAnsi(text: string): string {
return text.replace(/\x1b\[[0-9;]*m/g, '');
}

describe('shortenCwd', () => {
test('shortens POSIX paths under the home directory', {
skip: process.platform === 'win32',
}, () => {
assert.equal(shortenCwd('/Users/alice/work/project', '/Users/alice'), '~/work/project');
assert.equal(shortenCwd('/Users/alice/..\\notes', '/Users/alice'), '~/..\\notes');
assert.equal(shortenCwd('/Users/alice', '/Users/alice'), '~');
});

test('keeps POSIX paths outside the home directory absolute', {
skip: process.platform === 'win32',
}, () => {
assert.equal(shortenCwd('/Users/alice-shared', '/Users/alice'), '/Users/alice-shared');
assert.equal(shortenCwd('/Users', '/Users/alice'), '/Users');
assert.equal(shortenCwd('/tmp/project', '/Users/alice'), '/tmp/project');
});

test('shortens Windows profile paths (#3825)', { skip: process.platform !== 'win32' }, () => {
assert.equal(shortenCwd('C:\\Users\\alice\\Videos', 'C:\\Users\\alice'), '~/Videos');
assert.equal(
shortenCwd('C:\\Users\\alice\\Videos\\Clips', 'C:\\Users\\alice'),
'~/Videos\\Clips',
);
assert.equal(shortenCwd('C:\\Users\\alice', 'C:\\Users\\alice'), '~');
});

test('shortens Windows profile paths with case-only differences (#3825)', {
skip: process.platform !== 'win32',
}, () => {
assert.equal(shortenCwd('c:\\users\\alice\\videos', 'C:\\Users\\alice'), '~/videos');
});

test('keeps Windows paths outside the profile directory absolute (#3825)', {
skip: process.platform !== 'win32',
}, () => {
assert.equal(
shortenCwd('C:\\Users\\alice-shared', 'C:\\Users\\alice'),
'C:\\Users\\alice-shared',
);
assert.equal(shortenCwd('D:\\data\\project', 'C:\\Users\\alice'), 'D:\\data\\project');
});
});
17 changes: 12 additions & 5 deletions packages/cli/src/pi-transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import {
} from '@maka/core/tool-result-status';
import { type ShellRunUpdate } from '@maka/core/events';
import { homedir } from 'node:os';
import { basename } from 'node:path';
import { basename, isAbsolute, relative, sep } from 'node:path';
import type { MakaSessionDriver, MakaSideConversationParentStatus } from './session-driver.js';
import { BoundedChunkBuffer } from './bounded-chunk-buffer.js';
import { ansi } from './tui-ansi.js';
Expand Down Expand Up @@ -1938,12 +1938,19 @@ function firstLinePreview(text: string): string {
* Shorten an absolute path to a `~`-relative form for the statusline.
* `/Users/alice/workspace/project` → `~/workspace/project`.
* Falls back to the original path if it is not under the home directory.
* Comparison runs through `path.relative`, so Windows profile paths and
* case-only differences shorten as well; the remainder keeps its native
* separators (`~/Videos\Clips` on Windows).
*/
function shortenCwd(cwd: string, homeDir?: string): string {
export function shortenCwd(cwd: string, homeDir?: string): string {
const home = homeDir ?? homedir();
if (home && cwd.startsWith(home + '/')) return `~${cwd.slice(home.length)}`;
if (home && cwd === home) return '~';
return cwd;
if (!home) return cwd;
const rel = relative(home, cwd);
if (rel === '') return '~';
if (isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`)) {
return cwd;
}
return `~/${rel}`;
}

function formatCost(costUsd: number): string {
Expand Down