fix(context): derive project from explicit projects array, not cwd
When a caller (e.g. worker context-inject route) passes a `projects` array without a matching cwd, the cwd-derived `context.primary` drifted from the projects being queried — producing an empty-state header for one project while querying another. Use the last entry of `projects` so header and query target stay in sync.
This commit is contained in:
@@ -130,11 +130,14 @@ export async function generateContext(
|
||||
const config = loadContextConfig();
|
||||
const cwd = input?.cwd ?? process.cwd();
|
||||
const context = getProjectContext(cwd);
|
||||
const project = context.primary;
|
||||
const platformSource = input?.platform_source;
|
||||
|
||||
// Use provided projects array (for worktree support) or fall back to all known projects
|
||||
// Single source of truth: explicit projects override cwd-derived context.
|
||||
// `project` (used for header + single-project query) is always the last entry
|
||||
// of `projects` so the empty-state header and the query target stay in sync
|
||||
// when a caller passes `projects` without a matching cwd (e.g. worker route).
|
||||
const projects = input?.projects ?? context.allProjects;
|
||||
const project = projects[projects.length - 1];
|
||||
|
||||
// Full mode: fetch all observations but keep normal rendering (level 1 summaries)
|
||||
if (input?.full) {
|
||||
|
||||
Reference in New Issue
Block a user