Repository navigation
feat(default-cwd): create dated folders under ~/pi-cwd using the local date - #996
Merged
Merged
Conversation
…l date "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]>
5 tasks done
dreadster3
added a commit
to dreadster3/pi-web
that referenced
this pull request
Sep 30, 2026
…ence fix + default-CWD folders (#12) * fix: do not persist new-session model picks into global defaults (agegr#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]> * feat(default-cwd): create dated folders under ~/pi-cwd using the local 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]> * fix(sidebar): keep handleDefaultCwd next to the worktree handlers 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. * chore(demo): mirror the upstream model-default selectors byte-identically 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. * chore(demo): port upstream's feature hunks into the adapted copies 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. * chore(demo): stub PUT /api/models/default in the mock 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. * chore(demo): validate default-model mock like the real route Fold-in from review: reject empty provider/modelId and validate the thinking level set, mirroring app/api/models/default/route.ts 400s. --------- Co-authored-by: luck <[email protected]> Co-authored-by: luwanglin <[email protected]> Co-authored-by: Alex Yang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
…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]> (cherry picked from commit 433d09e)
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
…egr#996 The built-in default is ~/pi-cwd/{date} now, so the initial placeholder before GET /api/default-cwd answers must show that instead of the old ~/pi-cwd-{date}.
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
…w project its own path setting Upstream closed agegr#892 in favour of agegr#996, so the configurable default cwd is gone: lib/default-cwd.ts, app/api/default-cwd/route.ts, lib/file-access.ts and lib/default-cwd.test.mjs are byte-identical to upstream/main again, and the DirectoryPicker Escape tweak that came with agegr#892 is reverted. "Use default directory" therefore keeps upstream's dated ~/pi-cwd/<YYYYMMDD> behaviour. The New project action that grew out of it keeps working through its own layer: - lib/default-project.ts stores defaultProjectPath in ~/.pi/agent/pi-web.json, empty meaning the built-in ~/pi-cwd (upstream's dated-folder parent). - GET/PUT /api/default-project own that setting; POST { name } creates or reuses <project directory>/<name>, and the sidebar selects the result through /api/cwd/validate like any other directory. - The Settings panel's General section now offers "Default project directory" instead of "Default directory" (settings.defaultProjectPath*).
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
…#907 agegr#941 agegr#946 agegr#961 agegr#968 agegr#969 agegr#1007 agegr#1008 agegr#1009 agegr#1010) 上游已把我们提前摘取的 agegr#884 / agegr#871 / agegr#996 / agegr#961 原样合并(agegr#961 逐字节相同), agegr#967 与 agegr#963 由上游的 agegr#1009 / agegr#1008 接管。 冲突解决: - demo/ 对齐上游 fe288c0,撤销 agegr#963 对 demo 的两处改动(`@/lib/chat-phase-label` 在 demo/lib 下不存在,会打断 Pages 构建)。 - AGENTS.md:保留我们的 default-project 条目,open-folder 换成上游的 open-in-explorer。 - MessageView.tsx / SessionSidebar.tsx / FileExplorer.tsx:以上游为准, DismissButton 采用上游的独立文件,保留我们的思考卡片与文件管理改动。 - SessionSidebar 移除引用已删函数的旧 agegr#951 工作区按钮(agegr#951 的其他入口另行收尾)。
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
…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]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
…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]>
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.
Summary
~/pi-cwd/YYYYMMDDinstead of creating~/pi-cwd-YYYYMMDDfolders directly in home. Folders are still dated, so a first-time user never lands in a folder holding their own data and gets a fresh scratch cwd per day.toISOString()gave the UTC date, so in UTC+8 the folder was named after yesterday until 08:00./api/default-cwdonly creates the folder and returns its path, and the sidebar passes it tocommitCustomPath(), so/api/cwd/validatechecks it, adds it to the file allow-list, and resolves its project identity.remember: falsekeeps it from replacing the custom-path picker's last path.~/pi-cwd-YYYYMMDDfolders with sessions stay browsable as session cwds; selecting one again goes through/api/cwd/validate.Supersedes the approach in #892 (configurable default path): the dated name is deliberate, so only its location changes.
Test plan
lib/default-cwd.test.mjs: local date stamp (checked underTZ=Asia/ShanghaiandTZ=America/Los_Angeles), path under~/pi-cwdcomponents/SessionSidebar.project-identity.test.mjs: default cwd goes throughcommitCustomPath(..., { remember: false })tsc --noEmit, eslint on changed filesPOST /api/default-cwd→POST /api/cwd/validate→ file list200, sidebar shows~/pi-cwd/20260929,pi-web:last-custom-cwduntouched, no console errors🤖 Generated with Claude Code