fix(chat): recall the current session's prompts by default; tidy the six merged PRs

Input history (#3035) shipped with "All projects" as the default scope and
only recorded prompts sent after the upgrade, so ArrowUp showed other
sessions' prompts and, once switched to "Current session", nothing at all.
Default to the current session and merge the visible transcript's prompts
with the persisted bucket. Existing sessions recall as they did before
#3035, while new prompts keep their attachments and stay recallable after
a revert hides them from the transcript.

Cleanup across #1855, #2297, #3072, #3178, #3035 and #3135: drop the
duplicate poll guards in the file content poller, the zod schema the
VS Code package cannot depend on, a copied file-URL helper and stray
whitespace; move the Enter-to-send strings into the settings namespace;
document OPENCHAMBER_CHATS_DIR, resolve the chats root once on the server
and warm it alongside the other bootstrap calls.
This commit is contained in:
Bohdan Triapitsyn
2026-09-05 20:16:14 +03:00
parent 3df97908fe
commit f46fb718c5
73 changed files with 513 additions and 242 deletions
+1 -2
View File
@@ -313,8 +313,7 @@ function getCurrentUsername() {
// when the user has lingering enabled. Detect it so `startup enable` can warn
// that the service may otherwise stop on logout. Returns null when the state
// cannot be determined (no username, loginctl unavailable, or odd output).
function getUserLingerEnabled(username) {
const user = typeof username === 'string' && username.length > 0 ? username : getCurrentUsername();
function getUserLingerEnabled(user) {
if (!user) {
return null;
}
+1 -1
View File
@@ -1320,7 +1320,7 @@ const resolveMemoryProjectId = createMemoryProjectResolver({
return sanitizeProjects(settings?.projects || []).map((project) => project.path);
},
resolvePrimaryWorktreeRoot,
managedProjectRoots: [path.join(OPENCHAMBER_USER_CONFIG_ROOT, 'chats'), OPENCHAMBER_CHATS_DIR],
managedProjectRoots: [...new Set([path.join(OPENCHAMBER_USER_CONFIG_ROOT, 'chats'), OPENCHAMBER_CHATS_DIR])],
});
/**
+6 -6
View File
@@ -526,9 +526,12 @@ export const registerFsRoutes = (app, dependencies) => {
openchamberUserConfigRoot,
managedChatsRoot,
} = dependencies;
const managedRoots = [openchamberUserConfigRoot, managedChatsRoot]
.filter((root) => typeof root === 'string' && root.trim().length > 0)
.map((root) => path.resolve(root));
// Chat worktrees may live outside every project workspace; both managed
// roots stay valid filesystem targets.
const chatsRoot = typeof managedChatsRoot === 'string' && managedChatsRoot.trim()
? path.resolve(managedChatsRoot.trim())
: path.join(openchamberUserConfigRoot, 'chats');
const managedRoots = [path.resolve(openchamberUserConfigRoot), chatsRoot];
const realpathCache = createRealpathCache({
realpath: fsPromises.realpath.bind(fsPromises),
});
@@ -707,9 +710,6 @@ export const registerFsRoutes = (app, dependencies) => {
if (!home || typeof home !== 'string' || home.length === 0) {
return res.status(500).json({ error: 'Failed to resolve home directory' });
}
const chatsRoot = managedChatsRoot && managedChatsRoot.trim()
? path.resolve(managedChatsRoot.trim())
: path.join(openchamberUserConfigRoot, 'chats');
return res.json({ home, chatsRoot });
} catch (error) {
console.error('Failed to resolve home directory:', error);
@@ -1,4 +1,4 @@
export const DEFAULT_INPUT_HISTORY_SCOPE = 'global';
export const DEFAULT_INPUT_HISTORY_SCOPE = 'session';
export const DEFAULT_INPUT_HISTORY_LIMIT = 40;
const MIN_INPUT_HISTORY_LIMIT = 1;
const MAX_INPUT_HISTORY_LIMIT = 100;
@@ -705,12 +705,11 @@ export const createSettingsHelpers = (dependencies) => {
result.gitChangesViewMode = mode;
}
}
switch (candidate.toolJsonViewMode) {
case 'summary':
case 'formatted':
case 'raw':
result.toolJsonViewMode = candidate.toolJsonViewMode;
break;
if (typeof candidate.toolJsonViewMode === 'string') {
const mode = candidate.toolJsonViewMode.trim();
if (mode === 'summary' || mode === 'formatted' || mode === 'raw') {
result.toolJsonViewMode = mode;
}
}
if (typeof candidate.directoryShowHidden === 'boolean') {
result.directoryShowHidden = candidate.directoryShowHidden;
@@ -121,7 +121,7 @@ describe('settings helpers', () => {
inputHistoryLimit: 40,
});
expect(helpers.formatSettingsResponse({})).toMatchObject({
inputHistoryScope: 'global',
inputHistoryScope: 'session',
inputHistoryLimit: DEFAULT_INPUT_HISTORY_LIMIT,
});
} finally {
@@ -265,14 +265,14 @@ describe('settings helpers', () => {
expect(helpers.sanitizeSettingsUpdate({ inputHistoryScope: 'workspace' })).toEqual({});
});
it('defaults inputHistoryScope to global in formatted settings responses', () => {
it('defaults inputHistoryScope to session in formatted settings responses', () => {
const helpers = createTestHelpers();
expect(helpers.formatSettingsResponse({ inputHistoryScope: 'session' })).toMatchObject({
inputHistoryScope: 'session',
expect(helpers.formatSettingsResponse({ inputHistoryScope: 'global' })).toMatchObject({
inputHistoryScope: 'global',
});
expect(helpers.formatSettingsResponse({})).toMatchObject({
inputHistoryScope: 'global',
inputHistoryScope: 'session',
});
});