Repository navigation
fix(mount): persist raw file content in file-index for file mode - #8531
Conversation
WalkthroughThis PR threads a new ChangesRaw content propagation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ParseFile
participant MountManager
participant FileIndex
participant TreeBuilder
participant ReduxStore
ParseFile->>MountManager: return {data, raw, hash, mtime}
MountManager->>MountManager: entry.state.set({data, raw})
MountManager->>FileIndex: stage({op: 'add', data, raw, hash, mtime})
FileIndex->>FileIndex: persist raw column (SQLite)
MountManager->>TreeBuilder: buildTree(entries)
TreeBuilder->>TreeBuilder: buildRequestNode sets raw from entry.raw
TreeBuilder-->>ReduxStore: tree items with raw
ReduxStore->>ReduxStore: merge item using FILE_DERIVED_REQUEST_FIELDS (incl. raw)
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
30355f3 to
d0d9032
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/bruno-electron/src/services/mount/manager.js (1)
191-195: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCarry
rawinto the partial-parse error path.parseFilereturnsrawfor partial parses, but this branch drops it by storing only{ data, error }, soentry.rawbecomesnullintree-builder.js. Addraw: result.rawhere so partial request nodes keep their source text.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-electron/src/services/mount/manager.js` around lines 191 - 195, The partial-parse error path in the mount manager is dropping the source text returned by parseFile, which causes entry.raw to be null later. Update the error branch in manager.js where entry.state is set for result.error so it stores raw: result.raw alongside data and error, matching the success path and preserving partial request content for tree-builder.js.
🧹 Nitpick comments (2)
packages/bruno-electron/src/services/mount/file-index.js (2)
33-35: 🧹 Nitpick | 🔵 Trivial | 💤 Low valueOne-time full re-parse across all collections. Resetting
mtime=0/hash=''for every row (all collections, not just the mounted one) forces a complete re-walk and re-parse on the next launch. Intentional for backfill, but worth a heads-up: on large/multi-collection setups this adds a noticeable one-time startup cost after upgrade. Consider confirming this is acceptable or scoping the reset if it proves too heavy.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-electron/src/services/mount/file-index.js` around lines 33 - 35, The migration in `file-index.js` is resetting `mtime` and `hash` for every `file_index_entries` row, which triggers a full re-parse across all collections on next launch. Review the `up` migration block and either confirm this all-collection backfill is intentionally required, or change the `UPDATE` in the migration logic to scope the reset to only the mounted collection if the startup cost is too heavy.
167-167: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueStorage footprint doubles per entry. Persisting full
rawtext alongside the parseddataJSON roughly doubles the on-disk size per request inmount-snapshots.db.getCacheSize()will report the larger value and cache-clear expectations may shift. Fine functionally — flagging so the size impact is a conscious tradeoff.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-electron/src/services/mount/file-index.js` at line 167, The snapshot record in file-index.js is persisting both raw text and parsed data, which roughly doubles storage per entry; decide whether raw is truly needed and, if not, remove it from the persisted mount-snapshots.db shape or make it optional/lazy in the snapshot-building flow around the readFileSync/raw assignment. If raw must stay, update getCacheSize() expectations and any cache-clearing logic/tests to reflect the larger per-entry footprint and keep the schema change intentional.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/bruno-electron/src/services/mount/manager.js`:
- Around line 191-195: The partial-parse error path in the mount manager is
dropping the source text returned by parseFile, which causes entry.raw to be
null later. Update the error branch in manager.js where entry.state is set for
result.error so it stores raw: result.raw alongside data and error, matching the
success path and preserving partial request content for tree-builder.js.
---
Nitpick comments:
In `@packages/bruno-electron/src/services/mount/file-index.js`:
- Around line 33-35: The migration in `file-index.js` is resetting `mtime` and
`hash` for every `file_index_entries` row, which triggers a full re-parse across
all collections on next launch. Review the `up` migration block and either
confirm this all-collection backfill is intentionally required, or change the
`UPDATE` in the migration logic to scope the reset to only the mounted
collection if the startup cost is too heavy.
- Line 167: The snapshot record in file-index.js is persisting both raw text and
parsed data, which roughly doubles storage per entry; decide whether raw is
truly needed and, if not, remove it from the persisted mount-snapshots.db shape
or make it optional/lazy in the snapshot-building flow around the
readFileSync/raw assignment. If raw must stay, update getCacheSize()
expectations and any cache-clearing logic/tests to reflect the larger per-entry
footprint and keep the schema change intentional.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3ea7e56f-0aa3-451e-9f7a-aca90e1acee8
📒 Files selected for processing (5)
packages/bruno-app/src/providers/ReduxStore/slices/collections/index.jspackages/bruno-electron/src/services/mount/file-index.jspackages/bruno-electron/src/services/mount/manager.jspackages/bruno-electron/src/services/mount/tree-builder.jspackages/bruno-electron/src/services/pool/jobs/parse-file.js
|
Tests |
Store the original file content as a `raw` column in the file-index and propagate it through the parse pipeline, mount manager, and tree builder so request nodes carry their raw content in file mode. Adds a migration to add the column and force a re-index of existing entries.
d0d9032 to
11d59eb
Compare
Description
JIRA
In file mode, request nodes were not carrying their raw file content, leaving the
rawfield empty. This change persists the original file content through the mount pipeline so it is available on request nodes.Changes
contentasrawalongside the parsed data.raw TEXTcolumn (schema migration v2) and read/write it inentries(),stage(), and the on-disk read path. The migration forces a re-index of existing entries (mtime = 0, hash = '') so the column gets populated.rawwhen updating in-memory state and staging index entries.rawon request nodes (defaulting tonull).rawtoFILE_DERIVED_REQUEST_FIELDSso it is treated as a file-derived field.How to test
Summary by CodeRabbit
New Features
Bug Fixes