docs/working-directories.md
Working directories
The sidebar directory control lists exact persisted root cwd strings from
list_cwd, together with directories chosen during this app process. Add starts
at / and uses builtin.complete-files with an absolute @/… query. Only
absolute directory suggestions (display paths ending in /) appear. The path
is taken from the display field, not from the macro's chat replacement syntax;
spaces and apostrophes therefore remain literal path characters. Completion demand
is debounced by 200 ms, with at most one RPC in flight and only the latest pending
path retained. Dialog dismissal or scope retirement prevents further admission;
late results and obsolete failures never update the dialog or generate toasts.
Add validates absolute paths without CR, LF or NUL before queuing/encoding; invalid
input displays no suggestions and does not strand the single-flight slot. Its
atomic demand revision also rejects superseded or dismissed requests that have
been pumped but not yet admitted by the transport worker. Worker checks never
read dialog/UI state. The Add debounce remains 200 ms; composer completion below
reuses its existing 150 ms scheduler rather than changing either scheduler.
The anchored directory list and selected directory button use a single line with
start ellipsis, keeping the path tail visible when width is constrained (for
example …/task-name/worktree). Every row still holds the exact full path as its
selection value and accessibility description; the selected button describes the
full path and keeps its separate end dropdown icon. Add directory… is a
distinct final action, not a directory. Dismissal, screen stop, selection/scope
retirement and endpoint switching retire the popup and unadmitted Add completion
demand. Inbox headings remain full-path wrapping headings, not abbreviated labels.
Android-local /cwd
- Bare
/cwdopens the session/directory drawer and selects Sessions, even offline or while remote macro/model discovery is unavailable. It does not start a prompt, create a helper/session, or change the connection directory. Offline navigation applies to an already-open chat after connection loss. Explicit Disconnect still closes that chat, and starting a chat without a connection still returns to the connection list. /cwd /absolute/pathuses the same asynchronousupdate_cwd(new_cwd)browsing operation as the directory control. Only a successful, still-owned acknowledgement changes the local browsing scope and opens Sessions. It does not supply a leaf ID, edit the selected root, or save a new profile cwd. A failed, superseded, disconnected, endpoint-retired, selection-retired or stopped-screen command cannot open a stale drawer or overwrite the current browsing scope. An already admitted wire update cannot be retracted; stale acknowledgement handling is not a claim that the server rolled it back.- Every recognized
/cwdinvocation stays local, including incomplete/unsupported arguments. Relative paths, multiline/NUL arguments and disconnected parameterized invocations receive an explicit local notice, never an agent prompt. Use an absolute path; there is no shell parsing, quoting,~expansion, normalization or cwd-relative resolution. Spaces, apostrophes, trailing path spaces and..remain exact path characters. Do not wrap space-containing paths in shell quotes.
Composer completion suggests exact known absolute persisted/RAM choices already
discovered by this endpoint, including its current directory. /cwd /… additionally
queries builtin.complete-files with the existing CSV query,0,@/… grammar and no
leaf/helper creation. It uses the composer's 150 ms debounce, single in-flight
chain, latest pending demand and visit/input ownership guards, not a separate
completion pipeline. Directory parsing is shared with Add: only absolute display
paths ending in / become candidates; chat replacements, files and relative
suggestions are ignored. Accepted paths replace the argument verbatim, without
@, brackets or shell quoting, and directory tails can reopen completion.
Cancellation/dismissal and navigation retire queued demand before transport
admission; admitted work may finish, but stale replies never edit the composer.
Choices belong to one endpoint runtime. Switching endpoints and returning does not restore the saved profile cwd over a live choice. Runtime choices are not written to profiles or to persisted selection-map keys. They disappear on process reload; the saved profile's initial cwd remains its initial configuration.
Inbox defaults to All directories on that endpoint. Its switch can limit it to Current directory. Background Inbox monitoring and quiet-baseline/alert state remain endpoint-global regardless of that presentation switch. Replies from other endpoint connections never populate this endpoint's Inbox.
Both Inbox views show cwd headings: the selected directory's group first, then
other exact paths in lexicographic order. Entries retain newest-alert order
within each group. Headings use persisted root cwd from optional batched
list_roots enrichment. Leaves publish without waiting for that lookup; late
mapping can enrich only its own current snapshot. At most one roots request is
outstanding per sidebar connection generation, so a stalled optional lookup does
not accumulate one request per leaf refresh. The connection default is never a
substitute. Missing or unavailable mappings form one Unknown working directory
group last, including while root lookup remains pending or cannot be admitted.
Search retains its name/model semantics and omits empty groups.
Headings wrap, are accessibility headings, and have no open or context actions.
Sessions always requests an explicit nonempty cwd. If the initial profile cwd is empty, the first known directory is selected; with no known directories, the control remains Choose directory and full session browsing and first-send creation are disabled until an explicit selection. Empty never means “all sessions.” Existing profiles with a configured initial cwd retain it.
Opening a session resolves its persisted directory through the existing exact-leaf
leaf_stats.root_cwd (no filesystem scans or full root inventory), validating the
reply's leaf identity and persistent-session status. Missing or invalid directory
authority fails closed, without substituting an Intent path or connection default.
It uses that exact cwd as the browsing context, and the feed owner's
update_cwd(new_cwd, leaf_id) changes default and subscription together. It does
not rewrite the root. Selecting a directory without opening a session uses
update_cwd(new_cwd) and does not pretend to change a selected root's cwd.
Dropdown, Add and typed command acknowledgements all require the captured live
endpoint, selection, lifecycle epoch and directory intent, irrespective of whether
they open Sessions. Presentation-only tab/filter changes do not retire an admitted
directory choice; sidebar presentation epochs are not mutation ownership guards.
Existing subscription acknowledgement, replay, drop, history, and selection
ownership gates remain in the conversation controller.
Integration validation
Focused JVM selections:
name.devnull.ezagent.android.connection.DirectoryStateTestname.devnull.ezagent.android.composer.CwdCommandsTestname.devnull.ezagent.android.ui.DirectoryPopupTestname.devnull.ezagent.android.ui.composer.CompletionUiTestname.devnull.ezagent.android.ui.ChatDirectoryNavigationUiTestname.devnull.ezagent.android.connection.DirectoryCompletionQueueTestname.devnull.ezagent.android.conversation.DirectoryNavigationWireTestname.devnull.ezagent.android.conversation.RecoveryAdmissionTestname.devnull.ezagent.android.chat.ChatRuntimeIntegrationTestname.devnull.ezagent.android.connection.RuntimeDirectoryStoreTestname.devnull.ezagent.android.ui.sidebar.SessionSidebarControllerTestname.devnull.ezagent.android.connection.EndpointMonitorTest
Also run the existing workspace, conversation, chat-runtime, endpoint-switching,
and UI suites after integration. Required Android exercise: dropdown and Add,
space-containing path completion, cwd A/B and endpoint away/back RAM retention,
process reload, empty-profile/no-roots gating, global/current Inbox, cross-cwd
Inbox opening with root-derived cwd, and unchanged history/reading restoration.
Also exercise narrow-width shared-prefix dropdown/selected-button tails, full-path
accessibility, Add/dismiss/stop, bare /cwd from Inbox and offline, parameterized
/cwd success/failure, space/apostrophe directory-only autocomplete, quick edits,
selection/endpoint changes and screen stop with held replies. JVM test additions
alone are not Android validation evidence.