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:
Bohdan Triapitsyn
2026-08-18 02:59:04 +03:00
committed by GitHub
parent 7611076436
commit 34e8a24b20
102 changed files with 10640 additions and 1630 deletions
+61 -10
View File
@@ -35,6 +35,10 @@ type ContextPanelTab = {
id: string;
mode: ContextPanelMode;
targetPath: string | null;
/** Saved project plan this tab shows, for `plan` tabs opened from the notes
panel. Project plans are addressed by id because their markdown is
server-owned and has no client-visible path. */
projectPlanId: string | null;
dedupeKey: string;
label: string | null;
sessionTitleFallback: string | null;
@@ -47,6 +51,7 @@ type ContextPanelTab = {
type ContextPanelTabDescriptor = {
mode: ContextPanelMode;
targetPath?: string | null;
projectPlanId?: string | null;
dedupeKey?: string | null;
label?: string | null;
sessionTitleFallback?: string | null;
@@ -241,6 +246,9 @@ const createContextPanelTab = (descriptor: ContextPanelTabDescriptor): ContextPa
id: buildContextPanelTabID(descriptor.mode, dedupeKey),
mode: descriptor.mode,
targetPath: normalizedTargetPath,
projectPlanId: typeof descriptor.projectPlanId === 'string' && descriptor.projectPlanId.trim()
? descriptor.projectPlanId.trim()
: null,
dedupeKey,
label: normalizeContextTabLabel(descriptor.label),
sessionTitleFallback: normalizeContextTabLabel(descriptor.sessionTitleFallback),
@@ -300,6 +308,7 @@ const sanitizeContextPanelTabs = (tabs: unknown): ContextPanelTab[] => {
const candidate = entry as {
mode?: unknown;
targetPath?: unknown;
projectPlanId?: unknown;
dedupeKey?: unknown;
label?: unknown;
sessionTitleFallback?: unknown;
@@ -338,6 +347,9 @@ const sanitizeContextPanelTabs = (tabs: unknown): ContextPanelTab[] => {
id,
mode: candidate.mode,
targetPath,
projectPlanId: typeof candidate.projectPlanId === 'string' && candidate.projectPlanId.trim()
? candidate.projectPlanId.trim()
: null,
dedupeKey,
label: normalizeContextTabLabel(typeof candidate.label === 'string' ? candidate.label : null),
sessionTitleFallback: normalizeContextTabLabel(typeof candidate.sessionTitleFallback === 'string' ? candidate.sessionTitleFallback : null),
@@ -607,7 +619,6 @@ interface UIStore {
contextEditorTreeVisible: boolean;
contextEditorTreeWidth: number;
notesPanelHeight: number;
todoPanelHeight: number;
/** Expanded collapsible sections of the in-chat work-status panel, by id. */
workStatusExpandedSections: Record<string, boolean>;
/** Scroll offset of that panel, so it survives being unmounted. */
@@ -749,6 +760,21 @@ interface UIStore {
showOpenCodeUpdateNotifications: boolean;
agentControlToolEnabled: boolean;
agentWebToolEnabled: boolean;
agentMemoryToolEnabled: boolean;
/**
* Whether this build has agent memory at all. Server-owned and not
* persisted: an unreleased feature must not come back from a stale cache.
*/
agentMemoryFeatureAvailable: boolean;
/**
* When the user last looked at each memory scope, keyed by scope. Drives the
* new/changed badges; there is no stored review state.
*/
agentMemoryViewedAt: Record<string, number>;
/** Width of the project context panel's section sidebar, in pixels. */
projectContextSidebarWidth: number;
/** Active tab of the project context panel (notes/todos/plans). */
projectContextTab: string;
inputSpellcheckEnabled: boolean;
wideChatLayoutEnabled: boolean;
codeBlockLineWrap: boolean;
@@ -806,7 +832,6 @@ interface UIStore {
setWorkStatusOverlayOpen: (open: boolean) => void;
setWorkStatusSectionVisible: (sectionId: string, visible: boolean) => void;
setWorkStatusHiddenSections: (sectionIds: string[]) => void;
setTodoPanelHeight: (height: number) => void;
setSessionSwitcherOpen: (open: boolean) => void;
setSessionDropdownOpen: (open: boolean) => void;
setActiveMainTab: (tab: MainTab) => void;
@@ -923,6 +948,11 @@ interface UIStore {
setShowOpenCodeUpdateNotifications: (value: boolean) => void;
setAgentControlToolEnabled: (value: boolean) => void;
setAgentWebToolEnabled: (value: boolean) => void;
setAgentMemoryToolEnabled: (value: boolean) => void;
setAgentMemoryFeatureAvailable: (value: boolean) => void;
markAgentMemoryViewed: (key: string, viewedAt: number) => void;
setProjectContextSidebarWidth: (width: number) => void;
setProjectContextTab: (value: string) => void;
setInputSpellcheckEnabled: (value: boolean) => void;
setWideChatLayoutEnabled: (value: boolean) => void;
setCodeBlockLineWrap: (value: boolean) => void;
@@ -979,7 +1009,6 @@ export const useUIStore = create<UIStore>()(
workStatusPanelFits: false,
workStatusOverlayOpen: false,
workStatusHiddenSections: [],
todoPanelHeight: 259,
isSessionSwitcherOpen: false,
isSessionDropdownOpen: false,
activeMainTab: 'chat',
@@ -1082,6 +1111,11 @@ export const useUIStore = create<UIStore>()(
showOpenCodeUpdateNotifications: !isWindowsArm64(),
agentControlToolEnabled: true,
agentWebToolEnabled: true,
agentMemoryToolEnabled: false,
agentMemoryFeatureAvailable: false,
agentMemoryViewedAt: {},
projectContextSidebarWidth: 168,
projectContextTab: 'notes',
inputSpellcheckEnabled: false,
wideChatLayoutEnabled: false,
codeBlockLineWrap: true,
@@ -1576,9 +1610,6 @@ export const useUIStore = create<UIStore>()(
set({ workStatusHiddenSections: [...new Set(sectionIds)] });
},
setTodoPanelHeight: (height) => {
set({ todoPanelHeight: height });
},
setSessionSwitcherOpen: (open) => {
if (get().isSessionSwitcherOpen === open) {
@@ -2306,6 +2337,27 @@ export const useUIStore = create<UIStore>()(
setAgentWebToolEnabled: (value) => {
set({ agentWebToolEnabled: value });
},
setAgentMemoryToolEnabled: (value) => {
set({ agentMemoryToolEnabled: value });
},
setAgentMemoryFeatureAvailable: (value) => {
set({ agentMemoryFeatureAvailable: value });
},
setProjectContextSidebarWidth: (width) => {
set({ projectContextSidebarWidth: width });
},
markAgentMemoryViewed: (key, viewedAt) => {
set((state) => ({
// Never moves backwards: a stale unmount landing after a newer look
// would otherwise resurrect badges the user has already cleared.
agentMemoryViewedAt: viewedAt > (state.agentMemoryViewedAt[key] ?? 0)
? { ...state.agentMemoryViewedAt, [key]: viewedAt }
: state.agentMemoryViewedAt,
}));
},
setProjectContextTab: (value) => {
set({ projectContextTab: value });
},
setInputSpellcheckEnabled: (value) => {
set({ inputSpellcheckEnabled: value });
},
@@ -2524,9 +2576,6 @@ export const useUIStore = create<UIStore>()(
if (typeof state.notesPanelHeight !== 'number' || !Number.isFinite(state.notesPanelHeight)) {
state.notesPanelHeight = 112;
}
if (typeof state.todoPanelHeight !== 'number' || !Number.isFinite(state.todoPanelHeight)) {
state.todoPanelHeight = 259;
}
}
// v0 -> v1: reset legacy notification templates
@@ -2624,7 +2673,6 @@ export const useUIStore = create<UIStore>()(
workStatusScrollTop: state.workStatusScrollTop,
workStatusPanelEnabled: state.workStatusPanelEnabled,
workStatusHiddenSections: state.workStatusHiddenSections,
todoPanelHeight: state.todoPanelHeight,
isSessionSwitcherOpen: state.isSessionSwitcherOpen,
activeMainTab: state.activeMainTab,
sidebarSection: state.sidebarSection,
@@ -2689,6 +2737,9 @@ export const useUIStore = create<UIStore>()(
showOpenCodeUpdateNotifications: state.showOpenCodeUpdateNotifications,
agentControlToolEnabled: state.agentControlToolEnabled,
agentWebToolEnabled: state.agentWebToolEnabled,
agentMemoryToolEnabled: state.agentMemoryToolEnabled,
agentMemoryViewedAt: state.agentMemoryViewedAt,
projectContextSidebarWidth: state.projectContextSidebarWidth,
inputSpellcheckEnabled: state.inputSpellcheckEnabled,
wideChatLayoutEnabled: state.wideChatLayoutEnabled,
codeBlockLineWrap: state.codeBlockLineWrap,