feat(knowledge): rebuild the project notes panel as Project knowledge (#2973)
The panel stored notes, todos and plans inside one shared JSON file that six unrelated domains also wrote to, synchronised itself through window CustomEvents, and could only read plans. It is now Project knowledge: server-owned storage with explicit routes, a store with rollback, a section sidebar, plans that open and edit in place, and search across all of it. Notes and plans the user pins travel with every message sent in that project. Pinning is project state, not an attachment to one message, so it holds until unpinned and the work status panel names what is riding along and can detach it. Agent memory is added alongside, in two scopes: what is true about the user, and what is true about this codebase. The split is not cosmetic — a wrong project fact costs one project and is noticed, while a wrong global fact quietly shapes every session everywhere and the user has no code to check it against. It stays separate from notes so an agent mistake cannot land in what the user wrote. Sessions receive an index of titles only; bodies are read on demand, because an index carrying full text grows until it crowds out the conversation. Deciding what a session must be told, and whether it has been told, now lives on the server. The client owned it before, which meant sessions started without a UI — scheduled tasks, sessions the agent dispatches — received nothing at all, and a tab's record of what it had sent outlived the conversation: after compaction the agent no longer held the block while the tab went on believing it did. What was delivered is recorded in the session's own metadata, and compaction restores it through the runtime that already restores pinned messages, in the same turn. Agent memory ships dark behind OPENCHAMBER_MEMORY_ENABLE: unset, there is no tool, no routes, no session index, no settings row and no panel tab. Absent rather than switched off, so nothing invites turning on a feature that has not been announced. Pinned notes and plans are unaffected and ship as normal.
This commit is contained in:
committed by
GitHub
parent
7611076436
commit
34e8a24b20
@@ -254,6 +254,7 @@ export const createScheduledTasksRuntime = (deps) => {
|
||||
waitForOpenCodeReady,
|
||||
emitTaskRunEvent,
|
||||
setSessionAutoAccept,
|
||||
sessionKnowledgeRuntime = null,
|
||||
logger = console,
|
||||
maxGlobalConcurrency = DEFAULT_GLOBAL_CONCURRENCY,
|
||||
maxProjectConcurrency = DEFAULT_PROJECT_CONCURRENCY,
|
||||
@@ -451,7 +452,7 @@ export const createScheduledTasksRuntime = (deps) => {
|
||||
return projectRunning < maxProjectConcurrency;
|
||||
};
|
||||
|
||||
const buildPromptAsyncPayload = (task, projectPath) => ({
|
||||
const buildPromptAsyncPayload = (task, projectPath, knowledgeText = '') => ({
|
||||
model: {
|
||||
providerID: task.execution.providerID,
|
||||
modelID: task.execution.modelID,
|
||||
@@ -459,6 +460,10 @@ export const createScheduledTasksRuntime = (deps) => {
|
||||
...(task.execution.agent ? { agent: task.execution.agent } : {}),
|
||||
...(task.execution.variant ? { variant: task.execution.variant } : {}),
|
||||
parts: [
|
||||
// Standing project context first, so the prompt reads against it. A
|
||||
// scheduled run has no UI to attach this, which is why it is asked for
|
||||
// here rather than assembled by whoever is sending.
|
||||
...(knowledgeText ? [{ type: 'text', text: knowledgeText, synthetic: true }] : []),
|
||||
{
|
||||
type: 'text',
|
||||
text: expandSnippets(task.execution.prompt, projectPath),
|
||||
@@ -470,6 +475,13 @@ export const createScheduledTasksRuntime = (deps) => {
|
||||
});
|
||||
|
||||
const runPromptAsync = async ({ baseUrl, authHeaders, sessionID, projectPath, task }) => {
|
||||
// Never allowed to fail the run: a task that executes without its
|
||||
// background is a lesser loss than a task that does not execute.
|
||||
const knowledge = sessionKnowledgeRuntime
|
||||
? await sessionKnowledgeRuntime.resolvePendingForSession(sessionID, projectPath)
|
||||
.catch(() => ({ text: '', signature: '' }))
|
||||
: { text: '', signature: '' };
|
||||
|
||||
const promptUrl = new URL(`${baseUrl}/session/${encodeURIComponent(sessionID)}/prompt_async`);
|
||||
promptUrl.searchParams.set('directory', projectPath);
|
||||
const response = await fetch(promptUrl.toString(), {
|
||||
@@ -479,13 +491,20 @@ export const createScheduledTasksRuntime = (deps) => {
|
||||
'content-type': 'application/json',
|
||||
accept: 'application/json',
|
||||
},
|
||||
body: JSON.stringify(buildPromptAsyncPayload(task, projectPath)),
|
||||
body: JSON.stringify(buildPromptAsyncPayload(task, projectPath, knowledge.text)),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const body = await response.text().catch(() => '');
|
||||
throw new Error(`prompt_async failed (${response.status})${body ? `: ${body}` : ''}`);
|
||||
}
|
||||
|
||||
// Recorded only after the prompt is accepted, so a failed dispatch carries
|
||||
// the context again on the next run.
|
||||
if (knowledge.text && sessionKnowledgeRuntime) {
|
||||
await sessionKnowledgeRuntime.recordDelivered(sessionID, projectPath, knowledge.signature)
|
||||
.catch(() => undefined);
|
||||
}
|
||||
};
|
||||
|
||||
const resolveScheduledCommand = async ({ client, projectPath, task }) => {
|
||||
|
||||
Reference in New Issue
Block a user