Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(agent/agentcontainers): allow auto start for discovered containers#19040

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

DanielleMaywood
Copy link
Contributor

strings.HasPrefix(s,"CODER_AGENT_AUTH=")||
strings.HasPrefix(s,"CODER_AGENT_DEVCONTAINERS_ENABLE=")
strings.HasPrefix(s,"CODER_AGENT_DEVCONTAINERS_ENABLE=")||
strings.HasPrefix(s,"CODER_AGENT_DEVCONTAINERS_PROJECT_DISCOVERY_ENABLE=")
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Missed this in a previous PR#19016

mtojek reacted with thumbs up emoji
@DanielleMaywoodDanielleMaywoodforce-pushed thedanielle/autostart-discovered-workspaces branch fromee6b803 todf5255bCompareJuly 28, 2025 09:26
}

api.knownDevcontainers[workspaceFolder]=dc
api.broadcastUpdatesLocked()
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We'll now broadcast updates as we find the dev containers. This makes it feel a little quicker when there is a lot of files being searched through.

@DanielleMaywoodDanielleMaywood marked this pull request as ready for reviewJuly 28, 2025 09:47
@DanielleMaywood
Copy link
ContributorAuthor

@coderabbitai review

coderabbitai[bot] reacted with eyes emoji

@coderabbitaicoderabbitai
Copy link

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitaicoderabbitai
Copy link

📝 Walkthrough

Walkthrough

The changes introduce support for automatically starting devcontainers during project discovery if their configuration specifiesAutoStart: true. This includes updating the devcontainer status, launching asynchronous container creation, filtering a specific environment variable, enhancing logging context, and adding comprehensive tests to verify the new auto-start behavior.

Changes

Cohort / File(s)Change Summary
AutoStart field addition
agent/agentcontainers/devcontainercli.go
AddedAutoStart boolean field to theCoderCustomization struct for JSON serialization.
Devcontainer discovery & auto-start logic
agent/agentcontainers/api.go
Enhanced project discovery to read theAutoStart flag from devcontainer config, set initial status, and asynchronously start containers when required. Improved logger context and filtered an additional environment variable.
Auto-start behavior tests
agent/agentcontainers/api_test.go
Added new subtests toTestDevcontainerDiscovery to verify auto-start logic, including multiple scenarios with differentAutoStart flag settings and corresponding expectations for container startup.

Sequence Diagram(s)

sequenceDiagram    participant User    participant API    participant DevcontainerCLI    User->>API: Triggers project discovery    API->>DevcontainerCLI: ReadConfig(devcontainer.json)    DevcontainerCLI-->>API: Returns config (with AutoStart flag)    API->>API: If AutoStart == true, set status to "Starting"    API->>API: Broadcast devcontainer update    API->>DevcontainerCLI: (async) CreateDevcontainer(workspace, configPath)    DevcontainerCLI-->>API: (container started)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

ObjectiveAddressedExplanation
Scan repositories for non-started devcontainers (devcontainer.json) and prompt in the UI to start them (#711)
Support a customization to auto start devcontainers via.customizations.coder.autostart = true (#711)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

Suggested reviewers

  • mafredri
  • mtojek

Note

⚡️ Unit Test Generation is now available in beta!

Learn morehere, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branchdanielle/autostart-discovered-workspaces

🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on oursupport page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings togenerate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add@coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

Copy link

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
agent/agentcontainers/api.go (2)

146-147:LGTM!

Correctly filters out the project discovery environment variable to prevent configuration conflicts between parent and child agents.


553-553:Broadcasting updates during discovery improves UX.

This allows the UI to show devcontainers as they're discovered rather than waiting for the entire discovery process to complete.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between398e80f and02e606e.

📒 Files selected for processing (3)
  • agent/agentcontainers/api.go (2 hunks)
  • agent/agentcontainers/api_test.go (1 hunks)
  • agent/agentcontainers/devcontainercli.go (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
agent/agentcontainers/api_test.go (5)

Learnt from: CR
PR: coder/coder#0
File: .cursorrules:0-0
Timestamp: 2025-07-21T14:32:43.064Z
Learning: Applies to **/*_test.go : All tests must uset.Parallel() to run concurrently, which improves test suite performance and helps identify race conditions.

Learnt from: CR
PR: coder/coder#0
File: .cursorrules:0-0
Timestamp: 2025-07-21T14:32:43.064Z
Learning: Applies to **/*_test.go : All tests should run in parallel usingt.Parallel() to ensure efficient testing and expose potential race conditions.

Learnt from: CR
PR: coder/coder#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T00:33:07.777Z
Learning: Applies to **/*_test.go : Use unique identifiers (e.g., fmt.Sprintf("test-client-%s-%d", t.Name(), time.Now().UnixNano())) and never use hardcoded names in concurrent tests to prevent race conditions.

Learnt from: CR
PR: coder/coder#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T00:33:07.155Z
Learning: Applies to **/*_test.go : Use unique identifiers (e.g., fmt.Sprintf("test-client-%s-%d", t.Name(), time.Now().UnixNano())) and never use hardcoded names in concurrent tests to prevent race conditions.

Learnt from: CR
PR: coder/coder#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-28T00:33:10.063Z
Learning: Applies to **/*_test.go : Use unique identifiers (e.g., fmt.Sprintf("test-client-%s-%d", t.Name(), time.Now().UnixNano())) and never use hardcoded names in concurrent tests to prevent race conditions.

🔇 Additional comments (3)
agent/agentcontainers/devcontainercli.go (1)

94-94:LGTM!

TheAutoStart field is correctly added to theCoderCustomization struct with appropriate JSON serialization tags.

agent/agentcontainers/api.go (1)

528-528:Good addition of workspace folder context to logger.

This improves traceability during project discovery.

agent/agentcontainers/api_test.go (1)

3572-3816:LGTM! Well-implemented test for auto-start functionality.

This new test comprehensively validates the auto-start behavior described in the PR objectives. The implementation follows established patterns and best practices:

  • Properly usest.Parallel() as required by the coding guidelines
  • Covers multiple scenarios: single enabled/disabled, mixed configurations, and multiple enabled devcontainers
  • Uses proper mock expectations withgomock.InOrder() to verify thatUp() is called only for devcontainers withAutoStart: true
  • Follows the existing test structure and cleanup patterns
  • Uses appropriate test utilities and context handling

The test effectively validates that discovered devcontainers with theAutoStart flag set will trigger container creation viaUp(), while those without it will not, which aligns perfectly with the PR's goal of implementing auto-start for discovered containers.

Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM!

gofunc() {
deferapi.asyncWg.Done()

_=api.CreateDevcontainer(dc.WorkspaceFolder,dc.ConfigPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: I suppose it returns an error, should we log it somewhere?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

CreateDevcontainer already does a reasonable amount of logging. I don't think theerror returned has any additional information to what is already logged.

mtojek reacted with thumbs up emoji
// detects an error has been logged.
})

t.Run("AutoStart",func(t*testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice tests!

@DanielleMaywoodDanielleMaywood merged commit66cf90c intomainJul 28, 2025
26 checks passed
@DanielleMaywoodDanielleMaywood deleted the danielle/autostart-discovered-workspaces branchJuly 28, 2025 11:30
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJul 28, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@mtojekmtojekmtojek approved these changes

@mafredrimafredriAwaiting requested review from mafredri

+1 more reviewer

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

Reviewers whose approvals may not affect merge requirements
Assignees

@DanielleMaywoodDanielleMaywood

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Devcontainers: Scan repositories for non-started devcontainers (devcontainer.json) and prompt in the UI to start them
3 participants
@DanielleMaywood@johnstcn@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp