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
@@ -7,6 +7,7 @@ import {
|
||||
} from '@/components/sections/shared/SettingsSection';
|
||||
import { recordDeferredOpenCodeRestart } from '@/lib/opencode/deferredRestart';
|
||||
import { updateDesktopSettings } from '@/lib/persistence';
|
||||
import { useAgentMemoryStore } from '@/stores/useAgentMemoryStore';
|
||||
import { useUIStore } from '@/stores/useUIStore';
|
||||
import { useI18n } from '@/lib/i18n';
|
||||
|
||||
@@ -27,6 +28,11 @@ export const OpenChamberToolsSettings: React.FC = () => {
|
||||
const setAgentControlToolEnabled = useUIStore((state) => state.setAgentControlToolEnabled);
|
||||
const agentWebToolEnabled = useUIStore((state) => state.agentWebToolEnabled);
|
||||
const setAgentWebToolEnabled = useUIStore((state) => state.setAgentWebToolEnabled);
|
||||
const agentMemoryToolEnabled = useUIStore((state) => state.agentMemoryToolEnabled);
|
||||
// Absent, not merely off: the feature is finished but unreleased, and a
|
||||
// visible switch invites turning on something that was never announced.
|
||||
const agentMemoryAvailable = useUIStore((state) => state.agentMemoryFeatureAvailable);
|
||||
const setAgentMemoryToolEnabled = useUIStore((state) => state.setAgentMemoryToolEnabled);
|
||||
|
||||
const handleAgentControlToolChange = React.useCallback((enabled: boolean) => {
|
||||
setAgentControlToolEnabled(enabled);
|
||||
@@ -40,6 +46,24 @@ export const OpenChamberToolsSettings: React.FC = () => {
|
||||
recordDeferredOpenCodeRestart('cli', { id: 'agent-web-tool' });
|
||||
}, [setAgentWebToolEnabled]);
|
||||
|
||||
// Turning memory off removes the whole feature, not just the tool: the panel
|
||||
// tab goes with it and sessions stop being given the index. Showing the user
|
||||
// what is stored would be pointless once the agent can no longer manage it.
|
||||
const handleAgentMemoryToolChange = React.useCallback((enabled: boolean) => {
|
||||
setAgentMemoryToolEnabled(enabled);
|
||||
// Re-read after the write lands, not before. The switch flips the client
|
||||
// immediately, which makes the panel ask the server straight away — and
|
||||
// while the setting is still being written the server truthfully answers
|
||||
// "disabled", which used to leave the tab hidden until a restart.
|
||||
void updateDesktopSettings({ agentMemoryToolEnabled: enabled })
|
||||
.finally(() => {
|
||||
if (enabled) {
|
||||
void useAgentMemoryStore.getState().refresh();
|
||||
}
|
||||
});
|
||||
recordDeferredOpenCodeRestart('cli', { id: 'agent-memory-tool' });
|
||||
}, [setAgentMemoryToolEnabled]);
|
||||
|
||||
return (
|
||||
<SettingsSection title={t('settings.openchamber.tools.title')}>
|
||||
<div className={SETTINGS_OPTION_STACK_CLASS}>
|
||||
@@ -60,6 +84,17 @@ export const OpenChamberToolsSettings: React.FC = () => {
|
||||
ariaLabel={t('settings.openchamber.tools.field.agentWebToolAria')}
|
||||
info={t('settings.openchamber.tools.field.agentWebToolInfo')}
|
||||
/>
|
||||
|
||||
{agentMemoryAvailable ? (
|
||||
<SettingsCheckboxRow
|
||||
settingsItem="sessions.agent-memory-tool"
|
||||
checked={agentMemoryToolEnabled}
|
||||
onChange={handleAgentMemoryToolChange}
|
||||
label={t('settings.openchamber.tools.field.agentMemoryTool')}
|
||||
ariaLabel={t('settings.openchamber.tools.field.agentMemoryToolAria')}
|
||||
info={t('settings.openchamber.tools.field.agentMemoryToolInfo')}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</SettingsSection>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user