fix: apply the review items for #714 at merge

- Session update no longer resets "How often" while typing: updateGitFetchStatus
  (session-ui.js) leaves a control alone while it is document.activeElement, and
  autoSaveGitFetch writes the clamped interval back itself (Enter saves with the
  field still focused).
- Partial override shows the app values: enabled = session ?? app switch,
  interval = session ?? app interval ?? 300 (session-ui.js updateGitFetchStatus).
- runFetch (git-fetch.ts) arms the spawn with what the core.sshCommand read left
  of timeoutMs, and answers ETIMEDOUT without spawning when nothing is left, so a
  git that never answers costs one timeout, not two.
- fetchEnvFor keeps a GIT_SSH from the server's environment (repoSshCommand ||
  base.GIT_SSH), fileoverview and CLAUDE.md line updated to say so.
- i18n.js: the zh-CN "Git fetch on an interval" description scopes the only
  writing git command to the Git window.
- styles.css: the disabled/busy rules are scoped to .git-status-actions
  .btn-icon-sm (moved beside .git-status-actions), and the busy pulse stops
  under prefers-reduced-motion.
- Comments that called the override per case now say per session: session.ts
  (field, restore and getter docs, setGitFetchSettings), git-fetch-scheduler.ts:2,
  server-timing.ts:78, server.ts (cleanup and restore), app.js _onSessionUpdated,
  session-ui.js (openSessionOptions and updateGitFetchStatus).
- Tests: test/git-fetch-session-options-ui.test.ts (new, JSDOM: typing survives
  an SSE update, the Enter write-back, both partial cases); test/git-fetch.test.ts
  (GIT_SSH kept; one bound for the read and the fetch, stub git on PATH).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Codeman maintainer committed 2026-10-27 01:58:14 +01:00
1 parent 3411d7f35a
commit 6539bc6c82
12 files changed
+299 -68

No files matched your search

+43
View File
@@ -246,6 +246,13 @@ describe('fetchEnvFor', () => {
const env = fetchEnvFor({ ...BASE, GIT_SSH_COMMAND: 'ssh -i /home/t/personal' }, 'ssh -i /repo/key');
expect(env.GIT_SSH_COMMAND).toBe('ssh -i /home/t/personal');
});
it("leaves a GIT_SSH in the server's environment to git, which reads it last and would never see it under a written default", () => {
const env = fetchEnvFor({ ...BASE, GIT_SSH: '/home/t/bin/work-ssh' }, null);
expect(env.GIT_SSH_COMMAND).toBeUndefined();
expect(env.GIT_SSH).toBe('/home/t/bin/work-ssh');
expect(env.GIT_TERMINAL_PROMPT).toBe('0');
});
});
// ─── Real git, real local repository ─────────────────────────────────────────
@@ -558,6 +565,42 @@ describe.skipIf(!gitPresent)('runFetch (the whole tree, not just the git parent)
});
});
// ─── One bound for the config read and the fetch ─────────────────────────────
describe.skipIf(process.platform === 'win32')('runFetch (one bound for the config read and the fetch)', () => {
it('answers at the timeout when git never answers, not at twice it, because the core.sshCommand read spends part of the bound', async () => {
// A `git` that never answers anything, first on PATH, so the read ahead of the fetch hangs exactly as long as
// the fetch would. Both spawns take PATH from process.env at call time. It records its arguments, so the test
// can tell which of the two it was asked to run.
const bin = join(dir, 'bin');
const calls = join(dir, 'calls');
mkdirSync(bin);
writeFileSync(join(bin, 'git'), `#!/bin/sh\necho "$*" >> '${calls}'\nexec sleep 30\n`, { mode: 0o755 });
const savedPath = process.env.PATH;
process.env.PATH = `${bin}:${savedPath ?? ''}`;
try {
const started = Date.now();
const err = (await runFetch(dir, buildFetchArgs(), { timeoutMs: 1_000 }).catch((e) => e)) as {
code?: unknown;
killed?: boolean;
};
const elapsed = Date.now() - started;
expect(err.code).toBe('ETIMEDOUT');
expect(err.killed).toBe(true);
expect(describeFetchFailure(err).code).toBe('TIMEOUT');
// One bound, not one per spawn: the read used all of it, so the fetch got nothing and was not started
// (2019 ms here before the fix, when the fetch was armed with a fresh timeout of its own).
expect(elapsed).toBeGreaterThanOrEqual(950);
expect(elapsed).toBeLessThan(1_600);
expect(readFileSync(calls, 'utf8').trim().split('\n')).toEqual(['config --get core.sshCommand']);
} finally {
if (savedPath === undefined) delete process.env.PATH;
else process.env.PATH = savedPath;
}
});
});
// ─── One run per folder, and one bound for the whole tick ────────────────────
describe.skipIf(!gitPresent)('fetchWorkspaceOnce (the join)', () => {