|
1 | 1 | # Active Context |
2 | 2 |
|
3 | | -**Last Updated**: 2026-03-07 |
4 | | -**Current Phase**: Post v0.6.0 — z-index fix + GPT-5.4 + .env improvements |
5 | | -**Next Action**: PR ready for review |
| 3 | +**Last Updated**: 2026-03-08 |
| 4 | +**Current Phase**: `question-refinement` branch — pre-consensus question refinement, native web search, citations, tools-by-default |
| 5 | +**Next Action**: Branch in progress, uncommitted changes staged |
6 | 6 |
|
7 | | -## Latest Work (2026-03-07) |
| 7 | +## Latest Work (2026-03-08) |
8 | 8 |
|
9 | | -### Z-index stacking context fix |
10 | | -- **Problem**: Nested stacking contexts (`z-10` on main content, `z-20` on TopBar header) trapped dropdowns inside containers. Account menu's `fixed inset-0 z-40` backdrop was meaningless outside its container. |
11 | | -- **Fix**: Removed unnecessary z-index values creating stacking contexts, added `isolate` to Shell root, defined z-index tokens in CSS (`--z-background`, `--z-dropdown`, `--z-overlay`, `--z-modal`), replaced backdrop hack with `useRef` + `mousedown` click-outside pattern (matching ExportMenu). |
12 | | -- Files: `duh-theme.css`, `Shell.tsx`, `TopBar.tsx`, `GridOverlay.tsx`, `ParticleField.tsx`, `ExportMenu.tsx`, `ConsensusComplete.tsx`, `ThreadDetail.tsx` |
| 9 | +### Question Refinement |
| 10 | +- Pre-consensus clarification step: analyze question → ask clarifying questions → enrich with answers → proceed to consensus |
| 11 | +- `src/duh/consensus/refine.py` — `analyze_question()` + `enrich_question()`, uses MOST EXPENSIVE model (not cheapest) |
| 12 | +- API: `POST /api/refine` → `RefineResponse{needs_refinement, questions[]}`, `POST /api/enrich` → `EnrichResponse{enriched_question}` |
| 13 | +- CLI: `duh ask --refine "question"` — interactive `click.prompt()` loop, default `--no-refine` |
| 14 | +- Frontend: consensus store `'refining'` status, `submitQuestion` → refine → clarify → enrich → `startConsensus` |
| 15 | +- `RefinementPanel.tsx` — tabbed UI inside GlassPanel, checkmarks on answered tabs, Skip + Start Consensus buttons |
| 16 | +- Graceful fallback: any failure → proceed to consensus with original question |
13 | 17 |
|
14 | | -### GPT-5.4 added to model catalog |
15 | | -- `gpt-5.4`: 1M context, 128K output, $2.50/$15.00 per MTok, no temperature (uses reasoning.effort) |
16 | | -- Added to `NO_TEMPERATURE_MODELS` set |
17 | | -- File: `src/duh/providers/catalog.py` |
| 18 | +### Native Provider Web Search |
| 19 | +- Providers use server-side search instead of DDG proxy when `config.tools.web_search.native` is true |
| 20 | +- `web_search: bool` param added to `ModelProvider.send()` protocol |
| 21 | +- Anthropic: `web_search_20250305` server tool in tools[] |
| 22 | +- Google: `GoogleSearch()` grounding (replaces function tools — can't coexist) |
| 23 | +- Mistral: `{"type": "web_search"}` appended to tools |
| 24 | +- OpenAI: `web_search_options={}` only for `_SEARCH_MODELS` set; others fall back to DDG |
| 25 | +- Perplexity: no-op (always searches natively) |
| 26 | +- `tool_augmented_send`: filters DDG `web_search` tool when native=True, passes flag to provider |
18 | 27 |
|
19 | | -### .env improvements |
20 | | -- Added provider API key placeholders to `.env.example` (ANTHROPIC, OPENAI, GOOGLE, PERPLEXITY, MISTRAL) |
21 | | -- Updated README quick start with all provider env vars + `.env` reference |
22 | | -- Note: Google key env var is `GOOGLE_API_KEY` (not `GEMINI_API_KEY`) |
| 28 | +### Citations — Persisted + Domain-Grouped |
| 29 | +- `Citation` dataclass (url, title, snippet) on `ModelResponse.citations` |
| 30 | +- Extraction per provider: Anthropic (`web_search_tool_result`), Google (grounding metadata), Perplexity (`response.citations`) |
| 31 | +- **Persistence**: `citations_json` TEXT column on `Contribution` model, SQLite auto-migration via `ensure_schema()` |
| 32 | +- `proposal_citations` tracked on `ConsensusContext` → archived to `RoundResult` → persisted via `_persist_consensus` |
| 33 | +- Thread detail API returns `citations` on `ContributionResponse` |
| 34 | +- **Domain-grouped Sources nav**: ConsensusNav (live) + ThreadNav (stored) group citations by hostname |
| 35 | + - Nested Disclosure: outer "Sources (17)" → inner "wikipedia.org (3)" → P/C/R role badges per citation |
| 36 | + - P (green) = propose, C (amber) = challenge, R (blue) = revise |
| 37 | +- `CitationList` shared component for inline display below content |
| 38 | + |
| 39 | +### Anthropic Streaming + max_tokens |
| 40 | +- `AnthropicProvider.send()` now uses streaming internally via `_collect_stream()` — avoids 10-minute timeout |
| 41 | +- `max_tokens` bumped from 16384 → 32768 across all 6 handler defaults (propose, challenge, revise, commit, voting, decomposition) |
| 42 | +- Citations are part of the value — truncating them undermines trust |
| 43 | + |
| 44 | +### Parallel Challenge Streaming |
| 45 | +- `_stream_challenges()` in `ws.py` uses `asyncio.as_completed()` to send each challenge result to the frontend as it finishes |
| 46 | +- Previously: all challengers ran in parallel but results were batched after all completed |
| 47 | +- Now: first challenger to respond appears immediately in the UI |
| 48 | + |
| 49 | +### Tools Enabled by Default |
| 50 | +- `web_search` tool wired through CLI, REST, and WebSocket paths by default |
| 51 | +- Provider tool format fix: `tool_augmented_send` builds generic `{name, description, parameters}` — each provider transforms to native format in `send()` |
| 52 | + |
| 53 | +### Sidebar UX |
| 54 | +- New-question button (Heroicons pencil-square) + collapsible sidebar toggle |
| 55 | +- Shell manages `desktopSidebarOpen` (default true) + `mobileSidebarOpen` separately |
| 56 | +- TopBar shows sidebar toggle when desktop sidebar collapsed or always on mobile |
23 | 57 |
|
24 | 58 | ### Test Results |
25 | | -- 1603 Python tests + 185 Vitest tests (1788 total) |
| 59 | +- 1641 Python tests + 194 Vitest tests (1835 total) |
26 | 60 | - Build clean, all tests pass |
27 | 61 |
|
28 | 62 | --- |
29 | 63 |
|
30 | 64 | ## Current State |
31 | 65 |
|
32 | | -- **Branch `ux-cleanup`** — z-index fix, GPT-5.4, .env docs |
33 | | -- **1603 Python tests + 185 Vitest tests** (1788 total) |
| 66 | +- **Branch `question-refinement`** — in progress, not yet merged |
| 67 | +- **1641 Python tests + 194 Vitest tests** (1835 total) |
34 | 68 | - All previous features intact (v0.1–v0.6) |
| 69 | +- Prior work merged: z-index fix, GPT-5.4, .env docs, password reset |
35 | 70 |
|
36 | 71 | ## Open Questions (Still Unresolved) |
37 | 72 |
|
|
0 commit comments