Skip to content

FreshOpenCode reports wrong working directory on launch #436

Description

@danshapiro

Summary

When launching a freshopencode pane from a directory other than the freshell project root (e.g. ~/code/foo), the agent reports its working directory as ~/code/freshell instead of the intended directory.

Steps to Reproduce

  1. Launch freshopencode in directory ~/code/foo
  2. Ask the agent "what directory are we in?"
  3. It responds with ~/code/freshell instead of ~/code/foo

Expected Behavior

The agent should report the directory it was launched in (i.e. the cwd/initialCwd provided when the pane was created).

Investigative Notes

  • The freshAgent.create WS message sends cwd: content.initialCwd (src/components/fresh-agent/FreshAgentView.tsx:576)
  • The server passes m.cwd to the runtime manager (server/ws-handler.ts:3093)
  • The opencode adapter stores cwd: normalized.cwd on session create (server/fresh-agent/adapters/opencode/adapter.ts:394)
  • The PTY/CLI is spawned via runCli with the stored cwd (server/fresh-agent/adapters/opencode/adapter.ts:341)
  • The adapter then uses runCli([export, sessionId], cwd) for history reads (server/fresh-agent/adapters/opencode/adapter.ts:309)

The issue may be in how the cwd flows from the UI/initial pane setup through to the adapter — or in how the initialCwd is resolved when creating the pane, potentially falling back to the server process cwd (~/code/freshell).

Affected Components

  • server/fresh-agent/adapters/opencode/adapter.ts
  • src/components/fresh-agent/FreshAgentView.tsx
  • Possibly the pane creation/cwd resolution flow in the Redux store

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions