this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: stop republishing unchanged posts on legacy state

The previous legacy fallback at publish.ts treated any state entry
without a noteHash as "changed", forcing a full note republish on the
first run after upgrading to v0.5.0. That was wasteful: contentHash
already detects every local change, so when contentHash matches the
file is unchanged and PDS still matches it.

Now: if contentHash matches and noteHash is missing, silently backfill
noteHash from local content and skip the republish. Also split the
"content changed" reason string into "document changed" / "note
changed" / "content changed" so the change-detection trigger is visible
at a glance.

+35 -21
+35 -21
packages/remanso-cli/src/commands/publish.ts
··· 116 116 process.exit(1); 117 117 } 118 118 119 - const { config, configPath: resolvedConfigPath } = await loadConfig( 120 - configPath, 121 - ); 119 + const { config, configPath: resolvedConfigPath } = 120 + await loadConfig(configPath); 122 121 const configDir = path.dirname(resolvedConfigPath); 123 122 124 123 log.info(`Content directory: ${config.contentDir}`); ··· 209 208 const postsToPublish: Array<{ 210 209 post: BlogPost; 211 210 action: "create" | "update"; 212 - reason: "content changed" | "forced" | "new post" | "missing state"; 211 + reason: 212 + | "content changed" 213 + | "document changed" 214 + | "note changed" 215 + | "forced" 216 + | "new post" 217 + | "missing state"; 213 218 updateDocument: boolean; 214 219 updateNote: boolean; 215 220 }> = []; ··· 245 250 const noteHash = await computeNoteHash(post); 246 251 247 252 const documentChanged = postState.contentHash !== contentHash; 248 - // Treat absence of noteHash (legacy state) as changed so we populate it 253 + // Legacy state (no noteHash): only republish the note when the file 254 + // actually changed. If contentHash matches, we trust local and 255 + // silently backfill noteHash below. 249 256 const noteChanged = postState.noteHash 250 257 ? postState.noteHash !== noteHash 251 - : true; 258 + : documentChanged; 252 259 253 260 if (documentChanged || noteChanged) { 254 261 postsToPublish.push({ 255 262 post, 256 263 action: post.frontmatter.atUri ? "update" : "create", 257 - reason: "content changed", 264 + reason: 265 + documentChanged && noteChanged 266 + ? "content changed" 267 + : documentChanged 268 + ? "document changed" 269 + : "note changed", 258 270 updateDocument: documentChanged, 259 271 updateNote: noteChanged, 260 272 }); 273 + } else if (!postState.noteHash) { 274 + postState.noteHash = noteHash; 261 275 } 262 276 } 263 277 } ··· 389 403 updateNote: boolean; 390 404 }> = []; 391 405 392 - for ( 393 - const { 394 - post, 395 - action, 396 - updateDocument: shouldUpdateDoc, 397 - updateNote: shouldUpdateNote, 398 - } of postsToPublish 399 - ) { 406 + for (const { 407 + post, 408 + action, 409 + updateDocument: shouldUpdateDoc, 410 + updateNote: shouldUpdateNote, 411 + } of postsToPublish) { 400 412 const trimmedContent = post.content.trim(); 401 413 const titleMatch = trimmedContent.match(/^# (.+)$/m); 402 414 const title = titleMatch ? titleMatch[1] : post.frontmatter.title; ··· 485 497 486 498 noteQueue.push({ post, action, atUri, updateNote: shouldUpdateNote }); 487 499 } catch (error) { 488 - const errorMessage = error instanceof Error 489 - ? error.message 490 - : String(error); 500 + const errorMessage = 501 + error instanceof Error ? error.message : String(error); 491 502 s.stop(`Error publishing "${path.basename(post.filePath)}"`); 492 503 log.error(` ${errorMessage}`); 493 504 errorCount++; ··· 495 506 } 496 507 497 508 // Pass 2: Create/update Remanso notes 498 - for ( 499 - const { post, action, atUri, updateNote: shouldUpdateNote } of noteQueue 500 - ) { 509 + for (const { 510 + post, 511 + action, 512 + atUri, 513 + updateNote: shouldUpdateNote, 514 + } of noteQueue) { 501 515 if (!shouldUpdateNote && action !== "create") continue; 502 516 const relativeFilePath = path.relative(configDir, post.filePath); 503 517 try {