fix: proper project isolation and relative path matching for file-context hook
- Use getProjectContext(cwd).allProjects for project scoping (same as SessionStart) - Convert absolute file_path to relative using cwd (observations store relative paths) - API accepts comma-separated projects param with IN() SQL filter - Remove basename matching — use full relative path to avoid cross-file collisions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -111,8 +111,8 @@ export class DataRoutes extends BaseRouteHandler {
|
||||
});
|
||||
|
||||
/**
|
||||
* Get observations associated with a file path
|
||||
* GET /api/observations/by-file?path=<file_path>&project=<project>&limit=30
|
||||
* Get observations associated with a file path, scoped to projects
|
||||
* GET /api/observations/by-file?path=<file_path>&projects=<comma,separated>&limit=30
|
||||
*/
|
||||
private handleGetObservationsByFile = this.wrapHandler((req: Request, res: Response): void => {
|
||||
const filePath = req.query.path as string | undefined;
|
||||
@@ -121,11 +121,12 @@ export class DataRoutes extends BaseRouteHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
const project = req.query.project as string | undefined;
|
||||
const projectsParam = req.query.projects as string | undefined;
|
||||
const projects = projectsParam ? projectsParam.split(',').filter(Boolean) : undefined;
|
||||
const limit = req.query.limit ? parseInt(req.query.limit as string, 10) : undefined;
|
||||
|
||||
const db = this.dbManager.getSessionStore().db;
|
||||
const observations = getObservationsByFilePath(db, filePath, { project, limit });
|
||||
const observations = getObservationsByFilePath(db, filePath, { projects, limit });
|
||||
|
||||
res.json({ observations, count: observations.length });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user