Repository navigation
chore: sync upstream (agegr/pi-web @ 433d09e) — model-default persistence fix + default-CWD folders - #12
Merged
Conversation
…gr#871) * fix: do not persist new-session model picks into global defaults Selecting a model for a single Pi Web chat was rewriting ~/.pi/agent/settings.json via persistExplicitStartupPreferences, so a one-off DeepSeek/flash pick silently became the CLI/global default. Align with the TUI: session-scoped selection unless the user explicitly opts into persist (future "Save as default"). * feat: explicit save-as-default for model and reasoning level With new-session picks now session-scoped, pi-web had no way left to change the default model or reasoning level. Add the Web counterpart of the TUI's Ctrl+S: a star on each row of the model selector and the reasoning menu. - PUT /api/models/default writes defaultProvider/defaultModel or defaultThinkingLevel, only for models the selector can offer, and refuses with 409 when a trusted project's .pi/settings.json overrides the key. - The star saves the default and selects it for the current chat. - Menu rows use SelectorRow, styled like session-list rows: the save star floats on hover/focus (always visible on touch), the default gets an inline marker. - Remove the no-op startup-preferences helper and its call site. Co-Authored-By: Claude Opus 5.5 <[email protected]> * style: simpler default marker in model and reasoning menus Drop the session-list accent bar on the active row and the inline star after the default's name. The default row now shows a small static grey star in the right gutter, the same spot where the save button floats in on hover or focus, so an idle menu carries a single marker. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: luwanglin <[email protected]> Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…l date (agegr#996) "Use default directory" now opens ~/pi-cwd/YYYYMMDD instead of scattering ~/pi-cwd-YYYYMMDD folders across home. The date still keeps a first-time user out of folders that hold their own data and gives a fresh scratch cwd per day. The stamp is the local calendar date; toISOString() gave the UTC one, so in UTC+8 the folder was named after yesterday until 08:00. The default directory is now selected exactly like any other directory. /api/default-cwd only creates the folder and returns its path; the sidebar then passes it to commitCustomPath(), so /api/cwd/validate checks it, adds it to the file allow-list, and resolves its project identity. The only difference is remember: false, so it does not replace the custom-path picker's last path. With that, the allow-list no longer scans home for default cwds at all. Older ~/pi-cwd-YYYYMMDD folders with sessions are ordinary session cwds, and selecting any dated folder again goes through /api/cwd/validate. Co-authored-by: Claude Opus 5.5 <[email protected]>
The fork's branch quick-switch added `handleUseBranch` right after `handleDefaultCwd`, so the source slice the project-identity test reads (handleDefaultCwd → handleCreateWorktree) swallowed a `setSelectedCwd` call and the assertion failed. Move `handleUseBranch` above `handleDefaultCwd` instead: `handleCreateWorktree` closes over it, so moving it below would trip the temporal dead zone. Functionally neutral — no body change, only declaration order. Follow-up to upstream 433d09e, which added the test and the commitCustomPath `remember` param the slice also asserts on.
…ally Port the byte-identical mirrors from upstream 6a1246e so the demo copies stay byte-identical mirrors of the root files as they were before the merge: ChatInput, ModelSelector, useAgentSession, models-cache and the three i18n message files, plus the new SelectorRow both selectors import.
ChatWindow and SessionSidebar are pre-adapted demo copies, so they get the feature hunks from 6a1246e (defaultModel/savedDefaultThinkingLevel props into ChatInput) and 433d09e (commitCustomPath's remember param plus the handleDefaultCwd -> commitCustomPath hand-off) rather than a byte copy. Their divergence from the root is unchanged, 3 and 39 diff lines.
The model and reasoning selectors' star now writes the global default through PUT /api/models/default (upstream 6a1246e); the demo has no real models.json, so the mock records the pick in memory and serves it back as `defaultModel` / `savedDefaultThinkingLevel` from GET /api/models, the same way the other mutable settings panels work in the demo. POST /api/default-cwd already exists and needs no change: 433d09e only made the client select its result through /api/cwd/validate, which the mock's cwdRoute already answers for SCRATCH_ROOT.
Fold-in from review: reject empty provider/modelId and validate the thinking level set, mirroring app/api/models/default/route.ts 400s.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Periodic upstream sync — this time a clean merge with zero conflicts, plus fork-side finishing commits.
Upstream contents (merged as-is)
6a1246e— fix: do not persist new-session model picks into global defaults (fix: do not persist new-session model picks into global defaults agegr/pi-web#871). Introduceslib/default-preferences.ts,app/api/models/default/route.ts, star-to-save-default in the model/reasoning selectors (SelectorRow), and removeslib/startup-preferences.{ts,.test.mjs}.433d09e— feat(default-cwd): dated folders under~/pi-cwdvia a "default cwd" shortcut that runs through the same server-side validation as a custom path (newlib/default-cwd.ts+ source-inspection test).Fork-side commits
1063399— merge ofupstream/mainbe66efc— fix(sidebar): pure relocation of ourhandleUseBranchcallback so upstream's new source-slice test (asserts thehandleDefaultCwd → handleCreateWorktreewindow contains nosetSelectedCwd) passes against our adapted file. Functionally inert: declaration order satisfied, no body edits, no TDZ (the worktree handler reads the binding during render, so the callback stays declared before it).0db5112— demo byte-mirrors rebuilt: ChatInput, ModelSelector, SelectorRow (new), useAgentSession, models-cache, i18n ×3 — allcmp-identical to root.38eee82— adapted demo copies ported, not copied: ChatWindow (divergence stays exactly the pre-merge 3demoAssetPathlines) and SessionSidebar (divergence stays exactly the pre-merge 39 de-memo lines); both received upstream's feature hunks (default-model props / default-cwd hand-off).8964a93+7284778— demo mockPUT /api/models/defaultwith the real route's contract (200{ok, defaultModel|defaultThinkingLevel}, 400 with the same error string, empty-string + thinking-level validation folded in from review), canned/interactive style consistent with the rest of the demo mocks. Rootapp/apiis byte-identical to upstream.Not mirrored to demo (verified zero demo-side imports):
lib/default-cwd.ts,default-preferences.ts,rpc-manager.ts,file-access.ts,enabled-models-runtime.ts.Gates
npx tsc --noEmitroot + demo ✅ · eslint on changed files ✅ ·env -u PI_WEB_IDLE_TIMEOUT_MS npm test: 1423 tests / 1422 pass, sole failure the pre-approvedlib/skill-lock.test.mjsXDG case ✅ · byte-mirror parity 8/8 ✅ · adapted-copy divergence scope unchanged (3/39 lines) ✅ · reviewed: SHIP (reviewer re-computed diff scope, relocation purity, mock contract, and left-absent imports).