Skip to content

chore: sync upstream (agegr/pi-web @ 433d09e) — model-default persistence fix + default-CWD folders - #12

Merged
dreadster3 merged 8 commits into
mainfrom
chore/sync-upstream-2
Sep 30, 2026
Merged

dreadster3 merged 8 commits into
mainfrom
chore/sync-upstream-2

Conversation

@dreadster3

Copy link
Copy Markdown
Owner

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). Introduces lib/default-preferences.ts, app/api/models/default/route.ts, star-to-save-default in the model/reasoning selectors (SelectorRow), and removes lib/startup-preferences.{ts,.test.mjs}.
  • 433d09e — feat(default-cwd): dated folders under ~/pi-cwd via a "default cwd" shortcut that runs through the same server-side validation as a custom path (new lib/default-cwd.ts + source-inspection test).

Fork-side commits

  • 1063399 — merge of upstream/main
  • be66efc — fix(sidebar): pure relocation of our handleUseBranch callback so upstream's new source-slice test (asserts the handleDefaultCwd → handleCreateWorktree window contains no setSelectedCwd) 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 — all cmp-identical to root.
  • 38eee82 — adapted demo copies ported, not copied: ChatWindow (divergence stays exactly the pre-merge 3 demoAssetPath lines) 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 mock PUT /api/models/default with 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. Root app/api is 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 --noEmit root + demo ✅ · eslint on changed files ✅ · env -u PI_WEB_IDLE_TIMEOUT_MS npm test: 1423 tests / 1422 pass, sole failure the pre-approved lib/skill-lock.test.mjs XDG 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).

luck and others added 8 commits September 29, 2026 22:02
…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.
@dreadster3
dreadster3 merged commit 39e4dde into main Sep 30, 2026
4 checks passed
@dreadster3
dreadster3 deleted the chore/sync-upstream-2 branch September 30, 2026 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants