Skip to content

fix(vscode): resolve HANA connection from config in subfolders#182

Merged
jung-thomas merged 1 commit into
mainfrom
fix/vscode-subfolder-connection-resolution
Jul 14, 2026
Merged

fix(vscode): resolve HANA connection from config in subfolders#182
jung-thomas merged 1 commit into
mainfrom
fix/vscode-subfolder-connection-resolution

Conversation

@jung-thomas

Copy link
Copy Markdown
Contributor

Problem

The VS Code extension's connection resolver only inspected the workspace root. CAP projects that keep their connection config in a subfolder (e.g. cap/) showed "HANA: Not Connected" even though .cdsrc-private.json / default-env.json existed one level down. The cwd passed to cds env / cf service-key was also the root, so binding resolution would fail there too.

Reproduced with the cloud-cap-hana-swapi project (config lives in cap/).

Fix

  • discovery.ts (new) — pure, bounded recursive scan (default depth 3) for directories containing .cdsrc-private.json, default-env.json, or a CAP package.json. Skips node_modules/.git/build dirs; returns candidates shallowest-first.
  • resolver.ts — refactored to resolveConnectionInDir(dir) so it resolves any directory and uses that dir as the cwd for cds env / cf service-key. resolveConnection(workspaceFolder) kept as a thin wrapper.
  • extension.ts — new autoResolveConnection(): honors a hana-cli.projectPath setting if set, otherwise scans, uses the single candidate directly, or shows a QuickPick when several exist.
  • package.json — adds the hana-cli.projectPath configuration contribution.
  • README — documents subfolder scanning + the new setting.

Bonus: hana-cli vscode status

Enhanced to compare the installed extension version against the packaged .vsix and suggest updating when behind. install now uses --force so it upgrades in place (no uninstall needed).

Testing

  • vscode-extension/test/suite/discovery.test.ts — 6 tests (subfolder detection, shallowest-first ordering, ignore rules, depth limit). ✅
  • tests/vscodeVersion.Test.js — 10 tests for compareVersions / parseVsixVersion / parseInstalledVersion. ✅
  • Both tsconfig compiles clean (strict).
  • Verified end-to-end against cloud-cap-hana-swapi: discovery finds cap/ and cds env ... --resolve-bindings resolves credentials from that cwd → status bar shows connected.
  • vscode status verified in both branches (up-to-date and update-available).

Notes

  • CHANGELOG.json/CHANGELOG.md intentionally untouched — this repo manages the changelog at release time via scripts/prepare-release.js, not per-PR.

The extension resolver only inspected the workspace root, so CAP
projects that keep their connection config in a subfolder (e.g. cap/)
showed "HANA: Not Connected" even though .cdsrc-private.json /
default-env.json existed one level down.

- Add discovery.ts: bounded recursive scan for directories containing
  .cdsrc-private.json, default-env.json, or a CAP package.json
  (skips node_modules/.git/build dirs; shallowest-first)
- Refactor resolver to resolveConnectionInDir(dir) so it resolves any
  directory and uses it as cwd for cds env / cf service-key
- extension.ts: honor new hana-cli.projectPath setting, else auto-scan,
  prompting via QuickPick when multiple candidates are found
- Add hana-cli.projectPath configuration contribution + README docs

Also enhance `hana-cli vscode status` to compare the installed
extension version against the packaged .vsix and suggest updating
(install now uses --force to upgrade in place).

Tests: discovery.test.ts (6) + vscodeVersion.Test.js (10), all green.
@jung-thomas
jung-thomas merged commit 3d44d26 into main Jul 14, 2026
16 checks passed
jung-thomas added a commit that referenced this pull request Jul 14, 2026
…183)

Two related artifact-inspector bugs in the VS Code extension:

1. Clicking an .hdbtable/.hdbview/etc. opened the inspector but left the
   object-name input empty. The extension posted an `openArtifact`
   message that no Vue component consumed. Fix: pass the name as a route
   query param the views already read (e.g. /inspect-table?table=NAME),
   matching how the browser UI navigates. Covers all artifact kinds.

2. Type-ahead suggestions never appeared in webview inputs. useSuggestions
   fetched with relative URLs, which resolve against the vscode-webview://
   origin instead of the http://localhost:<port> server. Fix: prefix
   fetches with getAdapter().getApiBaseUrl(), matching useHanaApi.

Also cut release 4.202607.1 (via scripts/prepare-release.js) documenting
these fixes plus the unreleased subfolder connection-resolution work and
`vscode status` update-check from PR #182.

Tests: new useSuggestions vitest (TDD red->green); full vue suite 51/51.

Co-authored-by: Thomas Jung <12159356+jung-thomas@users.noreply.github.com>
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.

1 participant