Skip to content

Conversation

@uinstinct
Copy link
Contributor

@uinstinct uinstinct commented Oct 24, 2025

Description

Use ide.readfile instead of fs.readfile in StaticContextService

resolves CON-4504

AI Code Review

  • Team members only: AI review runs automatically when PR is opened or marked ready for review
  • Team members can also trigger a review by commenting @continue-review

Checklist

  • [] I've read the contributing guide
  • [] The relevant docs, if any, have been updated or created
  • [] The relevant tests, if any, have been updated or created

Screen recording or screenshot

[ When applicable, please include a short screen recording or screenshot - this makes it much easier for us as contributors to review and understand your changes. See this PR as a good example. ]

Tests

[ What tests were added or updated to ensure the changes work as expected? ]


Summary by cubic

Refactored StaticContextService to use IDE file APIs for reading files and scanning directories, improving support for URIs and virtual workspaces. Addresses CON-4504 by routing file access through the IDE layer.

  • Refactors
    • Replaced fs.readFile with ide.readFile and fs.readdir with ide.listDir using FileType.
    • Normalized paths via pathToFileURL/localPathOrUriToPath for consistent URI handling.
    • Removed fs/promises dependency; logic for skipping dirs and filtering TS extensions unchanged.

@uinstinct uinstinct requested a review from a team as a code owner October 24, 2025 05:16
@uinstinct uinstinct requested review from tingwai and removed request for a team October 24, 2025 05:16
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 24, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@sestinj
Copy link
Contributor

sestinj commented Oct 27, 2025

@uinstinct I tried merging main into this branch but we still have a lot of test failures that must be coming from the changes here

@uinstinct uinstinct force-pushed the static-context-ide-readfile branch from 7be374d to 74af332 Compare October 28, 2025 04:57
if (entry.isDirectory()) {
// Skip common directories that typically don't contain source files
if (!shouldSkipDirectory(entry.name)) {
if (fileType === (2 as FileType.Directory)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not familiar with the ide API, we're supposed to typecast 2 as FileType.Directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, actually FileType enum exists in a .d.ts file which has import issues when not used as a type

we have done this in few places such as:

entry[1] === (1 as FileType.File) ||
entry[1] === (2 as FileType.Directory),

? (2 as FileType.Directory)
: dirent.isSymbolicLink()
? (64 as FileType.SymbolicLink)
: (1 as FileType.File),

@uinstinct uinstinct requested a review from tingwai November 6, 2025 02:33
@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Nov 6, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 6, 2025
@tingwai tingwai merged commit f2143a7 into continuedev:main Nov 6, 2025
56 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Nov 6, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2025
@uinstinct uinstinct deleted the static-context-ide-readfile branch November 7, 2025 02:24
@sestinj
Copy link
Contributor

sestinj commented Nov 7, 2025

🎉 This PR is included in version 1.32.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer released size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants