mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
refactor(frontend): extract navigation helpers and improve settings back navigation (#210)
* feat: add persistent model state storage with database backend - Create opencode_model_state table for storing user model preferences - Implement database-backed model state management (recent, favorite, variant) - Add atomic JSON file utilities with file locking for concurrent safety - Migrate providers routes from file-based to database storage - Add backfill migration to preserve existing model.json data - Include comprehensive tests for model-state and atomic-json modules - Refactor useSessionAgent hook to simplify agent/model resolution logic - Update getFileApiUrl to use consistent query parameter approach * fix: include workspace dependencies in Docker image * fix: overlay workspace node_modules after source to prevent layer overwrite * fix: ensure model state table exists for existing databases * feat: add model state persistence and improve model selection sync - Add setActiveModel to modelStore and useModelSelection for direct model updates - Sync session agent model/variant to store when messages load - Include model, agent, and variant in optimistic user messages - Fix useSessionAgent to check isFetching during message loading - Update env.ts to use getter for BASE_PATH for dynamic resolution - Fix test environment variable from OPENCODE_WORKSPACE_PATH to WORKSPACE_PATH * refactor(frontend): extract navigation helpers and improve settings back navigation - Move swipe-back route logic into shared navigation.ts module - Add getSessionListPath helper for consistent session list navigation - Add section history tracking to settings dialog for proper back navigation - Fix voice status overlay loading text visibility during starting state - Update env and vite config for production domain
This commit is contained in:
1 parent
549e0ac7b2
commit
e959cc409f
10 files changed
+361
-66
No files matched your search
@@ -0,0 +1,94 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { getSessionListPath, getSwipeBackTarget } from './navigation';
|
||||
|
||||
describe('getSessionListPath', () => {
|
||||
it('returns repo path for non-assistant sessions', () => {
|
||||
expect(getSessionListPath(42, false)).toBe('/repos/42');
|
||||
expect(getSessionListPath('123', false)).toBe('/repos/123');
|
||||
});
|
||||
|
||||
it('returns assistant path with view=sessions for assistant sessions', () => {
|
||||
expect(getSessionListPath(42, true)).toBe('/repos/42/assistant?view=sessions');
|
||||
expect(getSessionListPath('123', true)).toBe('/repos/123/assistant?view=sessions');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSwipeBackTarget', () => {
|
||||
describe('session detail routes', () => {
|
||||
it('returns repo path for normal session detail', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/sessions/abc', '')).toBe('/repos/42');
|
||||
expect(getSwipeBackTarget('/repos/123/sessions/xyz-789', '')).toBe('/repos/123');
|
||||
});
|
||||
|
||||
it('returns assistant path for assistant session detail with assistant=1', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/sessions/abc', '?assistant=1')).toBe(
|
||||
'/repos/42/assistant?view=sessions'
|
||||
);
|
||||
expect(getSwipeBackTarget('/repos/123/sessions/xyz', '?assistant=1')).toBe(
|
||||
'/repos/123/assistant?view=sessions'
|
||||
);
|
||||
});
|
||||
|
||||
it('returns repo path when assistant param is not 1', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/sessions/abc', '?assistant=0')).toBe('/repos/42');
|
||||
expect(getSwipeBackTarget('/repos/42/sessions/abc', '?other=value')).toBe('/repos/42');
|
||||
});
|
||||
});
|
||||
|
||||
describe('assistant route', () => {
|
||||
it('returns assistant sessions path for assistant route', () => {
|
||||
expect(getSwipeBackTarget('/repos/123/assistant', '')).toBe('/repos/123/assistant?view=sessions');
|
||||
});
|
||||
|
||||
it('returns repo path for assistant session list route', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/assistant', '?view=sessions')).toBe('/repos/42');
|
||||
});
|
||||
});
|
||||
|
||||
describe('repo route', () => {
|
||||
it('returns root for repo detail', () => {
|
||||
expect(getSwipeBackTarget('/repos/42', '')).toBe('/');
|
||||
expect(getSwipeBackTarget('/repos/123', '?sort=date')).toBe('/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('memories route', () => {
|
||||
it('returns repo path', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/memories', '')).toBe('/repos/42');
|
||||
expect(getSwipeBackTarget('/repos/123/memories', '?filter=all')).toBe('/repos/123');
|
||||
});
|
||||
});
|
||||
|
||||
describe('schedules routes', () => {
|
||||
it('returns repo path for repo schedules', () => {
|
||||
expect(getSwipeBackTarget('/repos/42/schedules', '')).toBe('/repos/42');
|
||||
});
|
||||
|
||||
it('returns root for top-level schedules', () => {
|
||||
expect(getSwipeBackTarget('/schedules', '')).toBe('/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('null returns', () => {
|
||||
it('returns null for root path', () => {
|
||||
expect(getSwipeBackTarget('/', '')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for login', () => {
|
||||
expect(getSwipeBackTarget('/login', '')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for setup', () => {
|
||||
expect(getSwipeBackTarget('/setup', '')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for register', () => {
|
||||
expect(getSwipeBackTarget('/register', '')).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null for unknown paths', () => {
|
||||
expect(getSwipeBackTarget('/unknown/path', '')).toBeNull();
|
||||
expect(getSwipeBackTarget('/api/something', '')).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user