mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-17 11:49:33 +01:00
fix(git): the interval fetches one run per folder, and the rest of the review (review)
The scheduler is the part that runs with nobody watching, so it is decided per folder rather than per session: sessions sharing a folder are the same clone and share one run that both see, `inFlight`/`lastRunAt` are keyed by the resolved folder, the schedule is stamped when a folder is picked instead of when its run starts, and a tick is skipped while the previous one is still going. The click route joins a run already going for the same folder rather than starting a second fetch in one clone. The tick keeps ONE bound for the git processes of the whole run and hands it to every folder, and bounds its folders with a bound of its own: the same semaphore cannot serve both levels, because a folder holding a slot would then wait for a slot its own fetch needs. Both bounds are `FETCH_CONCURRENCY`, so the ceiling is unchanged. The bound claim in CLAUDE.md, the `Limiter` jsdoc and docs/api-reference.md now describes it as it is. Before anything is fetched the folder is probed with the bounded path probe, so a case on a mount that stopped answering is skipped and never touched. The rest of the review: the hooks are named as they really are (`reference-transaction`, `pre-auto-gc` through the maintenance a fetch triggers, config commands such as `credential.helper`) and `FETCH_CONFIG_ARGS` turns maintenance and gc off for an unattended run; the claim that an agent in the same repository is not disturbed is replaced by the ref-lock collision it actually is; the click route publishes its own run as `trigger: 'click'`; `autoSaveGitFetch` uses `_apiJson` so a 400 shows the error toast and applies the returned settings; and the two wording fixes. Tests: the scheduler pins one run per folder, the two bounds, the probe before anything runs, and that closing the session holding the override keeps the folder while another session is still open on it; the route test pins the click publish and the join, asserting the join before the held run is released — releasing first lets the run finish and clears the lane, so the joiner would be entitled to its own fetch and the test would pass for the wrong reason.
This commit is contained in:
1 parent
9432d9f9e2
commit
ea4318947b
20 files changed
+774
-209
No files matched your search
@@ -88,29 +88,36 @@ describe('Session Options modal structure', () => {
|
||||
expect(modal.match(/<button[^>]*data-tab="context"[^>]*>/)?.[0]).not.toContain('data-claude-only');
|
||||
});
|
||||
|
||||
it('keeps the Git rail entry for every local case, and hides it for the ones nothing is ever fetched for', () => {
|
||||
it('keeps the Git rail entry for every local session, and hides it for the ones nothing is ever fetched for', () => {
|
||||
const modal = optionsModal();
|
||||
// A shell case has repositories too, so Git must not ride the Claude-only flag.
|
||||
// A shell session has repositories too, so Git must not ride the Claude-only flag.
|
||||
expect(modal.match(/<button[^>]*data-tab="git"[^>]*>/)?.[0]).not.toContain('data-claude-only');
|
||||
const open = methodBody('openSessionOptions(sessionId)');
|
||||
expect(open).toContain('.set-rail-item[data-tab="git"]');
|
||||
// Remote and Docker cases answer 'unsupported' on both git routes and the scheduler never fetches them,
|
||||
// Remote and Docker sessions answer 'unsupported' on both git routes and the scheduler never fetches them,
|
||||
// so the entry goes the same way the Claude-only ones do.
|
||||
expect(open).toMatch(/gitTabBtn\.style\.display = session\.remote \|\| session\.docker \? 'none' : ''/);
|
||||
});
|
||||
|
||||
it('makes the Git rows inert while a case follows the app, the way the keep-warm rows go inert', () => {
|
||||
it('makes the Git rows inert while a session follows the app, the way the keep-warm rows go inert', () => {
|
||||
const modal = optionsModal();
|
||||
const update = methodBody('updateGitFetchStatus(sessionId)');
|
||||
expect(update).toContain('set-row-disabled');
|
||||
expect(update).toContain('el.disabled = follows');
|
||||
// Decided from BOTH fields: a half-choice means the case is not following, and the half that still follows
|
||||
// shows the app's value while the other shows its own — a switch-only check would gray out a live row.
|
||||
// Decided from BOTH fields: a half-choice means the session is not following, and the half that still
|
||||
// follows shows the app's value while the other shows its own — a switch-only check would gray out a live row.
|
||||
expect(update).toMatch(
|
||||
/follows = session\.gitFetchEnabled === undefined && session\.gitFetchIntervalSeconds === undefined/
|
||||
);
|
||||
// Following saves null on both halves, which is what clears the override on the route.
|
||||
expect(methodBody('async autoSaveGitFetch()')).toContain('{ enabled: null, intervalSeconds: null }');
|
||||
const save = methodBody('async autoSaveGitFetch()');
|
||||
expect(save).toContain('{ enabled: null, intervalSeconds: null }');
|
||||
// Saves through the helper that says whether the call went through: `_apiPost` hands back the Response
|
||||
// without checking it, so a body the route refused (a 400) read as a save, and the panel showed a choice
|
||||
// the server never took.
|
||||
expect(save).toContain('this._apiJson(`/api/sessions/${this.editingSessionId}/git-fetch-settings`');
|
||||
expect(save).toContain('if (!data)');
|
||||
expect(save).not.toMatch(/await this\._apiPost\(/);
|
||||
// The status row is runtime text this method writes, so translating it would rewrite the stamp.
|
||||
expect(modal).toContain('id="gitFetchStatus" data-i18n-skip hidden');
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user