ResumeWorkingDir looks up the session named by --session and returns the working directory it was created with. It opens (and shares) the same session store CreateSession uses, so this peek does not pay for a second connection. Both explicit IDs and relative refs (e.g. "-1" for the last session) are
(ctx context.Context)
| 144 | // stored dir, or a dir that no longer exists — returns ok=false and leaves the |
| 145 | // run to its normal working-directory resolution. |
| 146 | func (b *localBackend) ResumeWorkingDir(ctx context.Context) (string, bool) { |
| 147 | if b.flags.sessionID == "" { |
| 148 | return "", false |
| 149 | } |
| 150 | |
| 151 | store, err := b.sessionStore(ctx, b.flags.createSessionRequest("")) |
| 152 | if err != nil { |
| 153 | return "", false |
| 154 | } |
| 155 | |
| 156 | // Relative refs (-1, -2, ...) resolve against the shared store here, which |
| 157 | // is already open at this point, so they reattach to their worktree too. |
| 158 | resolvedID, err := session.ResolveSessionID(ctx, store, b.flags.sessionID) |
| 159 | if err != nil { |
| 160 | return "", false |
| 161 | } |
| 162 | sess, err := store.GetSession(ctx, resolvedID) |
| 163 | if err != nil || sess.WorkingDir == "" { |
| 164 | return "", false |
| 165 | } |
| 166 | if fi, err := os.Stat(sess.WorkingDir); err != nil || !fi.IsDir() { |
| 167 | return "", false |
| 168 | } |
| 169 | return sess.WorkingDir, true |
| 170 | } |
| 171 | |
| 172 | func (b *localBackend) Close() error { |
| 173 | // Ensure any in-progress sessionStore initialization is observed |
nothing calls this directly
no test coverage detected