Skip to content

refactor(lana): use URI-safe file access - #952

Open
peternhale wants to merge 8 commits into
certinia:mainfrom
forcedotcom:ph/W-23939830-uri-upstream
Open

refactor(lana): use URI-safe file access#952
peternhale wants to merge 8 commits into
certinia:mainfrom
forcedotcom:ph/W-23939830-uri-upstream

Conversation

@peternhale

Copy link
Copy Markdown
Contributor

PR overview

Stack 2 of 4. Depends on #951. Makes log and workspace handling URI-native so Lana can operate against local and virtual filesystems.

Changes made

  • Replace filesystem paths with VS Code Uri values or serialized URI strings.
  • Route reads, writes, existence checks, caching, and navigation through URI-safe services.
  • Support file, memfs, vscode-vfs, and other virtual workspace schemes.
  • Update log analysis, language detection, providers, source lookup, and workspace selection.
  • Update URI mocks and affected unit tests.

Type of change

  • Refactor

Related issues

related W-23939830

Validation

  • pnpm typecheck
  • Seven focused unit suites: 98 tests

Comment thread lana/src/language/ApexLogLanguageDetector.ts Outdated
Comment thread lana/package.json Outdated
const buf = Buffer.alloc(4096);
const bytesRead = readSync(fd, buf, 0, 4096, 0);
const text = buf.toString('utf8', 0, bytesRead);
const text = (await readFile(uri)).slice(0, 4096);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads the whole file. we used to only read the first 4096 bytes to handle 100MB + logs.
We did this to support the code lenses on very large files vscode only returns document if it is less than 50MB I think (from memory) which is why we did this.

We could use the below which will give us the Uint8Array and avoid decoding the full file

const text = new TextDecoder().decode(bytes.subarray(0, 4096));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed as far as the current URI-safe APIs allow in 957277e. Detection now reads through workspace.fs and decodes only the first 4 KB from the returned byte array, preserving arbitrary URI providers and avoiding Node modules. workspace.fs still returns the complete byte array, so a true bounded provider read needs a future Services or filesystem-provider API; I am leaving this thread open for that remaining limitation.

Comment thread lana/src/language/ApexLogLanguageDetector.ts
Comment thread lana/src/commands/LogView.ts
@peternhale
peternhale force-pushed the ph/W-23939830-uri-upstream branch from 957277e to 4c271ca Compare August 27, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants