fix(local-system): restore loc param when calling readLocalFile IPC#13748
Conversation
The `denormalizeParams` method in `LocalSystemExecutionRuntime` was
missing a case for `readLocalFile`. It fell through to `default`, which
passed `{startLine, endLine, path}` as-is to the IPC layer. However,
the IPC handler (`LocalFileCtr.readFile`) expects `LocalReadFileParams`
with `loc?: [number, number]`, not `startLine`/`endLine`. As a result,
`loc` was always `undefined` on the IPC side, causing `readLocalFile`
to default to `[0, 200]` and always return content from line 0.
Fix: add an explicit `readLocalFile` case that reconstructs the `loc`
tuple from `startLine` and `endLine` before forwarding to the IPC layer.
Fixes lobehub#13735
|
Someone is attempting to deploy a commit to the LobeHub OSS Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## canary #13748 +/- ##
==========================================
- Coverage 66.58% 66.56% -0.03%
==========================================
Files 1999 2022 +23
Lines 165955 171262 +5307
Branches 19193 16654 -2539
==========================================
+ Hits 110503 113998 +3495
- Misses 55328 57139 +1811
- Partials 124 125 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
❤️ Great PR @octo-patch ❤️ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
Fixes #13735
Problem
The
readLocalFiletool accepts aloc: [startLine, endLine]parameter to read a specific line range. However, when called through the Desktop Electron runtime, thelocparameter was always ignored — the returned content always started from line 0.Root cause: A parameter conversion mismatch in
LocalSystemExecutionRuntime.denormalizeParams.The call chain is:
LocalSystemExecutor.readLocalFile(params)→ extractsloc→ passes{startLine, endLine, path}toruntime.readFile()ComputerRuntime.readFile()→ callscallService('readLocalFile', {startLine, endLine, path})LocalSystemExecutionRuntime.denormalizeParams('readLocalFile', ...)→ fell through todefault→ passed{startLine, endLine, path}unchanged to the IPC serviceLocalFileCtr.readFile()expectsLocalReadFileParamswithloc?: [number, number], notstartLine/endLinelocwasundefined,readLocalFiledefaulted to[0, 200]on every callSolution
Added an explicit
readLocalFilecase indenormalizeParamsthat reconstructs theloctuple fromstartLineandendLinebefore forwarding to the IPC layer:When neither
startLinenorendLineis provided,locisundefined, which causes thereadLocalFilebackend to use its own default of[0, 200]— preserving existing behavior.Testing
packages/local-file-shell/src/file/__tests__/file.test.tsandapps/desktop/src/main/controllers/__tests__/LocalFileCtr.test.tsthat the underlyingreadLocalFilecorrectly slices lines whenlocis providedlocwas never reaching the file-reading layer