Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
scope the document-save no-op check to the document, matching its scoped commit
[._.]/ Adam Eivyac40fbf636c6
diff --git a/server/routes/apps/documents.js b/server/routes/apps/documents.jsindex ecbd7b5974..b061cd2012 100644--- a/server/routes/apps/documents.js+++ b/server/routes/apps/documents.js@@ -196,7 +196,10 @@ router.put('/:id/documents/*docPath', loadApp, asyncHandler(async (req, res) =>await atomicWrite(resolved, content);await git.stageFiles(app.repoPath, [filename]);- const status = await git.getStatus(app.repoPath);+ // Scope the check to this document, because the commit below is scoped too:+ // a repo-wide `clean` is false whenever the user has any unrelated dirty file,+ // and the partial commit that follows then exits 1 on an unchanged document.+ const status = await git.getStatus(app.repoPath, { paths: [filename] });if (status.clean) {return res.json({ success: true, noChanges: true });}diff --git a/server/routes/apps/documents.test.js b/server/routes/apps/documents.test.jsindex eae4519d68..45b0470ab3 100644--- a/server/routes/apps/documents.test.js+++ b/server/routes/apps/documents.test.js@@ -126,6 +126,22 @@ describe('Apps Document Routes', () => {expect(await readFile(join(repoPath, 'docs', 'decisions', '2026-01-01-choice.md'), 'utf-8')).toBe('# Revised');});+ it('asks git about this document only, so unrelated dirt cannot force a partial commit that exits 1', async () => {+ // The commit is scoped to the document, so the "did anything change?" gate+ // must be too. Repo-wide, any unrelated dirty file reads as not-clean, and+ // `git commit -- <doc>` on an unchanged doc then exits 1 as a 500.+ git.getStatus.mockResolvedValueOnce({ clean: true });++ const res = await request(app)+ .put('/api/apps/app-1/documents/docs/API.md')+ .send({ content: '# API' });++ expect(git.getStatus).toHaveBeenCalledWith(repoPath, { paths: ['docs/API.md'] });+ expect(res.status).toBe(200);+ expect(res.body).toMatchObject({ success: true, noChanges: true });+ expect(git.commit).not.toHaveBeenCalled();+ });+it('refuses to write outside the browsable set', async () => {const res = await request(app).put('/api/apps/app-1/documents/server/index.js')diff --git a/server/services/git.js b/server/services/git.jsindex 973b46a9dc..5a4e016735 100644--- a/server/services/git.js+++ b/server/services/git.js@@ -38,10 +38,18 @@ export {};/**- * Get git status for a directory+ * Get git status for a directory.+ *+ * `paths` scopes the answer to a pathspec, for a caller whose follow-up write+ * is itself scoped — a repo-wide "is anything dirty?" does not answer "did THIS+ * file change?", and a partial `git commit -- <path>` exits 1 when that path+ * carries no change.*/-export async function getStatus(dir) {- const result = await execGit(['status', '--porcelain'], dir);+export async function getStatus(dir, { paths = [] } = {}) {+ const result = await execGit(+ ['status', '--porcelain', ...(paths.length ? ['--', ...paths] : [])],+ dir,+ );// trimEnd (not trim): porcelain status codes use leading spaces (e.g. ' M' = unstaged)const lines = result.stdout.trimEnd().split('\n').filter(Boolean);